1 | <?php |
||
14 | class UserRepositoryTest extends \PHPUnit_Framework_TestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var \Doctrine\Common\DataFixtures\Executor\AbstractExecutor |
||
18 | */ |
||
19 | protected $fixtureExectutor; |
||
20 | |||
21 | /** |
||
22 | * @var \JhUser\Repository\UserRepository |
||
23 | */ |
||
24 | protected $repository; |
||
25 | |||
26 | public function setUp() |
||
33 | |||
34 | public function testGetAllUsers() |
||
41 | |||
42 | public function testGetAllUsersWithPagination() |
||
49 | |||
50 | public function testFindOneByEmailReturnsNullIfNotExists() |
||
54 | |||
55 | public function testFindOneByEmailReturnsUserIfExists() |
||
65 | |||
66 | public function testFindOneByReturnsNullIfNotExists() |
||
70 | |||
71 | public function testFindOneByReturnsUserIfExists() |
||
72 | { |
||
73 | $user = new SingleUser(); |
||
74 | $this->fixtureExectutor->execute([$user]); |
||
75 | $result = $this->repository->findOneBy(["email" => "[email protected]"]); |
||
76 | $this->assertInstanceOf('JhUser\Entity\User', $result); |
||
77 | $this->assertSame($user->getUser()->getEmail(), $result->getEmail()); |
||
78 | $this->assertSame($user->getUser()->getPassword(), $result->getPassword()); |
||
79 | $this->assertSame($user->getUser()->getId(), $result->getId()); |
||
80 | } |
||
81 | |||
82 | public function testFindByReturnsEmptyIfNonExist() |
||
86 | |||
87 | public function testFindByReturnsCollectionIfExist() |
||
88 | { |
||
89 | $this->assertEmpty($this->repository->findBy(['email' => '[email protected]'])); |
||
90 | |||
91 | $users = new MultipleUser(); |
||
92 | $this->fixtureExectutor->execute([$users]); |
||
93 | $result = $this->repository->findBy(["password" => 'p$ssw0rd']); |
||
94 | $this->assertSame(count($users->getUsers()), count($result)); |
||
95 | } |
||
96 | |||
97 | public function testFindById() |
||
107 | |||
108 | public function testGetClass() |
||
112 | } |
||
113 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.