You are here

public function PreviewTest::testPreviewAdditionalInfo in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  2. 9 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 144

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
    ->submitForm($edit = [], 'Update preview');

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

  // Check that additional assets are attached.
  $this
    ->assertStringContainsString('views_ui_test/views_ui_test.test', $this
    ->getDrupalSettings()['ajaxPageState']['libraries'], 'Attached library found.');
  $this
    ->assertSession()
    ->responseContains('css/views_ui_test.test.css');
}