function PreviewTest::testPreviewAdditionalInfo

Same name in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  2. 8.9.x core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewAdditionalInfo()
  3. 11.x 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 153

Class

PreviewTest
Tests the UI preview functionality.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testPreviewAdditionalInfo() : void {
    \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');
}

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