mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add tests for MainScope and UserJob getters/setters
This commit is contained in:
parent
949c5424f0
commit
fc919e9547
@ -288,6 +288,11 @@ class User implements UserInterface, \Stringable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMainScopeHistories(): Collection
|
||||||
|
{
|
||||||
|
return $this->scopeHistories;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -332,6 +337,11 @@ class User implements UserInterface, \Stringable
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserJobHistories(): Collection
|
||||||
|
{
|
||||||
|
return $this->jobHistories;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
72
src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php
Normal file
72
src/Bundle/ChillMainBundle/Tests/Entity/UserTest.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
|
|
||||||
|
class UserTest extends TestCase
|
||||||
|
{
|
||||||
|
use ProphecyTrait;
|
||||||
|
|
||||||
|
public function testMainScopeHistory()
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
$scopeA = new Scope();
|
||||||
|
$scopeB = new Scope();
|
||||||
|
|
||||||
|
$user->setMainScope($scopeA);
|
||||||
|
$user->setMainScope($scopeB);
|
||||||
|
|
||||||
|
// 1. check getMainScope get now scopeB, not scopeA
|
||||||
|
self::assertSame($scopeB, $user->getMainScope());
|
||||||
|
|
||||||
|
// 2. get scopeA history, check endDate is not null
|
||||||
|
$histories = $user->getMainScopeHistories();
|
||||||
|
$scopeHistoryA = null;
|
||||||
|
foreach ($histories as $row) {
|
||||||
|
/** @var User\UserScopeHistory $row */
|
||||||
|
if ($scopeA === $row->getScope()) {
|
||||||
|
$scopeHistoryA = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::assertNotNull($scopeHistoryA->getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUserJobHistory()
|
||||||
|
{
|
||||||
|
$user = new User();
|
||||||
|
$jobA = new UserJob();
|
||||||
|
$jobB = new UserJob();
|
||||||
|
|
||||||
|
$user->setUserJob($jobA);
|
||||||
|
$user->setUserJob($jobB);
|
||||||
|
|
||||||
|
// 1. check getUserJob get now jobB, not jobA
|
||||||
|
self::assertSame($jobB, $user->getUserJob());
|
||||||
|
|
||||||
|
// 2. get jobA history, check endDate is not null
|
||||||
|
$histories = $user->getUserJobHistories();
|
||||||
|
$jobHistoryA = null;
|
||||||
|
foreach ($histories as $row) {
|
||||||
|
/** @var User\UserJobHistory $row */
|
||||||
|
if ($jobA === $row->getJob()) {
|
||||||
|
$jobHistoryA = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self::assertNotNull($jobHistoryA->getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user