/** * @covers ::on */ public function testCanHaveMultipleHandlersForOneEvent() { // ---------------------------------------------------------------- // setup your test $stream = new EventStream(); $eventName = RegisterEventHandlerTest_DummyEvent::class; $handler1 = function ($event) { }; $handler2 = function ($event) { }; $this->assertFalse(HasEventHandler::check($stream, $eventName)); // ---------------------------------------------------------------- // perform the change RegisterEventHandler::on($stream, $eventName, $handler1); RegisterEventHandler::on($stream, $eventName, $handler2); // ---------------------------------------------------------------- // test the results $handlers = GetEventHandlerList::from($stream, $eventName); $this->assertSame($handlers[0], $handler1); $this->assertSame($handlers[1], $handler2); }
/** * @covers ::from * @expectedException GanbaroDigital\EventStream\Exceptions\E4xx_NotAnEvent */ public function testThrowsExceptionWhenPassedAnInvalidEventName() { // ---------------------------------------------------------------- // setup your test $stream = new EventStream(); $eventName = self::class; // ---------------------------------------------------------------- // perform the change GetEventHandlerList::from($stream, $eventName); }