/** * @test */ public function testAdditionalFiltersGetPassedToTheQuery() { $this->fakeRegisteredSearchComponents(array()); $fakeResponse = $this->getDumbMock('\\Apache_Solr_Response'); $this->assertOneSearchWillBeTriggeredWithQueryAndShouldReturnFakeResponse('test', 0, $fakeResponse); $this->configurationMock->expects($this->any())->method('getSearchQueryFilterConfiguration')->will($this->returnValue(array('type:pages'))); $fakeRequest = new SearchRequest(array('q' => 'test')); $this->assertOneSearchWillBeTriggeredWithQueryAndShouldReturnFakeResponse('test', 0, $fakeResponse); $this->assertPerPageInSessionWillNotBeChanged(); $resultSet = $this->searchResultSetService->search($fakeRequest); $this->assertSame($resultSet->getResponse(), $fakeResponse, 'Did not get the expected fakeResponse'); $this->assertSame(count($resultSet->getUsedQuery()->getFilters()), 1, 'There should be one registered filter in the query'); }
/** * @test */ public function testExpandedDocumentsGetAddedWhenVariantsAreConfigured() { // we fake that collapsing is enabled $this->configurationMock->expects($this->atLeastOnce())->method('getSearchVariants')->will($this->returnValue(true)); // in this case we collapse on the type field $this->configurationMock->expects($this->atLeastOnce())->method('getSearchVariantsField')->will($this->returnValue('type')); $this->fakeRegisteredSearchComponents(array()); $fakedSolrResponse = $this->getFixtureContent('fakeCollapsedResponse.json'); $fakeHttpResponse = $this->getDumbMock('\\Apache_Solr_HttpTransport_Response'); $fakeHttpResponse->expects($this->once())->method('getBody')->will($this->returnValue($fakedSolrResponse)); $fakeResponse = new \Apache_Solr_Response($fakeHttpResponse); $this->assertOneSearchWillBeTriggeredWithQueryAndShouldReturnFakeResponse('variantsSearch', 0, $fakeResponse); $fakeRequest = new SearchRequest(array('q' => 'variantsSearch')); $resultSet = $this->searchResultSetService->search($fakeRequest); $this->assertSame(1, count($resultSet->getResponse()->response->docs), 'Unexpected amount of document'); /** @var $fistResult SearchResult */ $fistResult = $resultSet->getResponse()->response->docs[0]; $this->assertSame(5, count($fistResult->getVariants()), 'Unexpected amount of expanded result'); }