@@ 456-475 (lines=20) @@ | ||
453 | /** |
|
454 | * @group DDC-546 |
|
455 | */ |
|
456 | public function testContainsManyToManyInverse() |
|
457 | { |
|
458 | $group = $this->_em->find(CmsGroup::class, $this->groupId); |
|
459 | $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); |
|
460 | ||
461 | $user = $this->_em->find(CmsUser::class, $this->userId); |
|
462 | ||
463 | $queryCount = $this->getCurrentQueryCount(); |
|
464 | $this->assertTrue($group->users->contains($user)); |
|
465 | $this->assertEquals($queryCount+1, $this->getCurrentQueryCount(), "Checking for contains of managed entity should cause one query to be executed."); |
|
466 | $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
467 | ||
468 | $newUser = new CmsUser(); |
|
469 | $newUser->name = "A New group!"; |
|
470 | ||
471 | $queryCount = $this->getCurrentQueryCount(); |
|
472 | $this->assertFalse($group->users->contains($newUser)); |
|
473 | $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Checking for contains of new entity should cause no query to be executed."); |
|
474 | $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
475 | } |
|
476 | ||
477 | /** |
|
478 | * |
|
@@ 689-711 (lines=23) @@ | ||
686 | /** |
|
687 | * |
|
688 | */ |
|
689 | public function testRemoveElementManyToManyInverse() |
|
690 | { |
|
691 | $group = $this->_em->find(CmsGroup::class, $this->groupId); |
|
692 | $this->assertFalse($group->users->isInitialized(), "Pre-Condition: Collection is not initialized."); |
|
693 | ||
694 | $user = $this->_em->find(CmsUser::class, $this->userId); |
|
695 | $queryCount = $this->getCurrentQueryCount(); |
|
696 | ||
697 | $group->users->removeElement($user); |
|
698 | ||
699 | $this->assertEquals($queryCount + 1, $this->getCurrentQueryCount(), "Removing a managed entity should cause one query to be executed."); |
|
700 | $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
701 | ||
702 | $newUser = new CmsUser(); |
|
703 | $newUser->name = "A New group!"; |
|
704 | ||
705 | $queryCount = $this->getCurrentQueryCount(); |
|
706 | ||
707 | $group->users->removeElement($newUser); |
|
708 | ||
709 | $this->assertEquals($queryCount, $this->getCurrentQueryCount(), "Removing a new entity should cause no query to be executed."); |
|
710 | $this->assertFalse($user->groups->isInitialized(), "Post-Condition: Collection is not initialized."); |
|
711 | } |
|
712 | ||
713 | /** |
|
714 | * @group DDC-1399 |