function DisplayTest::testViewStatus

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

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);
    $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [
        ':edit' => 'views-edit-view',
        ':status' => 'enabled',
    ]);
    $this->assertNotEmpty($elements, 'The enabled class was found on the form wrapper');
    $view = Views::getView($id);
    $view->storage
        ->disable()
        ->save();
    $this->drupalGet('admin/structure/views/view/' . $id);
    $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [
        ':edit' => 'views-edit-view',
        ':status' => 'disabled',
    ]);
    $this->assertNotEmpty($elements, 'The disabled class was found on the form wrapper.');
}

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