protected function PreviewTest::testPreviewContextual

Tests contextual links in the preview form.

File

drupal/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php, line 33
Contains \Drupal\views_ui\Tests\PreviewTest.

Class

PreviewTest
Tests the preview form in the UI.

Namespace

Drupal\views_ui\Tests

Code

protected function testPreviewContextual() {
  module_enable(array(
    'contextual',
  ));
  $this
    ->drupalGet('admin/structure/views/view/test_preview/edit');
  $this
    ->assertResponse(200);
  $this
    ->drupalPost(NULL, $edit = array(), t('Update preview'));
  $elements = $this
    ->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(
    ':ul-class' => 'contextual-links',
    ':li-class' => 'filter-add',
  ));
  $this
    ->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.');
  $this
    ->drupalPost(NULL, $edit = array(
    'view_args' => '100',
  ), t('Update preview'));

  // Test that area text and exposed filters are present and rendered.
  $this
    ->assertFieldByName('id', NULL, 'ID exposed filter field found.');
  $this
    ->assertText('Test header text', 'Rendered header text found');
  $this
    ->assertText('Test footer text', 'Rendered footer text found.');
  $this
    ->assertText('Test empty text', 'Rendered empty text found.');
}