function DisplayTest::testViewStatus

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testViewStatus()
  2. 8.9.x core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testViewStatus()
  3. 11.x core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testViewStatus()

Tests that the view status is correctly reflected on the edit form.

File

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

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testViewStatus() : void {
    $view = $this->randomView();
    $id = $view['id'];
    // The view should initially have the enabled class on its form wrapper.
    $this->drupalGet('admin/structure/views/view/' . $id);
    $this->assertSession()
        ->elementExists('xpath', "//div[contains(@class, 'views-edit-view') and contains(@class, 'enabled')]");
    $view = Views::getView($id);
    $view->storage
        ->disable()
        ->save();
    // The view should now have the disabled class on its form wrapper.
    $this->drupalGet('admin/structure/views/view/' . $id);
    $this->assertSession()
        ->elementExists('xpath', "//div[contains(@class, 'views-edit-view') and contains(@class, 'disabled')]");
}

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