function DisplayTest::testHideDisplayOverride

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

Tests that the override option is hidden when it's not needed.

File

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

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testHideDisplayOverride() : void {
    // Test that the override option appears with two displays.
    $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
    $this->assertSession()
        ->pageTextContains('All displays');
    // Remove a display and test if the override option is hidden.
    $this->drupalGet('admin/structure/views/view/test_display/edit/block_1');
    $this->submitForm([], 'Delete Block');
    $this->submitForm([], 'Save');
    $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
    $this->assertSession()
        ->pageTextNotContains('All displays');
    // Test that the override option is shown when default display is on.
    \Drupal::configFactory()->getEditable('views.settings')
        ->set('ui.show.default_display', TRUE)
        ->save();
    $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
    $this->assertSession()
        ->pageTextContains('All displays');
    // Test that the override option is shown if the current display is
    // overridden so that the option to revert is available.
    $this->submitForm([
        'override[dropdown]' => 'page_1',
    ], 'Apply');
    \Drupal::configFactory()->getEditable('views.settings')
        ->set('ui.show.default_display', FALSE)
        ->save();
    $this->drupalGet('admin/structure/views/nojs/handler/test_display/page_1/field/title');
    $this->assertSession()
        ->pageTextContains('Revert to default');
}

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