function DisplayPageWebTest::testPageDisplayMenu
Same name in other branches
- 8.9.x core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testPageDisplayMenu()
- 10 core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testPageDisplayMenu()
- 11.x core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::testPageDisplayMenu()
Tests menu settings of page displays.
File
-
core/
modules/ views/ tests/ src/ Functional/ Plugin/ DisplayPageWebTest.php, line 95
Class
- DisplayPageWebTest
- Tests the views page display plugin as webtest.
Namespace
Drupal\Tests\views\Functional\PluginCode
public function testPageDisplayMenu() {
// Check local tasks.
$this->drupalGet('test_page_display_menu');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->elementTextEquals('xpath', "//ul[contains(@class, 'tabs primary')]//a[contains(@class, 'is-active')]/child::text()", 'Test default tab');
$this->assertSession()
->titleEquals('Test default page | Drupal');
$this->drupalGet('test_page_display_menu/default');
$this->assertSession()
->statusCodeEquals(404);
$this->drupalGet('test_page_display_menu/local');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->elementTextEquals('xpath', "//ul[contains(@class, 'tabs primary')]//a[contains(@class, 'is-active')]/child::text()", 'Test local tab');
$this->assertSession()
->titleEquals('Test local page | Drupal');
// Check an ordinary menu link.
$admin_user = $this->drupalCreateUser([
'administer menu',
]);
$this->drupalLogin($admin_user);
$this->drupalPlaceBlock('system_menu_block:tools');
$this->drupalGet('<front>');
$menu_link = $this->cssSelect('nav.block-menu ul.menu a');
$this->assertEquals('Test menu link', $menu_link[0]->getText());
$this->container
->get('module_installer')
->install([
'menu_ui',
'menu_link_content',
]);
// Update the menu link.
$this->drupalGet("admin/structure/menu/link/views_view:views.test_page_display_menu.page_3/edit");
$this->submitForm([
'title' => 'New title',
], 'Save');
$this->drupalGet('<front>');
$menu_link = $this->cssSelect('nav.block-menu ul.menu a');
$this->assertEquals('New title', $menu_link[0]->getText());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.