function AreaViewTest::testViewArea

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest::testViewArea()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest::testViewArea()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest::testViewArea()

Tests the view area handler.

File

core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php, line 33

Class

AreaViewTest
Tests the view area handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testViewArea() : void {
    
    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = $this->container
        ->get('renderer');
    $view = Views::getView('test_area_view');
    // Tests \Drupal\views\Plugin\views\area\View::calculateDependencies().
    $this->assertSame([
        'config' => [
            'views.view.test_simple_argument',
        ],
        'module' => [
            'views_test_data',
        ],
    ], $view->getDependencies());
    $this->executeView($view);
    $output = $view->render();
    $output = (string) $renderer->renderRoot($output);
    $this->assertStringContainsString('js-view-dom-id-' . $view->dom_id, $output, 'The test view is correctly embedded.');
    $view->destroy();
    $view->setArguments([
        27,
    ]);
    $this->executeView($view);
    $output = $view->render();
    $output = (string) $renderer->renderRoot($output);
    $this->assertStringNotContainsString('John', $output, 'The test view is correctly embedded with inherited arguments.');
    $this->assertStringContainsString('George', $output, 'The test view is correctly embedded with inherited arguments.');
    $view->destroy();
}

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