function PreviewTest::testPreviewAdditionalInfo

Same name and namespace in other branches
  1. 11.x core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  2. 10 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  3. 9 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  4. main core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()

Tests the additional information query info area.

File

core/modules/views_ui/tests/src/Functional/PreviewTest.php, line 136

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testPreviewAdditionalInfo() {
  \Drupal::service('module_installer')->install([
    'views_ui_test',
  ]);
  $this->resetAll();
  $this->drupalGet('admin/structure/views/view/test_preview/edit');
  $this->assertSession()
    ->statusCodeEquals(200);
  $this->drupalPostForm(NULL, $edit = [], 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]', [
    ':text' => 'Test row count',
  ]);
  $this->assertCount(1, $elements, 'Views Query Preview Info area altered.');
  // Check that additional assets are attached.
  $this->assertStringContainsString('views_ui_test/views_ui_test.test', $this->getDrupalSettings()['ajaxPageState']['libraries'], 'Attached library found.');
  $this->assertRaw('css/views_ui_test.test.css', 'Attached CSS asset found.');
}

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