Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EntityRepositoryTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EntityRepositoryTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class EntityRepositoryTest extends OrmFunctionalTestCase |
||
28 | { |
||
29 | protected function setUp() |
||
34 | |||
35 | public function tearDown() |
||
42 | |||
43 | public function loadFixture() |
||
82 | |||
83 | public function loadAssociatedFixture() |
||
104 | |||
105 | public function loadFixtureUserEmail() |
||
148 | |||
149 | public function buildUser($name, $username, $status, $address) |
||
162 | |||
163 | public function buildAddress($country, $city, $street, $zip) |
||
176 | |||
177 | View Code Duplication | public function testBasicFind() |
|
178 | { |
||
179 | $user1Id = $this->loadFixture(); |
||
180 | $repos = $this->_em->getRepository(CmsUser::class); |
||
181 | |||
182 | $user = $repos->find($user1Id); |
||
183 | $this->assertInstanceOf(CmsUser::class,$user); |
||
184 | $this->assertEquals('Roman', $user->name); |
||
185 | $this->assertEquals('freak', $user->status); |
||
186 | } |
||
187 | |||
188 | View Code Duplication | public function testFindByField() |
|
189 | { |
||
190 | $user1Id = $this->loadFixture(); |
||
|
|||
191 | $repos = $this->_em->getRepository(CmsUser::class); |
||
192 | |||
193 | $users = $repos->findBy(['status' => 'dev']); |
||
194 | $this->assertEquals(2, count($users)); |
||
195 | $this->assertInstanceOf(CmsUser::class,$users[0]); |
||
196 | $this->assertEquals('Guilherme', $users[0]->name); |
||
197 | $this->assertEquals('dev', $users[0]->status); |
||
198 | } |
||
199 | |||
200 | View Code Duplication | public function testFindByAssociationWithIntegerAsParameter() |
|
201 | { |
||
202 | $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); |
||
203 | $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); |
||
204 | |||
205 | $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); |
||
206 | $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); |
||
207 | |||
208 | $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); |
||
209 | $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); |
||
210 | |||
211 | unset($address1); |
||
212 | unset($address2); |
||
213 | unset($address3); |
||
214 | |||
215 | $this->_em->clear(); |
||
216 | |||
217 | $repository = $this->_em->getRepository(CmsAddress::class); |
||
218 | $addresses = $repository->findBy(['user' => [$user1->getId(), $user2->getId()]]); |
||
219 | |||
220 | $this->assertEquals(2, count($addresses)); |
||
221 | $this->assertInstanceOf(CmsAddress::class,$addresses[0]); |
||
222 | } |
||
223 | |||
224 | View Code Duplication | public function testFindByAssociationWithObjectAsParameter() |
|
225 | { |
||
226 | $address1 = $this->buildAddress('Germany', 'Berlim', 'Foo st.', '123456'); |
||
227 | $user1 = $this->buildUser('Benjamin', 'beberlei', 'dev', $address1); |
||
228 | |||
229 | $address2 = $this->buildAddress('Brazil', 'São Paulo', 'Bar st.', '654321'); |
||
230 | $user2 = $this->buildUser('Guilherme', 'guilhermeblanco', 'freak', $address2); |
||
231 | |||
232 | $address3 = $this->buildAddress('USA', 'Nashville', 'Woo st.', '321654'); |
||
233 | $user3 = $this->buildUser('Jonathan', 'jwage', 'dev', $address3); |
||
234 | |||
235 | unset($address1); |
||
236 | unset($address2); |
||
237 | unset($address3); |
||
238 | |||
239 | $this->_em->clear(); |
||
240 | |||
241 | $repository = $this->_em->getRepository(CmsAddress::class); |
||
242 | $addresses = $repository->findBy(['user' => [$user1, $user2]]); |
||
243 | |||
244 | $this->assertEquals(2, count($addresses)); |
||
245 | $this->assertInstanceOf(CmsAddress::class,$addresses[0]); |
||
246 | } |
||
247 | |||
248 | View Code Duplication | public function testFindFieldByMagicCall() |
|
249 | { |
||
250 | $user1Id = $this->loadFixture(); |
||
251 | $repos = $this->_em->getRepository(CmsUser::class); |
||
252 | |||
253 | $users = $repos->findByStatus('dev'); |
||
254 | $this->assertEquals(2, count($users)); |
||
255 | $this->assertInstanceOf(CmsUser::class,$users[0]); |
||
256 | $this->assertEquals('Guilherme', $users[0]->name); |
||
257 | $this->assertEquals('dev', $users[0]->status); |
||
258 | } |
||
259 | |||
260 | View Code Duplication | public function testFindAll() |
|
261 | { |
||
262 | $user1Id = $this->loadFixture(); |
||
263 | $repos = $this->_em->getRepository(CmsUser::class); |
||
264 | |||
265 | $users = $repos->findAll(); |
||
266 | $this->assertEquals(4, count($users)); |
||
267 | } |
||
268 | |||
269 | public function testFindByAlias() |
||
281 | |||
282 | public function testCount() |
||
296 | |||
297 | public function testCountBy() |
||
305 | |||
306 | /** |
||
307 | * @expectedException \Doctrine\ORM\ORMException |
||
308 | */ |
||
309 | public function testExceptionIsThrownWhenCallingFindByWithoutParameter() { |
||
313 | |||
314 | /** |
||
315 | * @expectedException \Doctrine\ORM\ORMException |
||
316 | */ |
||
317 | public function testExceptionIsThrownWhenUsingInvalidFieldName() { |
||
321 | |||
322 | /** |
||
323 | * @group locking |
||
324 | * @group DDC-178 |
||
325 | */ |
||
326 | public function testPessimisticReadLockWithoutTransaction_ThrowsException() |
||
333 | |||
334 | /** |
||
335 | * @group locking |
||
336 | * @group DDC-178 |
||
337 | */ |
||
338 | public function testPessimisticWriteLockWithoutTransaction_ThrowsException() |
||
345 | |||
346 | /** |
||
347 | * @group locking |
||
348 | * @group DDC-178 |
||
349 | */ |
||
350 | public function testOptimisticLockUnversionedEntity_ThrowsException() |
||
357 | |||
358 | /** |
||
359 | * @group locking |
||
360 | * @group DDC-178 |
||
361 | */ |
||
362 | public function testIdentityMappedOptimisticLockUnversionedEntity_ThrowsException() |
||
379 | |||
380 | /** |
||
381 | * @group DDC-819 |
||
382 | */ |
||
383 | View Code Duplication | public function testFindMagicCallByNullValue() |
|
384 | { |
||
385 | $this->loadFixture(); |
||
386 | |||
387 | $repos = $this->_em->getRepository(CmsUser::class); |
||
388 | |||
389 | $users = $repos->findByStatus(null); |
||
390 | $this->assertEquals(1, count($users)); |
||
391 | } |
||
392 | |||
393 | /** |
||
394 | * @group DDC-819 |
||
395 | */ |
||
396 | public function testInvalidMagicCall() |
||
403 | |||
404 | /** |
||
405 | * @group DDC-817 |
||
406 | */ |
||
407 | public function testFindByAssociationKey_ExceptionOnInverseSide() |
||
417 | |||
418 | /** |
||
419 | * @group DDC-817 |
||
420 | */ |
||
421 | View Code Duplication | public function testFindOneByAssociationKey() |
|
422 | { |
||
423 | list($userId, $addressId) = $this->loadAssociatedFixture(); |
||
424 | $repos = $this->_em->getRepository(CmsAddress::class); |
||
425 | $address = $repos->findOneBy(['user' => $userId]); |
||
426 | |||
427 | $this->assertInstanceOf(CmsAddress::class, $address); |
||
428 | $this->assertEquals($addressId, $address->id); |
||
429 | } |
||
430 | |||
431 | /** |
||
432 | * @group DDC-1241 |
||
433 | */ |
||
434 | public function testFindOneByOrderBy() |
||
444 | |||
445 | /** |
||
446 | * @group DDC-817 |
||
447 | */ |
||
448 | View Code Duplication | public function testFindByAssociationKey() |
|
449 | { |
||
450 | list($userId, $addressId) = $this->loadAssociatedFixture(); |
||
451 | $repos = $this->_em->getRepository(CmsAddress::class); |
||
452 | $addresses = $repos->findBy(['user' => $userId]); |
||
453 | |||
454 | $this->assertContainsOnly(CmsAddress::class, $addresses); |
||
455 | $this->assertEquals(1, count($addresses)); |
||
456 | $this->assertEquals($addressId, $addresses[0]->id); |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * @group DDC-817 |
||
461 | */ |
||
462 | View Code Duplication | public function testFindAssociationByMagicCall() |
|
463 | { |
||
464 | list($userId, $addressId) = $this->loadAssociatedFixture(); |
||
465 | $repos = $this->_em->getRepository(CmsAddress::class); |
||
466 | $addresses = $repos->findByUser($userId); |
||
467 | |||
468 | $this->assertContainsOnly(CmsAddress::class, $addresses); |
||
469 | $this->assertEquals(1, count($addresses)); |
||
470 | $this->assertEquals($addressId, $addresses[0]->id); |
||
471 | } |
||
472 | |||
473 | /** |
||
474 | * @group DDC-817 |
||
475 | */ |
||
476 | public function testFindOneAssociationByMagicCall() |
||
485 | |||
486 | public function testValidNamedQueryRetrieval() |
||
495 | |||
496 | public function testInvalidNamedQueryRetrieval() |
||
504 | |||
505 | /** |
||
506 | * @group DDC-1087 |
||
507 | */ |
||
508 | public function testIsNullCriteriaDoesNotGenerateAParameter() |
||
517 | |||
518 | View Code Duplication | public function testIsNullCriteria() |
|
519 | { |
||
520 | $this->loadFixture(); |
||
521 | |||
522 | $repos = $this->_em->getRepository(CmsUser::class); |
||
523 | |||
524 | $users = $repos->findBy(['status' => null]); |
||
525 | $this->assertEquals(1, count($users)); |
||
526 | } |
||
527 | |||
528 | /** |
||
529 | * @group DDC-1094 |
||
530 | */ |
||
531 | public function testFindByLimitOffset() |
||
545 | |||
546 | /** |
||
547 | * @group DDC-1094 |
||
548 | */ |
||
549 | public function testFindByOrderBy() |
||
562 | |||
563 | /** |
||
564 | * @group DDC-1376 |
||
565 | */ |
||
566 | public function testFindByOrderByAssociation() |
||
580 | |||
581 | /** |
||
582 | * @group DDC-1426 |
||
583 | */ |
||
584 | public function testFindFieldByMagicCallOrderBy() |
||
602 | |||
603 | /** |
||
604 | * @group DDC-1426 |
||
605 | */ |
||
606 | public function testFindFieldByMagicCallLimitOffset() |
||
618 | |||
619 | /** |
||
620 | * @group DDC-753 |
||
621 | */ |
||
622 | public function testDefaultRepositoryClassName() |
||
642 | |||
643 | /** |
||
644 | * @group DDC-753 |
||
645 | * @expectedException Doctrine\ORM\ORMException |
||
646 | * @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository. |
||
647 | */ |
||
648 | public function testSetDefaultRepositoryInvalidClassError() |
||
653 | |||
654 | /** |
||
655 | * @group DDC-3257 |
||
656 | */ |
||
657 | public function testSingleRepositoryInstanceForDifferentEntityAliases() |
||
669 | |||
670 | /** |
||
671 | * @group DDC-3257 |
||
672 | */ |
||
673 | public function testCanRetrieveRepositoryFromClassNameWithLeadingBackslash() |
||
680 | |||
681 | /** |
||
682 | * @group DDC-1376 |
||
683 | * |
||
684 | * @expectedException Doctrine\ORM\ORMException |
||
685 | * @expectedExceptionMessage You cannot search for the association field 'Doctrine\Tests\Models\CMS\CmsUser#address', because it is the inverse side of an association. |
||
686 | */ |
||
687 | public function testInvalidOrderByAssociation() |
||
692 | |||
693 | /** |
||
694 | * @group DDC-1500 |
||
695 | */ |
||
696 | View Code Duplication | public function testInvalidOrientation() |
|
697 | { |
||
698 | $this->expectException(ORMException::class); |
||
699 | $this->expectExceptionMessage('Invalid order by orientation specified for Doctrine\Tests\Models\CMS\CmsUser#username'); |
||
700 | |||
701 | $repo = $this->_em->getRepository(CmsUser::class); |
||
702 | $repo->findBy(['status' => 'test'], ['username' => 'INVALID']); |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * @group DDC-1713 |
||
707 | */ |
||
708 | public function testFindByAssociationArray() |
||
717 | |||
718 | /** |
||
719 | * @group DDC-1637 |
||
720 | */ |
||
721 | View Code Duplication | public function testMatchingEmptyCriteria() |
|
722 | { |
||
723 | $this->loadFixture(); |
||
724 | |||
725 | $repository = $this->_em->getRepository(CmsUser::class); |
||
726 | $users = $repository->matching(new Criteria()); |
||
727 | |||
728 | $this->assertEquals(4, count($users)); |
||
729 | } |
||
730 | |||
731 | /** |
||
732 | * @group DDC-1637 |
||
733 | */ |
||
734 | public function testMatchingCriteriaEqComparison() |
||
745 | |||
746 | /** |
||
747 | * @group DDC-1637 |
||
748 | */ |
||
749 | View Code Duplication | public function testMatchingCriteriaNeqComparison() |
|
750 | { |
||
751 | $this->loadFixture(); |
||
752 | |||
753 | $repository = $this->_em->getRepository(CmsUser::class); |
||
754 | $users = $repository->matching(new Criteria( |
||
755 | Criteria::expr()->neq('username', 'beberlei') |
||
756 | )); |
||
757 | |||
758 | $this->assertEquals(3, count($users)); |
||
759 | } |
||
760 | |||
761 | /** |
||
762 | * @group DDC-1637 |
||
763 | */ |
||
764 | View Code Duplication | public function testMatchingCriteriaInComparison() |
|
765 | { |
||
766 | $this->loadFixture(); |
||
767 | |||
768 | $repository = $this->_em->getRepository(CmsUser::class); |
||
769 | $users = $repository->matching(new Criteria( |
||
770 | Criteria::expr()->in('username', ['beberlei', 'gblanco']) |
||
771 | )); |
||
772 | |||
773 | $this->assertEquals(2, count($users)); |
||
774 | } |
||
775 | |||
776 | /** |
||
777 | * @group DDC-1637 |
||
778 | */ |
||
779 | View Code Duplication | public function testMatchingCriteriaNotInComparison() |
|
780 | { |
||
781 | $this->loadFixture(); |
||
782 | |||
783 | $repository = $this->_em->getRepository(CmsUser::class); |
||
784 | $users = $repository->matching(new Criteria( |
||
785 | Criteria::expr()->notIn('username', ['beberlei', 'gblanco', 'asm89']) |
||
786 | )); |
||
787 | |||
788 | $this->assertEquals(1, count($users)); |
||
789 | } |
||
790 | |||
791 | /** |
||
792 | * @group DDC-1637 |
||
793 | */ |
||
794 | public function testMatchingCriteriaLtComparison() |
||
805 | |||
806 | /** |
||
807 | * @group DDC-1637 |
||
808 | */ |
||
809 | public function testMatchingCriteriaLeComparison() |
||
820 | |||
821 | /** |
||
822 | * @group DDC-1637 |
||
823 | */ |
||
824 | public function testMatchingCriteriaGtComparison() |
||
835 | |||
836 | /** |
||
837 | * @group DDC-1637 |
||
838 | */ |
||
839 | public function testMatchingCriteriaGteComparison() |
||
850 | |||
851 | /** |
||
852 | * @group DDC-2430 |
||
853 | */ |
||
854 | View Code Duplication | public function testMatchingCriteriaAssocationByObjectInMemory() |
|
855 | { |
||
856 | list($userId, $addressId) = $this->loadAssociatedFixture(); |
||
857 | |||
858 | $user = $this->_em->find(CmsUser::class, $userId); |
||
859 | |||
860 | $criteria = new Criteria( |
||
861 | Criteria::expr()->eq('user', $user) |
||
862 | ); |
||
863 | |||
864 | $repository = $this->_em->getRepository(CmsAddress::class); |
||
865 | $addresses = $repository->matching($criteria); |
||
866 | |||
867 | $this->assertEquals(1, count($addresses)); |
||
868 | |||
869 | $addresses = new ArrayCollection($repository->findAll()); |
||
870 | |||
871 | $this->assertEquals(1, count($addresses->matching($criteria))); |
||
872 | } |
||
873 | |||
874 | /** |
||
875 | * @group DDC-2430 |
||
876 | */ |
||
877 | View Code Duplication | public function testMatchingCriteriaAssocationInWithArray() |
|
878 | { |
||
879 | list($userId, $addressId) = $this->loadAssociatedFixture(); |
||
880 | |||
881 | $user = $this->_em->find(CmsUser::class, $userId); |
||
882 | |||
883 | $criteria = new Criteria( |
||
884 | Criteria::expr()->in('user', [$user]) |
||
885 | ); |
||
886 | |||
887 | $repository = $this->_em->getRepository(CmsAddress::class); |
||
888 | $addresses = $repository->matching($criteria); |
||
889 | |||
890 | $this->assertEquals(1, count($addresses)); |
||
891 | |||
892 | $addresses = new ArrayCollection($repository->findAll()); |
||
893 | |||
894 | $this->assertEquals(1, count($addresses->matching($criteria))); |
||
895 | } |
||
896 | |||
897 | public function testMatchingCriteriaContainsComparison() |
||
912 | |||
913 | View Code Duplication | public function testMatchingCriteriaStartsWithComparison() |
|
914 | { |
||
915 | $this->loadFixture(); |
||
916 | |||
917 | $repository = $this->_em->getRepository(CmsUser::class); |
||
918 | |||
919 | $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'Foo'))); |
||
920 | $this->assertCount(0, $users); |
||
921 | |||
922 | $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('name', 'R'))); |
||
923 | $this->assertCount(1, $users); |
||
924 | |||
925 | $users = $repository->matching(new Criteria(Criteria::expr()->startsWith('status', 'de'))); |
||
926 | $this->assertCount(2, $users); |
||
927 | } |
||
928 | |||
929 | View Code Duplication | public function testMatchingCriteriaEndsWithComparison() |
|
930 | { |
||
931 | $this->loadFixture(); |
||
932 | |||
933 | $repository = $this->_em->getRepository(CmsUser::class); |
||
934 | |||
935 | $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'foo'))); |
||
936 | $this->assertCount(0, $users); |
||
937 | |||
938 | $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('name', 'oman'))); |
||
939 | $this->assertCount(1, $users); |
||
940 | |||
941 | $users = $repository->matching(new Criteria(Criteria::expr()->endsWith('status', 'ev'))); |
||
942 | $this->assertCount(2, $users); |
||
943 | } |
||
944 | |||
945 | /** |
||
946 | * @group DDC-2478 |
||
947 | */ |
||
948 | public function testMatchingCriteriaNullAssocComparison() |
||
973 | |||
974 | /** |
||
975 | * @group DDC-2055 |
||
976 | */ |
||
977 | public function testCreateResultSetMappingBuilder() |
||
985 | |||
986 | /** |
||
987 | * @group DDC-3045 |
||
988 | */ |
||
989 | View Code Duplication | public function testFindByFieldInjectionPrevented() |
|
990 | { |
||
991 | $this->expectException(ORMException::class); |
||
992 | $this->expectExceptionMessage('Unrecognized field: '); |
||
993 | |||
994 | $repository = $this->_em->getRepository(CmsUser::class); |
||
995 | $repository->findBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); |
||
996 | } |
||
997 | |||
998 | /** |
||
999 | * @group DDC-3045 |
||
1000 | */ |
||
1001 | View Code Duplication | public function testFindOneByFieldInjectionPrevented() |
|
1002 | { |
||
1003 | $this->expectException(ORMException::class); |
||
1004 | $this->expectExceptionMessage('Unrecognized field: '); |
||
1005 | |||
1006 | $repository = $this->_em->getRepository(CmsUser::class); |
||
1007 | $repository->findOneBy(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test']); |
||
1008 | } |
||
1009 | |||
1010 | /** |
||
1011 | * @group DDC-3045 |
||
1012 | */ |
||
1013 | public function testMatchingInjectionPrevented() |
||
1026 | |||
1027 | /** |
||
1028 | * @group DDC-3045 |
||
1029 | */ |
||
1030 | View Code Duplication | public function testFindInjectionPrevented() |
|
1031 | { |
||
1032 | $this->expectException(ORMException::class); |
||
1033 | $this->expectExceptionMessage('Unrecognized identifier fields: '); |
||
1034 | |||
1035 | $repository = $this->_em->getRepository(CmsUser::class); |
||
1036 | $repository->find(['username = ?; DELETE FROM cms_users; SELECT 1 WHERE 1' => 'test', 'id' => 1]); |
||
1037 | } |
||
1038 | |||
1039 | /** |
||
1040 | * @group DDC-3056 |
||
1041 | */ |
||
1042 | View Code Duplication | public function testFindByNullValueInInCondition() |
|
1043 | { |
||
1044 | $user1 = new CmsUser(); |
||
1045 | $user2 = new CmsUser(); |
||
1046 | |||
1047 | $user1->username = 'ocramius'; |
||
1048 | $user1->name = 'Marco'; |
||
1049 | $user2->status = null; |
||
1050 | $user2->username = 'deeky666'; |
||
1051 | $user2->name = 'Steve'; |
||
1052 | $user2->status = 'dbal maintainer'; |
||
1053 | |||
1054 | $this->_em->persist($user1); |
||
1055 | $this->_em->persist($user2); |
||
1056 | $this->_em->flush(); |
||
1057 | |||
1058 | $users = $this->_em->getRepository(CmsUser::class)->findBy(['status' => [null]]); |
||
1059 | |||
1060 | $this->assertCount(1, $users); |
||
1061 | $this->assertSame($user1, reset($users)); |
||
1062 | } |
||
1063 | |||
1064 | /** |
||
1065 | * @group DDC-3056 |
||
1066 | */ |
||
1067 | View Code Duplication | public function testFindByNullValueInMultipleInCriteriaValues() |
|
1068 | { |
||
1069 | $user1 = new CmsUser(); |
||
1070 | $user2 = new CmsUser(); |
||
1071 | |||
1072 | $user1->username = 'ocramius'; |
||
1073 | $user1->name = 'Marco'; |
||
1074 | $user2->status = null; |
||
1075 | $user2->username = 'deeky666'; |
||
1076 | $user2->name = 'Steve'; |
||
1077 | $user2->status = 'dbal maintainer'; |
||
1078 | |||
1079 | $this->_em->persist($user1); |
||
1080 | $this->_em->persist($user2); |
||
1081 | $this->_em->flush(); |
||
1082 | |||
1083 | $users = $this |
||
1084 | ->_em |
||
1085 | ->getRepository(CmsUser::class) |
||
1086 | ->findBy(['status' => ['foo', null]]); |
||
1087 | |||
1088 | $this->assertCount(1, $users); |
||
1089 | $this->assertSame($user1, reset($users)); |
||
1090 | } |
||
1091 | |||
1092 | /** |
||
1093 | * @group DDC-3056 |
||
1094 | */ |
||
1095 | public function testFindMultipleByNullValueInMultipleInCriteriaValues() |
||
1122 | } |
||
1123 | |||
1124 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.