self::DOCUMENT_URI, 'body' => [ 'type' => [], ] ]; protected function setUp(): void { parent::setUp(); $this->ontology = $this->getOntologyMock(); $this->service = $this->getServiceLocatorMock( [ Ontology::SERVICE_ID => $this->ontology, SearchTokenGenerator::class => new SearchTokenGenerator(), LoggerService::SERVICE_ID => new NullLogger(), PermissionInterface::SERVICE_ID => $this->createMock(PermissionInterface::class), ] ); } private function getIndexService(): IndexService { if (!$this->indexService) { $this->indexService = new IndexService(); $this->indexService->setOption(IndexService::OPTION_DOCUMENT_BUILDER, (new IndexDocumentBuilder())); $this->indexService->setServiceLocator($this->service); } return $this->indexService; } public function testCreateEmptyDocumentFromResource(): void { $indexService = $this->getIndexService(); $resource = $this->ontology->getClass(self::DOCUMENT_URI); $document = $indexService->createDocumentFromResource( $resource ); $this->assertInstanceOf(IndexDocument::class, $document); $this->assertEquals(self::DOCUMENT_URI, $document->getId()); $this->assertEquals(['type' => [], 'parent_classes' => ''], $document->getBody()); $this->assertEquals([], (array)$document->getDynamicProperties()); } public function testCreateDocumentFromResource(): void { $indexService = $this->getIndexService(); $document = $indexService->createDocumentFromArray( self::ARRAY_RESOURCE ); $this->assertInstanceOf(IndexDocument::class, $document); $this->assertEquals(self::DOCUMENT_URI, $document->getId()); $this->assertEquals(['type' => []], $document->getBody()); $this->assertEquals([], (array)$document->getDynamicProperties()); } }