function SearchKeywordsConditions::testSearchKeyswordsConditions

7.x search.test SearchKeywordsConditions::testSearchKeyswordsConditions()

Verify the kewords are captured and conditions respected.

File

drupal-7.x/modules/search/search.test, line 1212
Tests for search.module.

Class

SearchKeywordsConditions
Tests keywords and conditions.

Code

function testSearchKeyswordsConditions() {
  // No keys, not conditions - no results.
  $this->drupalGet('search/dummy_path');
  $this->assertNoText('Dummy search snippet to display');
  // With keys - get results.
  $keys = 'bike shed ' . $this->randomName();
  $this->drupalGet("search/dummy_path/{$keys}");
  $this->assertText("Dummy search snippet to display. Keywords: {$keys}");
  $keys = 'blue drop ' . $this->randomName();
  $this->drupalGet("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->drupalGet("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->drupalGet("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));
}