Ejemplo n.º 1
0
 public function testAttachDetachMethods()
 {
     $product = new UsingSPL\Product();
     $productPriceObserver = new UsingSPL\ProductPriceObserver();
     $observers = $product->getObservers();
     $this->assertInstanceOf('SplObjectStorage', $observers);
     $this->assertFalse($observers->contains($productPriceObserver));
     $product->attach($productPriceObserver);
     $this->assertTrue($observers->contains($productPriceObserver));
     $product->detach($productPriceObserver);
     $this->assertFalse($observers->contains($productPriceObserver));
 }