public function test__DispatchEventsWorker()
 {
     $bus = new EventBusSpy(new SimpleEventBus(new DummyLogger('Test')));
     $bus->addHandler('test.event', new TestEventHandler($bus));
     $this->assertTrue($bus->assertWasRegistered('test.event', new TestEventHandler($bus)));
     $recorder = new EventRecorder();
     $recorder->recordThat(new TestEvent('data'));
     $worker = new DispatchEventsWorker($bus, $recorder);
     $worker->execute(new SimpleCommand('Example'));
     $this->assertTrue($bus->eventWasHandled('test.event'));
 }
 public function test_a_handler_can_subscribe_to_several_events()
 {
     $bus = new EventBusSpy($this->getEventBus());
     // $bus->addHandler('test.event', new TestEventHandler($bus));
     // $bus->addHandler('simple.event', new TestEventHandler($bus));
     $bus->subscribeHandler(new TestEventHandler($bus), ['test.event', 'simple.event']);
     $bus->handle(new TestEvent('data'));
     $bus->handle(new SimpleEvent('other Data'));
     $expected = array('test.event' => array('TestEventHandler'), 'simple.event' => array('TestEventHandler'));
     $this->assertEquals($expected, $bus->getRecordedHandlers());
 }