ViewRenderTest.php

Same filename and directory in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewRenderTest.php
  2. 8.9.x core/modules/views/tests/src/Kernel/ViewRenderTest.php
  3. 10 core/modules/views/tests/src/Kernel/ViewRenderTest.php

Namespace

Drupal\Tests\views\Kernel

File

core/modules/views/tests/src/Kernel/ViewRenderTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\views\Kernel;

use Drupal\views\Views;

/**
 * Tests general rendering of a view.
 *
 * @group views
 */
class ViewRenderTest extends ViewsKernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $testViews = [
        'test_view_render',
    ];
    
    /**
     * Tests render functionality.
     */
    public function testRender() : void {
        $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'));
    }

}

Classes

Title Deprecated Summary
ViewRenderTest Tests general rendering of a view.

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