Version 1
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / AreaViewTest.php
diff --git a/web/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php b/web/core/modules/views/tests/src/Kernel/Handler/AreaViewTest.php
new file mode 100644 (file)
index 0000000..6eaba13
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+namespace Drupal\Tests\views\Kernel\Handler;
+
+use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
+use Drupal\views\Views;
+
+/**
+ * Tests the view area handler.
+ *
+ * @group views
+ * @see \Drupal\views\Plugin\views\area\View
+ */
+class AreaViewTest extends ViewsKernelTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public 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->assertIdentical(['config' => ['views.view.test_simple_argument']], $view->getDependencies());
+
+    $this->executeView($view);
+    $output = $view->render();
+    $output = $renderer->renderRoot($output);
+    $this->assertTrue(strpos($output, 'js-view-dom-id-' . $view->dom_id) !== FALSE, 'The test view is correctly embedded.');
+    $view->destroy();
+
+    $view->setArguments([27]);
+    $this->executeView($view);
+    $output = $view->render();
+    $output = $renderer->renderRoot($output);
+    $this->assertTrue(strpos($output, 'John') === FALSE, 'The test view is correctly embedded with inherited arguments.');
+    $this->assertTrue(strpos($output, 'George') !== FALSE, 'The test view is correctly embedded with inherited arguments.');
+    $view->destroy();
+  }
+
+}