1 search.test SearchKeywordsConditions::testSearchKeyswordsConditions()

Verify the kewords are captured and conditions respected.

File

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

Class

SearchKeywordsConditions
Tests keywords and conditions.

Code

function testSearchKeyswordsConditions() {
  // 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));
}