searchEngineMock = $this->createMock(Search::class); $this->subject = new ElasticSearchBridge(); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ Search::SERVICE_ID => $this->searchEngineMock, ] ) ); } public function testSearch(): void { $query = new SearchQuery('user input', 'rootClass', 'parentClass', 1, 10, 1); $resultSetMock = $this->createMock(ResultSet::class); $this->searchEngineMock ->expects($this->once()) ->method('query') ->with( 'user input AND parent_classes: "parentClass"', 'rootClass', 1, 10 ) ->willReturn($resultSetMock); $result = $this->subject->search($query); $this->assertEquals($resultSetMock, $result); } }