public function DisplayPageWebTest::testPageDisplayMenu in Drupal 8
Same name and namespace in other branches
- 9 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 93
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);
$element = $this
->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]/child::text()', [
':ul_class' => 'tabs primary',
':a_class' => 'is-active',
]);
$this
->assertEqual($element[0]
->getText(), t('Test default tab'));
$this
->assertTitle('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);
$element = $this
->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]/child::text()', [
':ul_class' => 'tabs primary',
':a_class' => 'is-active',
]);
$this
->assertEqual($element[0]
->getText(), t('Test local tab'));
$this
->assertTitle('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
->assertEqual($menu_link[0]
->getText(), 'Test menu link');
// Update the menu link.
$this
->drupalPostForm("admin/structure/menu/link/views_view:views.test_page_display_menu.page_3/edit", [
'title' => 'New title',
], t('Save'));
$this
->drupalGet('<front>');
$menu_link = $this
->cssSelect('nav.block-menu ul.menu a');
$this
->assertEqual($menu_link[0]
->getText(), 'New title');
}