Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Common / RenderWebTest.php
diff --git a/web/core/modules/system/tests/src/Functional/Common/RenderWebTest.php b/web/core/modules/system/tests/src/Functional/Common/RenderWebTest.php
new file mode 100644 (file)
index 0000000..65d2604
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\Common;
+
+use Drupal\Component\Serialization\Json;
+use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
+use Drupal\Tests\BrowserTestBase;
+use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
+
+/**
+ * Performs integration tests on drupal_render().
+ *
+ * @group Common
+ */
+class RenderWebTest extends BrowserTestBase {
+
+  use AssertPageCacheContextsAndTagsTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['common_test'];
+
+  /**
+   * Asserts the cache context for the wrapper format is always present.
+   */
+  public function testWrapperFormatCacheContext() {
+    $this->drupalGet('common-test/type-link-active-class');
+    $this->assertIdentical(0, strpos($this->getSession()->getPage()->getContent(), "<!DOCTYPE html>\n<html"));
+    $this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
+    $this->assertTitle('Test active link class | Drupal');
+    $this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
+
+    $this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
+    $this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
+    $json = Json::decode($this->getSession()->getPage()->getContent());
+    $this->assertEqual(['content', 'title'], array_keys($json));
+    $this->assertIdentical('Test active link class', $json['title']);
+    $this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
+  }
+
+}