public function testDispatcherHasListener() { $this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::PRE_PAYMENT_SUCCESS)); $this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::PRE_PAYMENT_FAILED)); $this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::POST_PAYMENT_SUCCESS)); $this->assertTrue($this->dispatcher->hasListeners(ServiredEvent::POST_PAYMENT_FAILED)); }
/** * @return void */ public function testBootShouldAddListenerToDispatcher() { $application = new Application(); $dispatcher = new EventDispatcher(); $application['dispatcher'] = $dispatcher; $serviceProvider = new KernelLogServiceProvider(); $serviceProvider->boot($application); $this->assertTrue($dispatcher->hasListeners('kernel.request')); $this->assertTrue($dispatcher->hasListeners('kernel.response')); }
public function testHasListeners() { $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); $this->assertFalse($dispatcher->hasListeners('foo')); $this->assertFalse($tdispatcher->hasListeners('foo')); $tdispatcher->addListener('foo', $listener = function () { }); $this->assertTrue($dispatcher->hasListeners('foo')); $this->assertTrue($tdispatcher->hasListeners('foo')); }
public function testGetHasListeners() { $dispatcher = new EventDispatcher(); $this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener'); $dispatcher->connect('foo', 'listenToFoo'); $this->assertEquals(true, $dispatcher->hasListeners('foo'), '->hasListeners() returns true if the event has some listeners'); $dispatcher->disconnect('foo', 'listenToFoo'); $this->assertFalse($dispatcher->hasListeners('foo'), '->hasListeners() returns false if the event has no listener'); $dispatcher->connect('bar', 'listenToBar'); $this->assertEquals(array('listenToBar'), $dispatcher->getListeners('bar'), '->getListeners() returns an array of listeners connected to the given event name'); $this->assertEquals(array(), $dispatcher->getListeners('foobar'), '->getListeners() returns an empty array if no listener are connected to the given event name'); }
public function removeSignalListener($signal, $callable) { $this->dispatcher->removeListener('morker.signal.' . $signal, $callable); if (!$this->dispatcher->hasListeners('morker.signal.' . $signal)) { pcntl_signal($signal, SIG_DFL); } }
/** * @see EventDispatcherInterface::hasListeners */ public function hasListeners($eventName = null) { if (null === $eventName) { return (bool) count($this->listenerIds) || (bool) count($this->listeners); } if (isset($this->listenerIds[$eventName])) { return true; } return parent::hasListeners($eventName); }
public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() { $this->assertFalse($this->dispatcher->hasListeners('foo')); $this->assertFalse($this->dispatcher->hasListeners()); }
/** @test */ public function it_asks_both_the_symfony_and_laravel_dispatcher_if_it_has_a_listener() { $this->symfony->hasListeners(static::EVENT)->willReturn(false); $this->laravel->hasListeners(static::EVENT)->willReturn(false); $this->assertFalse($this->dispatcher->hasListeners(static::EVENT)); }
/** * @see https://bugs.php.net/bug.php?id=62976 * * This bug affects: * - The PHP 5.3 branch for versions < 5.3.18 * - The PHP 5.4 branch for versions < 5.4.8 * - The PHP 5.5 branch is not affected */ public function testWorkaroundForPhpBug62976() { $dispatcher = new EventDispatcher(); $dispatcher->addListener('bug.62976', new CallableClass()); $dispatcher->removeListener('bug.62976', function () { }); $this->assertTrue($dispatcher->hasListeners('bug.62976')); }
public function hasListeners($eventName = null) { return $this->eventDispatcher->hasListeners($eventName); }