SearchKeywordsConditionsTest.php in Drupal 8
File
core/modules/search/tests/src/Functional/SearchKeywordsConditionsTest.php
View source
<?php
namespace Drupal\Tests\search\Functional;
use Drupal\Component\Utility\Html;
use Drupal\Tests\BrowserTestBase;
class SearchKeywordsConditionsTest extends BrowserTestBase {
protected static $modules = [
'comment',
'search',
'search_extra_type',
'test_page_test',
];
protected $defaultTheme = 'stark';
protected $searchingUser;
protected function setUp() {
parent::setUp();
$this->searchingUser = $this
->drupalCreateUser([
'search content',
'access content',
'access comments',
'skip comment approval',
]);
$this
->drupalLogin($this->searchingUser);
}
public function testSearchKeywordsConditions() {
$this
->drupalGet('search/dummy_path');
$this
->assertNoText('Dummy search snippet to display');
$keys = 'bike shed ' . $this
->randomMachineName();
$this
->drupalGet("search/dummy_path", [
'query' => [
'keys' => $keys,
],
]);
$this
->assertText("Dummy search snippet to display. Keywords: {$keys}");
$keys = 'blue drop ' . $this
->randomMachineName();
$this
->drupalGet("search/dummy_path", [
'query' => [
'keys' => $keys,
],
]);
$this
->assertText("Dummy search snippet to display. Keywords: {$keys}");
$keys = 'moving drop ' . $this
->randomMachineName();
$this
->drupalGet("search/dummy_path", [
'query' => [
'keys' => 'bike',
'search_conditions' => $keys,
],
]);
$this
->assertText("Dummy search snippet to display.");
$this
->assertRaw(Html::escape(print_r([
'keys' => 'bike',
'search_conditions' => $keys,
], TRUE)));
}
}