function DisplayTest::testDisableDisplay

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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')]");
}

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