/** * Tests User->addPersonnage() testRemovePersonnage() testGetPersonnages(). */ public function testAddPersonnage() { $personnages[0] = new Personnage(); $personnages[1] = new Personnage(); $personnages[2] = new Personnage(); $this->assertTrue($this->user->getPersonnages() instanceof Collection); $this->assertEquals(0, $this->user->getPersonnages()->count()); $this->user->addPersonnage($personnages[0]); $this->assertEquals(1, $this->user->getPersonnages()->count()); $this->assertTrue($this->user->getPersonnages()->contains($personnages[0])); $this->assertFalse($this->user->getPersonnages()->contains($personnages[1])); $this->assertFalse($this->user->getPersonnages()->contains($personnages[2])); $this->user->addPersonnage($personnages[1]); $this->assertEquals(2, $this->user->getPersonnages()->count()); $this->assertTrue($this->user->getPersonnages()->contains($personnages[0])); $this->assertTrue($this->user->getPersonnages()->contains($personnages[1])); $this->assertFalse($this->user->getPersonnages()->contains($personnages[2])); $this->user->removePersonnage($personnages[2]); $this->assertEquals(2, $this->user->getPersonnages()->count()); $this->assertTrue($this->user->getPersonnages()->contains($personnages[0])); $this->assertTrue($this->user->getPersonnages()->contains($personnages[1])); $this->assertFalse($this->user->getPersonnages()->contains($personnages[2])); $this->user->removePersonnage($personnages[0]); $this->assertEquals(1, $this->user->getPersonnages()->count()); $this->assertFalse($this->user->getPersonnages()->contains($personnages[0])); $this->assertTrue($this->user->getPersonnages()->contains($personnages[1])); $this->assertFalse($this->user->getPersonnages()->contains($personnages[2])); }