/** * Test manipulation of Annuaire collection. * * @covers Application\Sonata\UserBundle\Entity\User::addOwnedAnnuaire() * @covers Application\Sonata\UserBundle\Entity\User::removeOwnedAnnuaire() * @covers Application\Sonata\UserBundle\Entity\User::getOwnedAnnuaires() */ public function testAddOwnedAnnuaire() { $ownedAnnuaires[0] = new Annuaire(); $ownedAnnuaires[1] = new Annuaire(); $ownedAnnuaires[2] = new Annuaire(); $this->assertTrue($this->object->getOwnedAnnuaires() instanceof Collection); $this->assertEquals(0, $this->object->getOwnedAnnuaires()->count()); $this->object->addOwnedAnnuaire($ownedAnnuaires[0]); $this->assertEquals(1, $this->object->getOwnedAnnuaires()->count()); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[0])); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[1])); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[2])); $this->object->addOwnedAnnuaire($ownedAnnuaires[1]); $this->assertEquals(2, $this->object->getOwnedAnnuaires()->count()); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[0])); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[1])); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[2])); $this->object->removeOwnedAnnuaire($ownedAnnuaires[2]); $this->assertEquals(2, $this->object->getOwnedAnnuaires()->count()); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[0])); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[1])); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[2])); $this->object->removeOwnedAnnuaire($ownedAnnuaires[0]); $this->assertEquals(1, $this->object->getOwnedAnnuaires()->count()); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[0])); $this->assertTrue($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[1])); $this->assertFalse($this->object->getOwnedAnnuaires()->contains($ownedAnnuaires[2])); }