Example #1
0
 /**
  * Tests Registry->addLog().
  */
 public function testAddLog()
 {
     $this->registry = new Registry();
     $logs = array();
     for ($i = 0; $i < 3; ++$i) {
         $logs[$i] = new Log();
     }
     $this->registry->addLog($logs[0]);
     $this->assertEquals(1, $this->registry->getLogs()->count());
     $this->assertTrue($this->registry->getLogs()->contains($logs[0]));
     $this->assertFalse($this->registry->getLogs()->contains($logs[1]));
     $this->assertFalse($this->registry->getLogs()->contains($logs[2]));
     $this->registry->addLog($logs[1]);
     $this->assertEquals(2, $this->registry->getLogs()->count());
     $this->assertTrue($this->registry->getLogs()->contains($logs[0]));
     $this->assertTrue($this->registry->getLogs()->contains($logs[1]));
     $this->assertFalse($this->registry->getLogs()->contains($logs[2]));
     $this->registry->removeLog($logs[2]);
     $this->assertEquals(2, $this->registry->getLogs()->count());
     $this->assertTrue($this->registry->getLogs()->contains($logs[0]));
     $this->assertTrue($this->registry->getLogs()->contains($logs[1]));
     $this->assertFalse($this->registry->getLogs()->contains($logs[2]));
     for ($i = 0; $i < 2; ++$i) {
         $this->registry->removeLog($logs[0]);
         $this->assertEquals(1, $this->registry->getLogs()->count());
         $this->assertFalse($this->registry->getLogs()->contains($logs[0]));
         $this->assertTrue($this->registry->getLogs()->contains($logs[1]));
         $this->assertFalse($this->registry->getLogs()->contains($logs[2]));
     }
     for ($i = 0; $i < 2; ++$i) {
         $this->registry->removeLog($logs[1]);
         $this->assertEquals(0, $this->registry->getLogs()->count());
         $this->assertFalse($this->registry->getLogs()->contains($logs[0]));
         $this->assertFalse($this->registry->getLogs()->contains($logs[1]));
         $this->assertFalse($this->registry->getLogs()->contains($logs[2]));
     }
 }
Example #2
0
 /**
  * Remove registry.
  *
  * @param Registry $registry
  */
 public function removeRegistry(Registry $registry)
 {
     //AT - Do not remove the next line.
     $registry->removeLog($this);
     // synchronously updating inverse side
     $this->registries->removeElement($registry);
 }