You are here

ViewsTemplateTest.php in Drupal 9

Same filename and directory in other branches
  1. 8 core/modules/views/tests/src/Kernel/ViewsTemplateTest.php

File

core/modules/views/tests/src/Kernel/ViewsTemplateTest.php
View source
<?php

namespace Drupal\Tests\views\Kernel;

use Drupal\views\Views;

/**
 * Tests the template retrieval of views.
 *
 * @group views
 *
 * @see \Drupal\views_test_data\Plugin\views\style\StyleTemplateTest
 */
class ViewsTemplateTest extends ViewsKernelTestBase {

  /**
   * {@inheritdoc}
   */
  public static $testViews = [
    'test_view_display_template',
  ];

  /**
   * Tests render functionality.
   */
  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));
  }

}

Classes

Namesort descending Description
ViewsTemplateTest Tests the template retrieval of views.