function ViewsTemplateTest::testTemplate

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/ViewsTemplateTest.php \Drupal\Tests\views\Kernel\ViewsTemplateTest::testTemplate()
  2. 10 core/modules/views/tests/src/Kernel/ViewsTemplateTest.php \Drupal\Tests\views\Kernel\ViewsTemplateTest::testTemplate()
  3. 11.x core/modules/views/tests/src/Kernel/ViewsTemplateTest.php \Drupal\Tests\views\Kernel\ViewsTemplateTest::testTemplate()

Tests render functionality.

File

core/modules/views/tests/src/Kernel/ViewsTemplateTest.php, line 36

Class

ViewsTemplateTest
Tests the template retrieval of views.

Namespace

Drupal\Tests\views\Kernel

Code

public function testTemplate() {
    // Make sure that the rendering just calls the preprocess function once.
    $output = Views::getView('test_view_display_template')->preview();
    $renderer = $this->container
        ->get('renderer');
    // Check that the rendered output uses the correct template file.
    $this->assertStringContainsString('This module defines its own display template.', (string) $renderer->renderRoot($output));
}

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