Beispiel #1
0
 function testGetFromCallable()
 {
     $callback = function () {
         return true;
     };
     $listener = CallbackListener::createFromCallable($callback);
     $listener2 = CallbackListener::getFromCallable($callback);
     $this->assertEquals($listener, $listener2);
     $this->assertTrue($listener === $listener2);
 }
Beispiel #2
0
 function testRemoveScriber()
 {
     $this->dispatcher->removeAll();
     CallbackListener::clearListeners();
     $subscriber = new Subscriber();
     $this->dispatcher->addSubscriber($subscriber);
     $this->assertCount(1, $this->dispatcher->getListeners(self::EVENT_FOOL1));
     $this->assertCount(1, $this->dispatcher->getListeners(self::EVENT_FOOL2));
     $this->dispatcher->removeSubscriber($subscriber);
     $this->assertCount(0, $this->dispatcher->getListeners(self::EVENT_FOOL1));
     $this->assertCount(0, $this->dispatcher->getListeners(self::EVENT_FOOL2));
 }