class TestSearch in Google Search Appliance 8
Defines a test only search implementation.
Hierarchy
- class \Drupal\google_appliance\Service\Search implements SearchInterface- class \Drupal\google_appliance_test\TestSearch
 
Expanded class hierarchy of TestSearch
File
- tests/modules/ google_appliance_test/ src/ TestSearch.php, line 14 
Namespace
Drupal\google_appliance_testView source
class TestSearch extends Search {
  const TOTAL = 100;
  /**
   * {@inheritdoc}
   */
  public function search(SearchQuery $searchQuery) {
    $config = $this->configFactory
      ->get('google_appliance.settings');
    $perPage = $config
      ->get('display_settings.results_per_page');
    $result = new ResultSet();
    $result
      ->setTotal(self::TOTAL)
      ->setLastResult(20);
    foreach (range(1, $perPage) as $item) {
      $result
        ->addResult(new Result('http://example.com', 'http://example.com', sprintf('Result %d', $item), sprintf('this is a snippet from item %d', $item), date('Y-m-d'), 'text/html'));
    }
    if ($searchQuery
      ->getSearchQuery() === 'unicorns') {
      $result
        ->addSynonym(new Synonym('Donkeys', 'donkeys'));
    }
    return $result
      ->setSearchTitle($config
      ->get('display_settings.search_title'))
      ->setQuery($searchQuery)
      ->setResultsPerPage($perPage);
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| Search:: | protected | property | Config factory. | |
| Search:: | protected | property | HTTP Client. | |
| Search:: | protected | property | Module handler. | |
| Search:: | protected | property | Parser. | |
| Search:: | public | function | Constructs a new Search object. | |
| TestSearch:: | public | function | Performs search. Overrides Search:: | |
| TestSearch:: | constant | 
