@@ 465-484 (lines=20) @@ | ||
462 | /** |
|
463 | * @group DDC-546 |
|
464 | */ |
|
465 | public function testContainsManyToManyInverse() |
|
466 | { |
|
467 | $group = $this->em->find(CmsGroup::class, $this->groupId); |
|
468 | self::assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); |
|
469 | ||
470 | $user = $this->em->find(CmsUser::class, $this->userId); |
|
471 | ||
472 | $queryCount = $this->getCurrentQueryCount(); |
|
473 | self::assertTrue($group->users->contains($user)); |
|
474 | self::assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of managed entity should cause one query to be executed."); |
|
475 | self::assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
476 | ||
477 | $newUser = new CmsUser(); |
|
478 | $newUser->name = "A New group!"; |
|
479 | ||
480 | $queryCount = $this->getCurrentQueryCount(); |
|
481 | self::assertFalse($group->users->contains($newUser)); |
|
482 | self::assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); |
|
483 | self::assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
484 | } |
|
485 | ||
486 | /** |
|
487 | * |
|
@@ 698-720 (lines=23) @@ | ||
695 | /** |
|
696 | * |
|
697 | */ |
|
698 | public function testRemoveElementManyToManyInverse() |
|
699 | { |
|
700 | $group = $this->em->find(CmsGroup::class, $this->groupId); |
|
701 | self::assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); |
|
702 | ||
703 | $user = $this->em->find(CmsUser::class, $this->userId); |
|
704 | $queryCount = $this->getCurrentQueryCount(); |
|
705 | ||
706 | $group->users->removeElement($user); |
|
707 | ||
708 | self::assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a managed entity should cause one query to be executed."); |
|
709 | self::assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
710 | ||
711 | $newUser = new CmsUser(); |
|
712 | $newUser->name = "A New group!"; |
|
713 | ||
714 | $queryCount = $this->getCurrentQueryCount(); |
|
715 | ||
716 | $group->users->removeElement($newUser); |
|
717 | ||
718 | self::assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); |
|
719 | self::assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
720 | } |
|
721 | ||
722 | /** |
|
723 | * @group DDC-1399 |