diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php index 0bc6be6..e957eb9 100644 --- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php @@ -118,31 +118,12 @@ function testCommentTokenReplacement() { $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } - // Generate and test unsanitized tokens. - $tests['[comment:hostname]'] = $comment->getHostname(); - $tests['[comment:author]'] = $comment->getAuthorName(); - $tests['[comment:mail]'] = $this->adminUser->getEmail(); - $tests['[comment:homepage]'] = $comment->getHomepage(); - $tests['[comment:title]'] = $comment->getSubject(); - $tests['[comment:body]'] = $comment->comment_body->value; - $tests['[comment:langcode]'] = $comment->language()->getId(); - $tests['[comment:parent:title]'] = $parent_comment->getSubject(); - $tests['[comment:entity]'] = $node->getTitle(); - $tests['[comment:author:name]'] = $this->adminUser->getUsername(); - - foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input))); - } - // Test anonymous comment author. $author_name = $this->randomString(); $comment->setOwnerId(0)->setAuthorName($author_name); $input = '[comment:author]'; $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId())); $this->assertEqual($output, Xss::filter($author_name), format_string('Sanitized comment author token %token replaced.', array('%token' => $input))); - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); - $this->assertEqual($output, $author_name, format_string('Unsanitized comment author token %token replaced.', array('%token' => $input))); // Load node so comment_count gets computed. $node = Node::load($node->id()); diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php index 3ec91d9..5720d8f 100644 --- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php @@ -108,18 +108,6 @@ function testNodeTokenReplacement() { $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } - // Generate and test unsanitized tokens. - $tests['[node:title]'] = $node->getTitle(); - $tests['[node:body]'] = $node->body->value; - $tests['[node:summary]'] = $node->body->summary; - $tests['[node:langcode]'] = $node->language()->getId(); - $tests['[node:author:name]'] = $account->getUsername(); - - foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input))); - } - // Repeat for a node without a summary. $node = entity_create('node', array( 'type' => 'article', @@ -140,14 +128,6 @@ function testNodeTokenReplacement() { $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage)); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input))); } - - // Generate and test unsanitized tokens. - $tests['[node:summary]'] = $node->body->value; - - foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('language' => $this->interfaceLanguage, 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input))); - } } } diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index 33f867a..a410660 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -133,15 +133,6 @@ public function testSystemSiteTokenReplacement() { $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } - // Generate and test unsanitized tokens. - $tests['[site:name]'] = $config->get('name'); - $tests['[site:slogan]'] = $config->get('slogan'); - - foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE), $bubbleable_metadata); - $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); - } - // Check that the results of Token::generate are sanitized properly. This // does NOT test the cleanliness of every token -- just that the $sanitize // flag is being passed properly through the call stack and being handled @@ -149,9 +140,6 @@ public function testSystemSiteTokenReplacement() { $raw_tokens = array('slogan' => '[site:slogan]'); $generated = $this->tokenService->generate('site', $raw_tokens, [], [], $bubbleable_metadata); $this->assertEqual($generated['[site:slogan]'], $safe_slogan, 'Token sanitized.'); - - $generated = $this->tokenService->generate('site', $raw_tokens, array(), array('sanitize' => FALSE), $bubbleable_metadata); - $this->assertEqual($generated['[site:slogan]'], $slogan, 'Unsanitized token generated properly.'); } /** diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index 4fcb0f1..3bc7827 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -134,17 +134,6 @@ function testTaxonomyTokenReplacement() { $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } - // Generate and test unsanitized tokens. - $tests['[term:name]'] = $term2->getName(); - $tests['[term:description]'] = $term2->getDescription(); - $tests['[term:parent:name]'] = $term1->getName(); - $tests['[term:vocabulary:name]'] = $this->vocabulary->label(); - - foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); - } - // Generate and test sanitized tokens. $tests = array(); $tests['[vocabulary:vid]'] = $this->vocabulary->id(); @@ -160,15 +149,6 @@ function testTaxonomyTokenReplacement() { $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } - - // Generate and test unsanitized tokens. - $tests['[vocabulary:name]'] = $this->vocabulary->label(); - $tests['[vocabulary:description]'] = $this->vocabulary->getDescription(); - - foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); - $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); - } } }