@@ 328-339 (lines=12) @@ | ||
325 | /** |
|
326 | * @group DDC-2504 |
|
327 | */ |
|
328 | public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWhenMatchingItemIsFound() |
|
329 | { |
|
330 | $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); |
|
331 | ||
332 | // Test One to Many existence retrieved from DB |
|
333 | $childClass = $this->_em->find(DDC2504ChildClass::class, $this->ddc2504ChildClassId); |
|
334 | $queryCount = $this->getCurrentQueryCount(); |
|
335 | ||
336 | $this->assertTrue($otherClass->childClasses->contains($childClass)); |
|
337 | $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); |
|
338 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), 'Search operation was performed via SQL'); |
|
339 | } |
|
340 | ||
341 | /** |
|
342 | * @group DDC-2504 |
|
@@ 378-390 (lines=13) @@ | ||
375 | /** |
|
376 | * @group DDC-2504 |
|
377 | */ |
|
378 | public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem() |
|
379 | { |
|
380 | $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); |
|
381 | $childClass = new DDC2504ChildClass(); |
|
382 | ||
383 | $this->_em->persist($childClass); |
|
384 | ||
385 | $queryCount = $this->getCurrentQueryCount(); |
|
386 | ||
387 | $this->assertFalse($otherClass->childClasses->contains($childClass)); |
|
388 | $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); |
|
389 | $this->assertFalse($otherClass->childClasses->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
390 | } |
|
391 | ||
392 | /** |
|
393 | * @group DDC-2504 |
|
@@ 611-629 (lines=19) @@ | ||
608 | /** |
|
609 | * @group DDC-2504 |
|
610 | */ |
|
611 | public function testRemovalOfNewManagedElementFromOneToManyJoinedInheritanceCollectionDoesNotInitializeIt() |
|
612 | { |
|
613 | $otherClass = $this->_em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); |
|
614 | $childClass = new DDC2504ChildClass(); |
|
615 | ||
616 | $this->_em->persist($childClass); |
|
617 | $this->_em->flush(); |
|
618 | ||
619 | $queryCount = $this->getCurrentQueryCount(); |
|
620 | ||
621 | $otherClass->childClasses->removeElement($childClass); |
|
622 | ||
623 | $this->assertEquals( |
|
624 | $queryCount, |
|
625 | $this->getCurrentQueryCount(), |
|
626 | 'No queries are executed, as the owning side of the association is not actually updated.' |
|
627 | ); |
|
628 | $this->assertFalse($otherClass->childClasses->isInitialized(), 'Collection is not initialized.'); |
|
629 | } |
|
630 | ||
631 | /** |
|
632 | * |
|
@@ 838-850 (lines=13) @@ | ||
835 | $this->assertNull($user->groups->get(-1)); |
|
836 | } |
|
837 | ||
838 | public function testContainsKeyIndexByOneToMany() |
|
839 | { |
|
840 | $user = $this->_em->find(CmsUser::class, $this->userId); |
|
841 | /* @var $user CmsUser */ |
|
842 | ||
843 | $queryCount = $this->getCurrentQueryCount(); |
|
844 | ||
845 | $contains = $user->articles->containsKey($this->topic); |
|
846 | ||
847 | $this->assertTrue($contains); |
|
848 | $this->assertFalse($user->articles->isInitialized()); |
|
849 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
|
850 | } |
|
851 | ||
852 | public function testContainsKeyIndexByOneToManyJoinedInheritance() |
|
853 | { |
|
@@ 927-938 (lines=12) @@ | ||
924 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
|
925 | } |
|
926 | ||
927 | public function testContainsKeyNonExistentIndexByOneToMany() |
|
928 | { |
|
929 | $user = $this->_em->find(CmsUser::class, $this->userId2); |
|
930 | ||
931 | $queryCount = $this->getCurrentQueryCount(); |
|
932 | ||
933 | $contains = $user->articles->containsKey("NonExistentTopic"); |
|
934 | ||
935 | $this->assertFalse($contains); |
|
936 | $this->assertFalse($user->articles->isInitialized()); |
|
937 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
|
938 | } |
|
939 | ||
940 | public function testContainsKeyNonExistentIndexByManyToMany() |
|
941 | { |
|
@@ 940-952 (lines=13) @@ | ||
937 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
|
938 | } |
|
939 | ||
940 | public function testContainsKeyNonExistentIndexByManyToMany() |
|
941 | { |
|
942 | $user = $this->_em->find(CmsUser::class, $this->userId2); |
|
943 | ||
944 | ||
945 | $queryCount = $this->getCurrentQueryCount(); |
|
946 | ||
947 | $contains = $user->groups->containsKey("NonExistentTopic"); |
|
948 | ||
949 | $this->assertFalse($contains); |
|
950 | $this->assertFalse($user->groups->isInitialized()); |
|
951 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
|
952 | } |
|
953 | ||
954 | private function loadFixture() |
|
955 | { |