Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / System / TokenReplaceWebTest.php
diff --git a/web/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php b/web/core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php
new file mode 100644 (file)
index 0000000..450f507
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\System;
+
+use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
+use Drupal\Tests\BrowserTestBase;
+use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
+
+/**
+ * Tests the token system integration.
+ *
+ * @group system
+ */
+class TokenReplaceWebTest extends BrowserTestBase {
+
+  use AssertPageCacheContextsAndTagsTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['token_test', 'filter', 'node'];
+
+  /**
+   * Tests a token replacement on an actual website.
+   */
+  public function testTokens() {
+    $node = $this->drupalCreateNode();
+    $account = $this->drupalCreateUser();
+    $this->drupalLogin($account);
+
+    $this->drupalGet('token-test/' . $node->id());
+    $this->assertText("Tokens: {$node->id()} {$account->id()}");
+    $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
+    $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);
+
+    $this->drupalGet('token-test-without-bubleable-metadata/' . $node->id());
+    $this->assertText("Tokens: {$node->id()} {$account->id()}");
+    $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
+    $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);
+  }
+
+}