Code Duplication    Length = 13-15 lines in 5 locations

tests/Doctrine/Tests/ORM/Functional/ExtraLazyCollectionTest.php 5 locations

@@ 861-875 (lines=15) @@
858
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
859
    }
860
861
    public function testContainsKeyIndexByOneToManyJoinedInheritance()
862
    {
863
        $class = $this->em->getClassMetadata(DDC2504OtherClass::class);
864
        $class->getProperty('childClasses')->setIndexedBy('id');
865
866
        $otherClass = $this->em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId);
867
868
        $queryCount = $this->getCurrentQueryCount();
869
870
        $contains = $otherClass->childClasses->containsKey($this->ddc2504ChildClassId);
871
872
        self::assertTrue($contains);
873
        self::assertFalse($otherClass->childClasses->isInitialized());
874
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
875
    }
876
877
    public function testContainsKeyIndexByManyToMany()
878
    {
@@ 877-890 (lines=14) @@
874
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
875
    }
876
877
    public function testContainsKeyIndexByManyToMany()
878
    {
879
        $user = $this->em->find(CmsUser::class, $this->userId2);
880
881
        $group = $this->em->find(CmsGroup::class, $this->groupId);
882
883
        $queryCount = $this->getCurrentQueryCount();
884
885
        $contains = $user->groups->containsKey($group->name);
886
887
        self::assertTrue($contains, "The item is not into collection");
888
        self::assertFalse($user->groups->isInitialized(), "The collection must not be initialized");
889
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
890
    }
891
    public function testContainsKeyIndexByManyToManyNonOwning()
892
    {
893
        $user = $this->em->find(CmsUser::class, $this->userId2);
@@ 891-903 (lines=13) @@
888
        self::assertFalse($user->groups->isInitialized(), "The collection must not be initialized");
889
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
890
    }
891
    public function testContainsKeyIndexByManyToManyNonOwning()
892
    {
893
        $user = $this->em->find(CmsUser::class, $this->userId2);
894
        $group = $this->em->find(CmsGroup::class, $this->groupId);
895
896
        $queryCount = $this->getCurrentQueryCount();
897
898
        $contains = $group->users->containsKey($user->username);
899
900
        self::assertTrue($contains, "The item is not into collection");
901
        self::assertFalse($group->users->isInitialized(), "The collection must not be initialized");
902
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
903
    }
904
905
    public function testContainsKeyIndexByWithPkManyToMany()
906
    {
@@ 905-919 (lines=15) @@
902
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
903
    }
904
905
    public function testContainsKeyIndexByWithPkManyToMany()
906
    {
907
        $class = $this->em->getClassMetadata(CmsUser::class);
908
        $class->getProperty('groups')->setIndexedBy('id');
909
910
        $user = $this->em->find(CmsUser::class, $this->userId2);
911
912
        $queryCount = $this->getCurrentQueryCount();
913
914
        $contains = $user->groups->containsKey($this->groupId);
915
916
        self::assertTrue($contains, "The item is not into collection");
917
        self::assertFalse($user->groups->isInitialized(), "The collection must not be initialized");
918
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
919
    }
920
    public function testContainsKeyIndexByWithPkManyToManyNonOwning()
921
    {
922
        $class = $this->em->getClassMetadata(CmsGroup::class);
@@ 920-934 (lines=15) @@
917
        self::assertFalse($user->groups->isInitialized(), "The collection must not be initialized");
918
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
919
    }
920
    public function testContainsKeyIndexByWithPkManyToManyNonOwning()
921
    {
922
        $class = $this->em->getClassMetadata(CmsGroup::class);
923
        $class->getProperty('users')->setIndexedBy('id');
924
925
        $group = $this->em->find(CmsGroup::class, $this->groupId);
926
927
        $queryCount = $this->getCurrentQueryCount();
928
929
        $contains = $group->users->containsKey($this->userId2);
930
931
        self::assertTrue($contains, "The item is not into collection");
932
        self::assertFalse($group->users->isInitialized(), "The collection must not be initialized");
933
        self::assertEquals($queryCount + 1, $this->getCurrentQueryCount());
934
    }
935
936
    public function testContainsKeyNonExistentIndexByOneToMany()
937
    {