getRootClass(); /** @var MetadataService $test */ $serviceLocator = ServiceManager::getServiceManager(); $importer = new MetadataImporter(); $importer->setOptions([ MetadataImporter::INJECTOR_KEY => ['oat\taoQtiItem\model\qti\metadata\ontology\LomInjector'], MetadataImporter::EXTRACTOR_KEY => ['oat\taoQtiItem\model\qti\metadata\imsManifest\ImsManifestMetadataExtractor'], MetadataImporter::GUARDIAN_KEY => ['oat\taoQtiItem\model\qti\metadata\guardians\LomIdentifierGuardian'], ]); $metadataService = $this->getMockBuilder(MetadataService::class) ->disableOriginalConstructor() ->setMethods(['getImporter']) ->getMock(); $metadataService->expects($this->once()) ->method('getImporter') ->willReturn($importer); $serviceLocator->overload(MetadataService::SERVICE_ID, $metadataService); /** @var ImportService $importService */ $importService = $serviceLocator->get(ImportService::SERVICE_ID); $this->setInaccessibleProperty($importService, 'metadataImporter', null); $samplePath = dirname(__FILE__) . '/../samples/metadata/metadataGuardians/lomidentifieritem.zip'; $report = $importService->importQTIPACKFile($samplePath, $itemClass, true); $successes = $report->getSuccesses(); $this->assertCount(1, $successes); $itemResource = $successes[0]->getData(); $itemClass = \taoItems_models_classes_ItemsService::singleton()->getRootClass(); $samplePath = dirname(__FILE__) . '/../samples/metadata/metadataGuardians/lomidentifieritem.zip'; $report = $importService->importQTIPACKFile($samplePath, $itemClass, true); // Report must contain an information message. $this->assertTrue($report->contains(\common_report_Report::TYPE_INFO)); $this->assertEquals(1, count($report->getInfos())); \taoItems_models_classes_ItemsService::singleton()->deleteItem($itemResource); } }