Mercurial > hg > isophonics-drupal-site
diff core/modules/system/src/Tests/System/TokenReplaceWebTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/system/src/Tests/System/TokenReplaceWebTest.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,42 @@ +<?php + +namespace Drupal\system\Tests\System; + +use Drupal\Core\EventSubscriber\MainContentViewSubscriber; +use Drupal\simpletest\WebTestBase; +use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; + +/** + * Tests the token system integration. + * + * @group system + */ +class TokenReplaceWebTest extends WebTestBase { + + use AssertPageCacheContextsAndTagsTrait; + + /** + * {@inheritdoc} + */ + public static $modules = ['token_test', 'filter', 'node']; + + /** + * 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->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']); + } + +}