SearchNodePunctuationTest.php in Drupal 8
File
core/modules/search/tests/src/Functional/SearchNodePunctuationTest.php
View source
<?php
namespace Drupal\Tests\search\Functional;
use Drupal\Tests\BrowserTestBase;
class SearchNodePunctuationTest extends BrowserTestBase {
protected static $modules = [
'node',
'search',
];
protected $defaultTheme = 'stark';
public $testUser;
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
node_access_rebuild();
$this->testUser = $this
->drupalCreateUser([
'access content',
'search content',
'use advanced search',
'access user profiles',
]);
$this
->drupalLogin($this->testUser);
}
public function testPhraseSearchPunctuation() {
$node = $this
->drupalCreateNode([
'body' => [
[
'value' => "The bunny's ears were fluffy.",
],
],
]);
$node2 = $this
->drupalCreateNode([
'body' => [
[
'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();
$this
->refreshVariables();
$edit = [
'keys' => '"bunny\'s"',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertText($node
->label());
$username = $node
->getOwner()
->getAccountName();
$this
->assertSession()
->linkExists($username);
$edit = [
'keys' => '&',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one keyword');
$edit = [
'keys' => '&',
];
$this
->drupalPostForm('search/node', $edit, t('Search'));
$this
->assertNoRaw('<strong>&</strong>amp;');
$this
->assertText('You must include at least one keyword');
}
}