function SearchNodeAccessTest::testPhraseSearchPunctuation in Drupal 7
Tests that search works with punctuation and HTML entities.
File
- modules/
search/ search.test, line 2065 - Tests for search.module.
Class
- SearchNodeAccessTest
- Tests node search with node access control.
Code
function testPhraseSearchPunctuation() {
$node = $this
->drupalCreateNode(array(
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => "The bunny's ears were fuzzy.",
),
),
),
));
$node2 = $this
->drupalCreateNode(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
->drupalPost('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
->drupalPost('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one positive keyword');
$edit = array(
'keys' => '&',
);
$this
->drupalPost('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one positive keyword');
}