3 namespace Drupal\system\Tests\System;
5 use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
6 use Drupal\simpletest\WebTestBase;
7 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
10 * Tests the token system integration.
14 class TokenReplaceWebTest extends WebTestBase {
16 use AssertPageCacheContextsAndTagsTrait;
21 public static $modules = ['token_test', 'filter', 'node'];
24 * Tests a token replacement on an actual website.
26 public function testTokens() {
27 $node = $this->drupalCreateNode();
28 $account = $this->drupalCreateUser();
29 $this->drupalLogin($account);
31 $this->drupalGet('token-test/' . $node->id());
32 $this->assertText("Tokens: {$node->id()} {$account->id()}");
33 $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
34 $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);
36 $this->drupalGet('token-test-without-bubleable-metadata/' . $node->id());
37 $this->assertText("Tokens: {$node->id()} {$account->id()}");
38 $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
39 $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);