AreaViewTest.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class AreaViewTest extends ViewsKernelTestBase {
protected static $modules = [
'user',
];
public static $testViews = [
'test_simple_argument',
'test_area_view',
];
public function testViewArea() {
$renderer = $this->container
->get('renderer');
$view = Views::getView('test_area_view');
$this
->assertSame([
'config' => [
'views.view.test_simple_argument',
],
'module' => [
'views_test_data',
],
], $view
->getDependencies());
$this
->executeView($view);
$output = $view
->render();
$output = $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 = $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();
}
}