function ViewRenderTest::testRender

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

Tests render functionality.

File

core/modules/views/tests/src/Kernel/ViewRenderTest.php, line 22

Class

ViewRenderTest
Tests general rendering of a view.

Namespace

Drupal\Tests\views\Kernel

Code

public function testRender() {
    $state = $this->container
        ->get('state');
    $state->set('views_render.test', 0);
    // Make sure that the rendering just calls the preprocess function once.
    $view = Views::getView('test_view_render');
    $output = $view->preview();
    $this->container
        ->get('renderer')
        ->renderRoot($output);
    $this->assertEquals(1, $state->get('views_render.test'));
}

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