class TokenReplaceWebTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php \Drupal\Tests\system\Functional\System\TokenReplaceWebTest
- 10 core/modules/system/tests/src/Functional/System/TokenReplaceWebTest.php \Drupal\Tests\system\Functional\System\TokenReplaceWebTest
- 8.9.x 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\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\System\TokenReplaceWebTest uses \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of TokenReplaceWebTest
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ TokenReplaceWebTest.php, line 14
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',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.