function DisplayTest::testRenameDisplayAdminName

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php \Drupal\Tests\views_ui\FunctionalJavascript\DisplayTest::testRenameDisplayAdminName()
  2. 10 core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php \Drupal\Tests\views_ui\FunctionalJavascript\DisplayTest::testRenameDisplayAdminName()

Tests setting the administrative title.

File

core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php, line 89

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\FunctionalJavascript

Code

public function testRenameDisplayAdminName() : void {
    $titles = [
        'New admin title',
        '</title><script>alert("alert!")</script>',
    ];
    foreach ($titles as $new_title) {
        $this->drupalGet('admin/structure/views/view/test_content_ajax');
        $page = $this->getSession()
            ->getPage();
        $page->findLink('Edit view name/description')
            ->click();
        $this->getSession()
            ->executeScript("document.title = 'Initial title | " . \Drupal::config('system.site')->get('name') . "'");
        $admin_name_field = $this->assertSession()
            ->waitForField('Administrative name');
        $dialog_buttons = $page->find('css', '.ui-dialog-buttonset');
        $admin_name_field->setValue($new_title);
        $dialog_buttons->pressButton('Apply');
        $this->assertJsCondition("document.title === '" . $new_title . " (Content) | " . \Drupal::config('system.site')->get('name') . "'");
    }
}

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