Same name and namespace in other branches
- 8.9.x core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php \Drupal\Tests\system\Functional\System\TokenReplaceWebTest
- 9 core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php \Drupal\Tests\system\Functional\System\TokenReplaceWebTest
Tests the token system integration.
@group system
Hierarchy
- class \Drupal\Tests\system\Functional\System\TokenReplaceWebTest extends \Drupal\Tests\BrowserTestBase uses AssertPageCacheContextsAndTagsTrait
Expanded class hierarchy of TokenReplaceWebTest
File
- core/
modules/ system/ tests/ src/ Functional/ System/ TokenReplaceWebTest.php, line 16
Namespace
Drupal\Tests\system\Functional\SystemView source
class TokenReplaceWebTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'token_test',
'filter',
'node',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* 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
->assertSession()
->pageTextContains("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-bubbleable-metadata/' . $node
->id());
$this
->assertSession()
->pageTextContains("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',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Asserts whether an expected cache context was present in the last response. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Ensures that some cache contexts are present in the current response. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Asserts the max age header. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Ensures that some cache tags are present in the current response. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Asserts that a cache context was not present in the last response. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Asserts page cache miss, then hit for the given URL; checks cache headers. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Enables page caching. | |
AssertPageCacheContextsAndTagsTrait:: |
protected | function | Gets a specific header value as array. | |
TokenReplaceWebTest:: |
protected | property | ||
TokenReplaceWebTest:: |
protected static | property | ||
TokenReplaceWebTest:: |
public | function | Tests a token replacement on an actual website. |