You are here

public function DisplayTest::testActionLinks in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Tests the action links on the edit display UI.

File

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

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
    ->drupalGet($display_title_path);
  $this
    ->submitForm([
    'display_title' => $display_title,
  ], 'Apply');

  // Ensure that the title is escaped as expected.
  $this
    ->assertSession()
    ->assertEscaped($display_title);
  $this
    ->assertSession()
    ->responseNotContains($display_title);

  // Ensure that the dropdown buttons are displayed correctly.
  $this
    ->assertSession()
    ->buttonExists('Duplicate ' . $display_title);
  $this
    ->assertSession()
    ->buttonExists('Delete ' . $display_title);
  $this
    ->assertSession()
    ->buttonExists('Disable ' . $display_title);
  $this
    ->assertSession()
    ->buttonNotExists('Enable ' . $display_title);

  // Disable the display so we can test the rendering of the "Enable" button.
  $this
    ->submitForm([], 'Disable ' . $display_title);
  $this
    ->assertSession()
    ->buttonExists('Enable ' . $display_title);
  $this
    ->assertSession()
    ->buttonNotExists('Disable ' . $display_title);

  // Ensure that the title is escaped as expected.
  $this
    ->assertSession()
    ->assertEscaped($display_title);
  $this
    ->assertSession()
    ->responseNotContains($display_title);
}