function DisplayTest::testActionLinks

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testActionLinks()
  2. 10 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testActionLinks()
  3. 11.x core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testActionLinks()

Tests the action links on the edit display UI.

File

core/modules/views_ui/tests/src/Functional/DisplayTest.php, line 237

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testActionLinks() {
    // Change the display title of a display so it contains characters that will
    // be escaped when rendered.
    $display_title = "'<test>'";
    $this->drupalGet('admin/structure/views/view/test_display');
    $display_title_path = 'admin/structure/views/nojs/display/test_display/block_1/display_title';
    $this->drupalPostForm($display_title_path, [
        'display_title' => $display_title,
    ], t('Apply'));
    // Ensure that the title is escaped as expected.
    $this->assertEscaped($display_title);
    $this->assertNoRaw($display_title);
    // Ensure that the dropdown buttons are displayed correctly.
    $this->assertFieldByXpath('//input[@type="submit"]', 'Duplicate ' . $display_title);
    $this->assertFieldByXpath('//input[@type="submit"]', 'Delete ' . $display_title);
    $this->assertFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title);
    $this->assertNoFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title);
    // Disable the display so we can test the rendering of the "Enable" button.
    $this->drupalPostForm(NULL, NULL, 'Disable ' . $display_title);
    $this->assertFieldByXpath('//input[@type="submit"]', 'Enable ' . $display_title);
    $this->assertNoFieldByXpath('//input[@type="submit"]', 'Disable ' . $display_title);
    // Ensure that the title is escaped as expected.
    $this->assertEscaped($display_title);
    $this->assertNoRaw($display_title);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.