offlineQtiRunnerService = new OfflineQtiRunnerService(); $this->qtiRunnerServiceMock = $this->getQtiRunnerServiceMock(); $this->serviceContextMock = $this ->getMockBuilder(RunnerServiceContext::class) ->getMock(); $serviceLocatorMock = $this->getServiceLocatorMock([ QtiRunnerService::SERVICE_ID => $this->qtiRunnerServiceMock, ]); $this->offlineQtiRunnerService->setServiceLocator($serviceLocatorMock); } public function testGetItems() { $this->assertEquals([ 'I01' => [ 'baseUrl' => 'itemPublicUrl', 'itemData' => [ 'data' => [ 'responses' => [ 'responseIdentifier' => [ 'test' => 'test', ], ], ], ], 'itemState' => 'itemState', 'itemIdentifier' => 'I01', 'portableElements' => 'itemPortableElements', ], ], $this->offlineQtiRunnerService->getItems($this->serviceContextMock)); } private function getQtiRunnerServiceMock() { $qtiRunnerServiceMock = $this ->getMockBuilder(QtiRunnerService::class) ->getMock(); $qtiRunnerServiceMock ->method('getItemVariableElementsData') ->willReturn([ 'responseIdentifier' => [ 'test' => 'test', ], ]); $qtiRunnerServiceMock ->method('getItemData') ->willReturn([ 'data' => [ 'responses' => [ 'responseIdentifier' => [], ], ], ]); $qtiRunnerServiceMock ->method('getTestMap') ->willReturn([ 'parts' => [ 'P01' => [ 'sections' => [ 'S01' => [ 'items' => [ 'I01' => [], ], ], ], ], ], ]); $qtiRunnerServiceMock ->method('getItemPublicUrl')->willReturn('itemPublicUrl'); $qtiRunnerServiceMock ->method('getItemState')->willReturn('itemState'); $qtiRunnerServiceMock ->method('getItemPortableElements')->willReturn('itemPortableElements'); return $qtiRunnerServiceMock; } }