You are here

public function DisplayTest::testHideDisplayOverride 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::testHideDisplayOverride()

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

File

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

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
    ->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');
}