function DefaultViewsTest::testSplitListing

Tests that enabling views moves them to the correct table.

File

drupal/core/modules/views/lib/Drupal/views/Tests/UI/DefaultViewsTest.php, line 128
Definition of Drupal\views\Tests\UI\DefaultViewsTest.

Class

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

Namespace

Drupal\views\Tests\UI

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.');
}