1<?php 2 3namespace Drupal\Tests\views\Kernel\Handler; 4 5use Drupal\Tests\views\Kernel\ViewsKernelTestBase; 6use Drupal\views\Views; 7 8/** 9 * Tests the view area handler. 10 * 11 * @group views 12 * @see \Drupal\views\Plugin\views\area\View 13 */ 14class AreaViewTest extends ViewsKernelTestBase { 15 16 /** 17 * Modules to enable. 18 * 19 * @var array 20 */ 21 protected static $modules = ['user']; 22 23 /** 24 * Views used by this test. 25 * 26 * @var array 27 */ 28 public static $testViews = ['test_simple_argument', 'test_area_view']; 29 30 /** 31 * Tests the view area handler. 32 */ 33 public function testViewArea() { 34 /** @var \Drupal\Core\Render\RendererInterface $renderer */ 35 $renderer = $this->container->get('renderer'); 36 $view = Views::getView('test_area_view'); 37 38 // Tests \Drupal\views\Plugin\views\area\View::calculateDependencies(). 39 $this->assertSame(['config' => ['views.view.test_simple_argument'], 'module' => ['views_test_data']], $view->getDependencies()); 40 41 $this->executeView($view); 42 $output = $view->render(); 43 $output = $renderer->renderRoot($output); 44 $this->assertStringContainsString('js-view-dom-id-' . $view->dom_id, $output, 'The test view is correctly embedded.'); 45 $view->destroy(); 46 47 $view->setArguments([27]); 48 $this->executeView($view); 49 $output = $view->render(); 50 $output = $renderer->renderRoot($output); 51 $this->assertStringNotContainsString('John', $output, 'The test view is correctly embedded with inherited arguments.'); 52 $this->assertStringContainsString('George', $output, 'The test view is correctly embedded with inherited arguments.'); 53 $view->destroy(); 54 } 55 56} 57