eventManager = $this->createMock(EventManager::class); $this->subject = new TestTakerImportEventDispatcher(); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ EventManager::SERVICE_ID => $this->eventManager ] ) ); } public function testDispatch(): void { $resourceUri = 'abc123'; $report = $this->createMock(common_report_Report::class); $successReport = $this->createMock(common_report_Report::class); $resource = $this->createMock(core_kernel_classes_Resource::class); $report->method('getSuccesses') ->willReturn( [ $successReport ] ); $successReport->method('getData') ->willReturn($resource); $resource->method('getUri') ->willReturn($resourceUri); $this->eventManager ->expects($this->once()) ->method('trigger') ->with( new TestTakerImportedEvent( $resourceUri, [ 'uri' => $resourceUri ] ) ); $this->subject->dispatch( $report, function (core_kernel_classes_Resource $resource) { return [ 'uri' => $resource->getUri() ]; } ); } }