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. 10 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 268

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

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

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