Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\system\Tests\System;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
Chris@0
|
6 use Drupal\simpletest\WebTestBase;
|
Chris@0
|
7 use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
Chris@0
|
8
|
Chris@0
|
9 /**
|
Chris@0
|
10 * Tests the token system integration.
|
Chris@0
|
11 *
|
Chris@0
|
12 * @group system
|
Chris@0
|
13 */
|
Chris@0
|
14 class TokenReplaceWebTest extends WebTestBase {
|
Chris@0
|
15
|
Chris@0
|
16 use AssertPageCacheContextsAndTagsTrait;
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * {@inheritdoc}
|
Chris@0
|
20 */
|
Chris@0
|
21 public static $modules = ['token_test', 'filter', 'node'];
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Tests a token replacement on an actual website.
|
Chris@0
|
25 */
|
Chris@0
|
26 public function testTokens() {
|
Chris@0
|
27 $node = $this->drupalCreateNode();
|
Chris@0
|
28 $account = $this->drupalCreateUser();
|
Chris@0
|
29 $this->drupalLogin($account);
|
Chris@0
|
30
|
Chris@0
|
31 $this->drupalGet('token-test/' . $node->id());
|
Chris@0
|
32 $this->assertText("Tokens: {$node->id()} {$account->id()}");
|
Chris@0
|
33 $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
|
Chris@0
|
34 $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);
|
Chris@0
|
35
|
Chris@0
|
36 $this->drupalGet('token-test-without-bubleable-metadata/' . $node->id());
|
Chris@0
|
37 $this->assertText("Tokens: {$node->id()} {$account->id()}");
|
Chris@0
|
38 $this->assertCacheTags(['node:1', 'rendered', 'user:2']);
|
Chris@0
|
39 $this->assertCacheContexts(['languages:language_interface', 'theme', 'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT, 'user']);
|
Chris@0
|
40 }
|
Chris@0
|
41
|
Chris@0
|
42 }
|