TokenReplaceWebTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/System/TokenReplaceWebTest.php
View source
<?php
namespace Drupal\system\Tests\System;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
class TokenReplaceWebTest extends WebTestBase {
use AssertPageCacheContextsAndTagsTrait;
public static $modules = [
'token_test',
'filter',
'node',
];
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',
]);
}
}