You are here

function DefaultViewsTest::testSplitListing in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/views_ui/src/Tests/DefaultViewsTest.php \Drupal\views_ui\Tests\DefaultViewsTest::testSplitListing()

Tests that enabling views moves them to the correct table.

File

core/modules/views_ui/src/Tests/DefaultViewsTest.php, line 150
Contains \Drupal\views_ui\Tests\DefaultViewsTest.

Class

DefaultViewsTest
Tests enabling, disabling, and reverting default views via the listing page.

Namespace

Drupal\views_ui\Tests

Code

function testSplitListing() {

  // Build a re-usable xpath query.
  $xpath = '//div[@id="views-entity-list"]/div[@class = :status]/table//tr[@title = :title]';
  $arguments = array(
    ':status' => 'views-list-section enabled',
    ':title' => t('Machine name: test_view_status'),
  );
  $this
    ->drupalGet('admin/structure/views');
  $elements = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertIdentical(count($elements), 0, 'A disabled view is not found in the enabled views table.');
  $arguments[':status'] = 'views-list-section disabled';
  $elements = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertIdentical(count($elements), 1, 'A disabled view is found in the disabled views table.');

  // Enable the view.
  $this
    ->clickViewsOperationLink(t('Enable'), '/test_view_status/');
  $elements = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertIdentical(count($elements), 0, 'After enabling a view, it is not found in the disabled views table.');
  $arguments[':status'] = 'views-list-section enabled';
  $elements = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertIdentical(count($elements), 1, 'After enabling a view, it is found in the enabled views table.');

  // Attempt to disable the view by path directly, with no token.
  $this
    ->drupalGet('admin/structure/views/view/test_view_status/disable');
  $this
    ->assertResponse(403);
}