Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / AreaViewTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Kernel\Handler;
4
5 use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
6 use Drupal\views\Views;
7
8 /**
9  * Tests the view area handler.
10  *
11  * @group views
12  * @see \Drupal\views\Plugin\views\area\View
13  */
14 class AreaViewTest extends ViewsKernelTestBase {
15
16   /**
17    * Modules to enable.
18    *
19    * @var array
20    */
21   public 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->assertIdentical(['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->assertTrue(strpos($output, 'js-view-dom-id-' . $view->dom_id) !== FALSE, '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->assertTrue(strpos($output, 'John') === FALSE, 'The test view is correctly embedded with inherited arguments.');
52     $this->assertTrue(strpos($output, 'George') !== FALSE, 'The test view is correctly embedded with inherited arguments.');
53     $view->destroy();
54   }
55
56 }