1 search.test SearchKeywordsConditions::testSearchKeywordsConditions()

Verify the keywords are captured and conditions respected.

File

core/modules/search/tests/search.test, line 1183
Tests for search.module.

Class

SearchKeywordsConditions
Tests keywords and conditions.

Code

function testSearchKeywordsConditions() {
  // No keys, not conditions - no results.
  $this->backdropGet('search/dummy_path');
  $this->assertNoText('Dummy search snippet to display');
  // With keys - get results.
  $keys = 'bike shed ' . $this->randomName();
  $this->backdropGet("search/dummy_path/{$keys}");
  $this->assertText("Dummy search snippet to display. Keywords: {$keys}");
  $keys = 'blue drop ' . $this->randomName();
  $this->backdropGet("search/dummy_path", array('query' => array('keys' => $keys)));
  $this->assertText("Dummy search snippet to display. Keywords: {$keys}");
  // Add some conditions and keys.
  $keys = 'moving drop ' . $this->randomName();
  $this->backdropGet("search/dummy_path/bike", array('query' => array('search_conditions' => $keys)));
  $this->assertText("Dummy search snippet to display.");
  $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE));
  // Add some conditions and no keys.
  $keys = 'drop kick ' . $this->randomName();
  $this->backdropGet("search/dummy_path", array('query' => array('search_conditions' => $keys)));
  $this->assertText("Dummy search snippet to display.");
  $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE));
}