1 search.test SearchNodeAccessTest::testPhraseSearchPunctuation()

Tests that search works with punctuation and HTML entities.

File

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

Class

SearchNodeAccessTest
Tests node search with node access control.

Code

function testPhraseSearchPunctuation() {
  $node = $this->backdropCreateNode(array('body' => array(LANGUAGE_NONE => array(array('value' => "The bunny's ears were fuzzy.")))));
  $node2 = $this->backdropCreateNode(array('body' => array(LANGUAGE_NONE => array(array('value' => 'Dignissim Aliquam & Quieligo meus natu quae quia te. Damnum© erat— neo pneum. Facilisi feugiat ibidem ratis.')))));

  // Update the search index.
  module_invoke_all('update_index');
  search_update_totals();

  // Refresh variables after the treatment.
  $this->refreshVariables();

  // Submit a phrase wrapped in double quotes to include the punctuation.
  $edit = array('keys' => '"bunny\'s"');
  $this->backdropPost('search/node', $edit, t('Search'));
  $this->assertText($node->title);

  // Search for "&" and verify entities are not broken up in the output.
  $edit = array('keys' => '&');
  $this->backdropPost('search/node', $edit, t('Search'));
  $this->assertNoRaw('<strong>&</strong>amp;');
  $this->assertText('You must include at least one keyword to match in the content. Keywords must be at least 3 characters, and punctuation is ignored.');

  $edit = array('keys' => '&amp;');
  $this->backdropPost('search/node', $edit, t('Search'));
  $this->assertNoRaw('<strong>&</strong>amp;');
  $this->assertText('You must include at least one keyword to match in the content. Keywords must be at least 3 characters, and punctuation is ignored.');
}