class SearchPageOverrideTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/search/tests/src/Functional/SearchPageOverrideTest.php \Drupal\Tests\search\Functional\SearchPageOverrideTest
- 9 core/modules/search/tests/src/Functional/SearchPageOverrideTest.php \Drupal\Tests\search\Functional\SearchPageOverrideTest
Tests if the result page can be overridden.
Verifies that a plugin can override the buildResults() method to control what the search results page looks like.
@group search
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\search\Functional\SearchPageOverrideTest
Expanded class hierarchy of SearchPageOverrideTest
File
- core/
modules/ search/ tests/ src/ Functional/ SearchPageOverrideTest.php, line 15
Namespace
Drupal\Tests\search\FunctionalView source
class SearchPageOverrideTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'search',
'search_extra_type',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A user with permission to administer search.
*
* @var \Drupal\user\UserInterface
*/
public $searchUser;
protected function setUp() : void {
parent::setUp();
// Log in as a user that can create and search content.
$this->searchUser = $this
->drupalCreateUser([
'search content',
'administer search',
]);
$this
->drupalLogin($this->searchUser);
}
public function testSearchPageHook() {
$keys = 'bike shed ' . $this
->randomMachineName();
$this
->drupalGet("search/dummy_path", [
'query' => [
'keys' => $keys,
],
]);
$this
->assertSession()
->pageTextContains('Dummy search snippet');
$this
->assertSession()
->pageTextContains('Test page text is here');
}
}