objectManagerHelper = new ObjectManagerHelper($this); $this->invokerMock = $this->createMock(InvokerInterface::class); $this->eventConfigMock = $this->createMock(ConfigInterface::class); $this->eventManager = $this->objectManagerHelper->getObject( EventManager::class, [ 'invoker' => $this->invokerMock, 'eventConfig' => $this->eventConfigMock ] ); } public function testDispatch() { $this->eventConfigMock->expects($this->once()) ->method('getObservers') ->with('some_eventname') ->willReturn(['observer' => ['instance' => 'class', 'method' => 'method', 'name' => 'observer']]); $this->eventManager->dispatch('some_eventName', ['123']); } public function testDispatchWithEmptyEventObservers() { $this->eventConfigMock->expects($this->once()) ->method('getObservers') ->with('some_event') ->willReturn([]); $this->invokerMock->expects($this->never())->method('dispatch'); $this->eventManager->dispatch('some_event'); } }