コード例 #1
0
ファイル: UserTest.php プロジェクト: Alexandre-T/jeu-de-role
 /**
  * Tests User->addSite() User->removeSite() User->getSites().
  */
 public function testAddSite()
 {
     $sites[0] = new Site();
     $sites[1] = new Site();
     $sites[2] = new Site();
     $this->assertTrue($this->user->getSites() instanceof Collection);
     $this->assertEquals(0, $this->user->getSites()->count());
     $this->user->addSite($sites[0]);
     $this->assertEquals(1, $this->user->getSites()->count());
     $this->assertTrue($this->user->getSites()->contains($sites[0]));
     $this->assertFalse($this->user->getSites()->contains($sites[1]));
     $this->assertFalse($this->user->getSites()->contains($sites[2]));
     $this->user->addSite($sites[1]);
     $this->assertEquals(2, $this->user->getSites()->count());
     $this->assertTrue($this->user->getSites()->contains($sites[0]));
     $this->assertTrue($this->user->getSites()->contains($sites[1]));
     $this->assertFalse($this->user->getSites()->contains($sites[2]));
     $this->user->removeSite($sites[2]);
     $this->assertEquals(2, $this->user->getSites()->count());
     $this->assertTrue($this->user->getSites()->contains($sites[0]));
     $this->assertTrue($this->user->getSites()->contains($sites[1]));
     $this->assertFalse($this->user->getSites()->contains($sites[2]));
     $this->user->removeSite($sites[0]);
     $this->assertEquals(1, $this->user->getSites()->count());
     $this->assertFalse($this->user->getSites()->contains($sites[0]));
     $this->assertTrue($this->user->getSites()->contains($sites[1]));
     $this->assertFalse($this->user->getSites()->contains($sites[2]));
 }