コード例 #1
0
 /**
  * @test
  */
 public function databaseResultIsUsedWhenNoCachedResultIsPresent()
 {
     $fakeConfiguration = array('select.' => array('checkRootPageId' => true, 'checkLanguage' => true, 'SELECT' => '', 'FROM' => '', 'ADD_WHERE' => '', 'GROUP_BY' => '', 'ORDER_BY' => ''), 'limit');
     $this->configurationMock->expects($this->once())->method('getSearchFrequentSearchesConfiguration')->will($this->returnValue($fakeConfiguration));
     $this->databaseMock->expects($this->once())->method('exec_SELECTgetRows')->will($this->returnValue(array(array('search_term' => 'my search', 'hits' => 22))));
     //we fake that we have no frequent searches in the cache and therefore expect that the database will be queried
     $this->fakeIdentifierNotInCache();
     $frequentTerms = $this->frequentSearchesService->getFrequentSearchTerms();
     $this->assertSame($frequentTerms, array('my search' => 22), 'Could not retrieve frequent search terms');
 }
コード例 #2
0
 /**
  * @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');
 }
コード例 #3
0
 /**
  * @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');
 }
コード例 #4
0
 public function setUp()
 {
     $this->typoScripConfigurationMock = $this->getDumbMock('ApacheSolrForTypo3\\Solr\\System\\Configuration\\TypoScriptConfiguration');
     $this->typoScripConfigurationMock->expects($this->once())->method('getIndexQueuePagesExcludeContentByClassArray')->will($this->returnValue(array('typo3-search-exclude')));
 }
コード例 #5
0
 /**
  * @param int $limit
  */
 protected function fakeLastSearchLimit($limit)
 {
     $this->configurationMock->expects($this->once())->method('getSearchLastSearchesLimit')->will($this->returnValue($limit));
 }