/** * @test */ public function it_returns_nothing_on_dispatch_until_when_no_listeners_attached() { $actionEventMock = $this->getMock(ActionEvent::class); $this->assertNull($this->proophActionEventEmitter->dispatchUntil($actionEventMock, function () { return true; })); }
/** * @test */ function it_detaches_listener_aggregate() { $listener1 = new ActionEventListenerMock(); $listenerAggregate = new ActionListenerAggregateMock(); $actionEvent = $this->proophActionEventEmitter->getNewActionEvent("test", $this, ['payload' => true]); $this->proophActionEventEmitter->attachListener("test", $listener1); $this->proophActionEventEmitter->attachListenerAggregate($listenerAggregate); $this->proophActionEventEmitter->detachListenerAggregate($listenerAggregate); $this->proophActionEventEmitter->dispatch($actionEvent); //If aggregate is not detached it would stop the event propagation and $listener1 would not be triggered $this->assertSame($actionEvent, $listener1->lastEvent); }