ontology = $this->createMock(Ontology::class); $this->subject = new IdentifierSearcher(); $this->subject->withLocalNamespace(self::LOCAL_NAMESPACE); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ Ontology::SERVICE_ID => $this->ontology, ] ) ); } public function testSearchByNoUri(): void { $query = new SearchQuery( 'user input', 'rootClass', 'parentClass', 1, 10, 1 ); $this->assertEquals(new ResultSet([], 0), $this->subject->search($query)); } public function testSearchByUri(): void { $uri = self::LOCAL_NAMESPACE; $label = 'My Resource label'; $query = new SearchQuery( $uri, 'rootClass', 'parentClass', 1, 10, 1 ); $resultSetMock = new ResultSet( [ [ 'id' => $uri, 'label' => $label, ], ], 1 ); $resource = $this->createMock(core_kernel_classes_Resource::class); $class = $this->createMock(core_kernel_classes_Class::class); $this->ontology ->method('getResource') ->willReturn($resource); $this->ontology ->method('getClass') ->willReturn($class); $resource ->method('exists') ->willReturn(true); $resource ->method('isInstanceOf') ->willReturn(true); $resource ->method('getUri') ->willReturn($uri); $resource ->method('getLabel') ->willReturn($label); $this->assertEquals($resultSetMock, $this->subject->search($query)); } }