SearchNodePunctuationTest.php in Zircon Profile 8.0
File
core/modules/search/src/Tests/SearchNodePunctuationTest.php
View source
<?php
namespace Drupal\search\Tests;
class SearchNodePunctuationTest extends SearchTestBase {
public $testUser;
protected function setUp() {
parent::setUp();
node_access_rebuild();
$this->testUser = $this
->drupalCreateUser(array(
'access content',
'search content',
'use advanced search',
'access user profiles',
));
$this
->drupalLogin($this->testUser);
}
function testPhraseSearchPunctuation() {
$node = $this
->drupalCreateNode(array(
'body' => array(
array(
'value' => "The bunny's ears were fluffy.",
),
),
));
$node2 = $this
->drupalCreateNode(array(
'body' => array(
array(
'value' => 'Dignissim Aliquam & Quieligo meus natu quae quia te. Damnum© erat— neo pneum. Facilisi feugiat ibidem ratis.',
),
),
));
$this->container
->get('plugin.manager.search')
->createInstance('node_search')
->updateIndex();
search_update_totals();
$this
->refreshVariables();
$edit = array(
'keys' => '"bunny\'s"',
);
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertText($node
->label());
$username = $node
->getOwner()
->getUsername();
$this
->assertLink($username);
$edit = array(
'keys' => '&',
);
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one keyword');
$edit = array(
'keys' => '&',
);
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one keyword');
}
}