Exemplo n.º 1
0
 /**
  * Tests User->addSitesPropose() User->removeSitesPropose() User->getSitesProposes().
  */
 public function testAddSitesPropose()
 {
     $sitesProposes[0] = new Site();
     $sitesProposes[1] = new Site();
     $sitesProposes[2] = new Site();
     $this->assertTrue($this->user->getSitesProposes() instanceof Collection);
     $this->assertEquals(0, $this->user->getSitesProposes()->count());
     $this->user->addSitesPropose($sitesProposes[0]);
     $this->assertEquals(1, $this->user->getSitesProposes()->count());
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[0]));
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[1]));
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[2]));
     $this->user->addSitesPropose($sitesProposes[1]);
     $this->assertEquals(2, $this->user->getSitesProposes()->count());
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[0]));
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[1]));
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[2]));
     $this->user->removeSitesPropose($sitesProposes[2]);
     $this->assertEquals(2, $this->user->getSitesProposes()->count());
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[0]));
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[1]));
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[2]));
     $this->user->removeSitesPropose($sitesProposes[0]);
     $this->assertEquals(1, $this->user->getSitesProposes()->count());
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[0]));
     $this->assertTrue($this->user->getSitesProposes()->contains($sitesProposes[1]));
     $this->assertFalse($this->user->getSitesProposes()->contains($sitesProposes[2]));
 }