You are here

public function PreviewTest::testPreviewAdditionalInfo in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views_ui/src/Tests/PreviewTest.php \Drupal\views_ui\Tests\PreviewTest::testPreviewAdditionalInfo()

Tests the additional information query info area.

File

core/modules/views_ui/src/Tests/PreviewTest.php, line 215
Contains \Drupal\views_ui\Tests\PreviewTest.

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\views_ui\Tests

Code

public function testPreviewAdditionalInfo() {
  \Drupal::service('module_installer')
    ->install(array(
    'views_ui_test',
  ));
  $this
    ->resetAll();
  $this
    ->drupalGet('admin/structure/views/view/test_preview/edit');
  $this
    ->assertResponse(200);
  $this
    ->drupalPostForm(NULL, $edit = array(), t('Update preview'));

  // Check for implementation of hook_views_preview_info_alter().
  // @see views_ui_test.module
  $elements = $this
    ->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(
    ':text' => t('Test row count'),
  ));
  $this
    ->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.');

  // Check that additional assets are attached.
  $this
    ->assertTrue(strpos($this
    ->getDrupalSettings()['ajaxPageState']['libraries'], 'views_ui_test/views_ui_test.test') !== FALSE, 'Attached library found.');
  $this
    ->assertRaw('css/views_ui_test.test.css', 'Attached CSS asset found.');
}