SearchNodePunctuationTest.php in Drupal 10
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() : void {
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.",
],
],
]);
$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
->drupalGet('search/node');
$this
->submitForm($edit, 'Search');
$this
->assertSession()
->pageTextContains($node
->label());
$username = $node
->getOwner()
->getAccountName();
$this
->assertSession()
->linkExists($username);
$edit = [
'keys' => '&',
];
$this
->drupalGet('search/node');
$this
->submitForm($edit, 'Search');
$this
->assertSession()
->responseNotContains('<strong>&</strong>amp;');
$this
->assertSession()
->statusMessageContains('You must include at least one keyword', 'warning');
$edit = [
'keys' => '&',
];
$this
->drupalGet('search/node');
$this
->submitForm($edit, 'Search');
$this
->assertSession()
->responseNotContains('<strong>&</strong>amp;');
$this
->assertSession()
->statusMessageContains('You must include at least one keyword', 'warning');
}
}