function DisplayTest::testDisableDisplay

Same name in other branches
  1. 9 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 86

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';
    $this->drupalGet($path_prefix);
    $this->assertEmpty($this->xpath('//div[contains(@class, :class)]', [
        ':class' => 'views-display-disabled',
    ]), 'Make sure the disabled display css class does not appear after initial adding of a view.');
    $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.');
    $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.');
    $this->drupalPostForm(NULL, [], 'Disable Page');
    $this->assertNotEmpty($this->xpath('//div[contains(@class, :class)]', [
        ':class' => 'views-display-disabled',
    ]), 'Make sure the disabled display css class appears once the display is marked as such.');
    $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.');
    $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is visible.');
    $this->drupalPostForm(NULL, [], 'Enable Page');
    $this->assertEmpty($this->xpath('//div[contains(@class, :class)]', [
        ':class' => 'views-display-disabled',
    ]), 'Make sure the disabled display css class does not appears once the display is enabled again.');
}

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