|
@@ 387-399 (lines=13) @@
|
| 384 |
|
/** |
| 385 |
|
* @group DDC-2504 |
| 386 |
|
*/ |
| 387 |
|
public function testContainsOnOneToManyJoinedInheritanceWillNotInitializeCollectionWithNewStateNotMatchingItem() |
| 388 |
|
{ |
| 389 |
|
$otherClass = $this->em->find(DDC2504OtherClass::class, $this->ddc2504OtherClassId); |
| 390 |
|
$childClass = new DDC2504ChildClass(); |
| 391 |
|
|
| 392 |
|
$this->em->persist($childClass); |
| 393 |
|
|
| 394 |
|
$queryCount = $this->getCurrentQueryCount(); |
| 395 |
|
|
| 396 |
|
self::assertFalse($otherClass->childClasses->contains($childClass)); |
| 397 |
|
self::assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of managed entity (but not persisted) should cause no query to be executed."); |
| 398 |
|
self::assertFalse($otherClass->childClasses->isInitialized(), "Post-Condition: Collection is not initialized."); |
| 399 |
|
} |
| 400 |
|
|
| 401 |
|
/** |
| 402 |
|
* @group DDC-2504 |
|
@@ 847-859 (lines=13) @@
|
| 844 |
|
self::assertNull($user->groups->get(-1)); |
| 845 |
|
} |
| 846 |
|
|
| 847 |
|
public function testContainsKeyIndexByOneToMany() |
| 848 |
|
{ |
| 849 |
|
$user = $this->em->find(CmsUser::class, $this->userId); |
| 850 |
|
/* @var $user CmsUser */ |
| 851 |
|
|
| 852 |
|
$queryCount = $this->getCurrentQueryCount(); |
| 853 |
|
|
| 854 |
|
$contains = $user->articles->containsKey($this->topic); |
| 855 |
|
|
| 856 |
|
self::assertTrue($contains); |
| 857 |
|
self::assertFalse($user->articles->isInitialized()); |
| 858 |
|
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
| 859 |
|
} |
| 860 |
|
|
| 861 |
|
public function testContainsKeyIndexByOneToManyJoinedInheritance() |
| 862 |
|
{ |
|
@@ 936-947 (lines=12) @@
|
| 933 |
|
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
| 934 |
|
} |
| 935 |
|
|
| 936 |
|
public function testContainsKeyNonExistentIndexByOneToMany() |
| 937 |
|
{ |
| 938 |
|
$user = $this->em->find(CmsUser::class, $this->userId2); |
| 939 |
|
|
| 940 |
|
$queryCount = $this->getCurrentQueryCount(); |
| 941 |
|
|
| 942 |
|
$contains = $user->articles->containsKey("NonExistentTopic"); |
| 943 |
|
|
| 944 |
|
self::assertFalse($contains); |
| 945 |
|
self::assertFalse($user->articles->isInitialized()); |
| 946 |
|
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
| 947 |
|
} |
| 948 |
|
|
| 949 |
|
public function testContainsKeyNonExistentIndexByManyToMany() |
| 950 |
|
{ |
|
@@ 949-961 (lines=13) @@
|
| 946 |
|
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
| 947 |
|
} |
| 948 |
|
|
| 949 |
|
public function testContainsKeyNonExistentIndexByManyToMany() |
| 950 |
|
{ |
| 951 |
|
$user = $this->em->find(CmsUser::class, $this->userId2); |
| 952 |
|
|
| 953 |
|
|
| 954 |
|
$queryCount = $this->getCurrentQueryCount(); |
| 955 |
|
|
| 956 |
|
$contains = $user->groups->containsKey("NonExistentTopic"); |
| 957 |
|
|
| 958 |
|
self::assertFalse($contains); |
| 959 |
|
self::assertFalse($user->groups->isInitialized()); |
| 960 |
|
self::assertEquals($queryCount + 1, $this->getCurrentQueryCount()); |
| 961 |
|
} |
| 962 |
|
|
| 963 |
|
private function loadFixture() |
| 964 |
|
{ |
|
@@ 94-106 (lines=13) @@
|
| 91 |
|
* @group DDC-546 |
| 92 |
|
* @group non-cacheable |
| 93 |
|
*/ |
| 94 |
|
public function testCountNotInitializesCollection() |
| 95 |
|
{ |
| 96 |
|
$user = $this->em->find(CmsUser::class, $this->userId); |
| 97 |
|
$queryCount = $this->getCurrentQueryCount(); |
| 98 |
|
|
| 99 |
|
self::assertFalse($user->groups->isInitialized()); |
| 100 |
|
self::assertCount(3, $user->groups); |
| 101 |
|
self::assertFalse($user->groups->isInitialized()); |
| 102 |
|
|
| 103 |
|
foreach ($user->groups AS $group) { } |
| 104 |
|
|
| 105 |
|
self::assertEquals($queryCount + 2, $this->getCurrentQueryCount(), "Expecting two queries to be fired for count, then iteration."); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* @group DDC-546 |