class AreaViewTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest
- 10 core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest
- 8.9.x core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php \Drupal\Tests\views\Kernel\Handler\AreaViewTest
Tests the view area handler.
@group views
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\views\Kernel\Handler\AreaViewTest implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of AreaViewTest
See also
\Drupal\views\Plugin\views\area\View
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaViewTest.php, line 14
Namespace
Drupal\Tests\views\Kernel\HandlerView source
class AreaViewTest extends ViewsKernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'user',
];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_simple_argument',
'test_area_view',
];
/**
* Tests the view area handler.
*/
public function testViewArea() {
/** @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 = $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();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.