You are here

public function DisplayTest::testDisableDisplay 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::testDisableDisplay()
  2. 10 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testDisableDisplay()

Tests disabling of a display.

File

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

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testDisableDisplay() {
  $view = $this
    ->randomView();
  $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';

  // Verify that the disabled display css class does not appear after initial
  // adding of a view.
  $this
    ->drupalGet($path_prefix);
  $this
    ->assertSession()
    ->elementNotExists('xpath', "//div[contains(@class, 'views-display-disabled')]");
  $this
    ->assertSession()
    ->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable');
  $this
    ->assertSession()
    ->buttonNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable');

  // Verify that the disabled display css class appears once the display is
  // marked as such.
  $this
    ->submitForm([], 'Disable Page');
  $this
    ->assertSession()
    ->elementExists('xpath', "//div[contains(@class, 'views-display-disabled')]");
  $this
    ->assertSession()
    ->buttonNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable');
  $this
    ->assertSession()
    ->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable');

  // Verify that the disabled display css class does not appears once the
  // display is enabled again.
  $this
    ->submitForm([], 'Enable Page');
  $this
    ->assertSession()
    ->elementNotExists('xpath', "//div[contains(@class, 'views-display-disabled')]");
}