コード例 #1
0
 public function testDispatchSomeEventsThroughAdHocListener()
 {
     $mockTester = $this->getMockBuilder('\\stdClass')->setMethods(array('doSomething'))->getMock();
     $mockTester->expects($this->once())->method('doSomething');
     $eventDispatcherFactory = new EventDispatcherFactory();
     $eventDispatcher = $eventDispatcherFactory->newGenericEventDispatcher();
     $eventDispatcher->addListener('notify.bar', new BarListener());
     $dispatchContext = new DispatchContext();
     $dispatchContext->set('mock', $mockTester);
     $eventDispatcher->dispatch('notify.bar', $dispatchContext);
     $eventDispatcher->dispatch('try.notify.empty.listener');
 }
コード例 #2
0
 public function testCanConstructGenericEventDispatcher()
 {
     $instance = new EventDispatcherFactory();
     $this->assertInstanceOf('\\Onoi\\EventDispatcher\\Dispatcher\\GenericEventDispatcher', $instance->newGenericEventDispatcher());
 }