queueDispatcher = $this->createMock(QueueDispatcher::class); $this->persistDataService = $this->createMock(PersistDataService::class); $this->qtiTestService = $this->createMock(taoQtiTest_models_classes_QtiTestService::class); $this->resourceJsonMetadataCompiler = $this->createMock(ResourceJsonMetadataCompiler::class); $this->ontology = $this->getOntologyMock(); $this->serviceLocator = $this->getServiceLocatorMock([ QueueDispatcher::SERVICE_ID => $this->queueDispatcher, PersistDataService::class => $this->persistDataService, taoQtiTest_models_classes_QtiTestService::class => $this->qtiTestService, ResourceJsonMetadataCompiler::SERVICE_ID => $this->resourceJsonMetadataCompiler, Ontology::SERVICE_ID => $this->ontology ]); $this->subject = new MetaDataDeliverySyncTask(); } public function testJsonSerialize(): void { $this->assertEquals( MetaDataDeliverySyncTask::class, $this->subject->jsonSerialize() ); } public function testInvoke() { $this->persistDataService->method('persist'); $this->qtiTestService->method('getItems')->willReturn([]); $this->queueDispatcher->method('createTask')->willReturn(true); $this->resourceJsonMetadataCompiler->method('compile')->willReturn([]); $this->subject->setServiceLocator($this->serviceLocator); $class = $this->ontology->getClass('http://tao.tld/bogusUri'); $mockDelivery = $class->createInstance('Bogus'); $mockTest = $class->createInstance('TestBogus'); $mockDelivery->setPropertyValue( $this->ontology->getProperty(DeliveryAssemblyService::PROPERTY_ORIGIN), $mockTest ); $param = [ 'deliveryId' => $mockDelivery->getUri(), 'max_tries' => 1, 'count' => 0 ]; $subject = $this->subject; $response = $subject($param); $expected = new Report(Report::TYPE_SUCCESS); $expected->setMessage('Success MetaData syncing for delivery: ' . $mockDelivery->getUri()); $this->assertEquals($expected, $response); } }