You are here

public function DisplayTest::testViewStatus in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/DisplayTest.php \Drupal\Tests\views_ui\Functional\DisplayTest::testViewStatus()
  2. 9 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 198

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testViewStatus() {
  $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')]");
}