You are here

public function DisplayPageWebTest::testPageDisplayMenu in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php \Drupal\views\Tests\Plugin\DisplayPageWebTest::testPageDisplayMenu()

Tests menu settings of page displays.

File

core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php, line 92
Contains \Drupal\views\Tests\Plugin\DisplayPageWebTest.

Class

DisplayPageWebTest
Tests the views page display plugin as webtest.

Namespace

Drupal\views\Tests\Plugin

Code

public function testPageDisplayMenu() {

  // Check local tasks.
  $this
    ->drupalGet('test_page_display_menu');
  $this
    ->assertResponse(200);
  $element = $this
    ->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
    ':ul_class' => 'tabs primary',
    ':a_class' => 'is-active',
  ));
  $this
    ->assertEqual((string) $element[0], t('Test default tab'));
  $this
    ->assertTitle(t('Test default page | Drupal'));
  $this
    ->drupalGet('test_page_display_menu/default');
  $this
    ->assertResponse(404);
  $this
    ->drupalGet('test_page_display_menu/local');
  $this
    ->assertResponse(200);
  $element = $this
    ->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
    ':ul_class' => 'tabs primary',
    ':a_class' => 'is-active',
  ));
  $this
    ->assertEqual((string) $element[0], t('Test local tab'));
  $this
    ->assertTitle(t('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((string) $menu_link[0], '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((string) $menu_link[0], 'New title');
}