From d379f3d7bdfe4ef9c0f0fe629394048229d6c2e2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 23 Apr 2011 20:09:54 -0400 Subject: - Patch #733192 by pillarsdotnet, Sutharsan, Letharion, clemens.tolboom: tokens enclosed in [ ] are not recognized. --- modules/system/system.test | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'modules') diff --git a/modules/system/system.test b/modules/system/system.test index fb6a6e867..cba19f3ff 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1595,6 +1595,35 @@ class TokenReplaceTestCase extends DrupalWebTestCase { $this->assertEqual($generated['[node:title]'], $node->title, t('Unsanitized token generated properly.')); } + /** + * Test whether token-replacement works in various contexts. + */ + function testSystemTokenRecognition() { + global $language; + + // Generate prefixes and suffixes for the token context. + $tests = array( + array('prefix' => 'this is the ', 'suffix' => ' site'), + array('prefix' => 'this is the', 'suffix' => 'site'), + array('prefix' => '[', 'suffix' => ']'), + array('prefix' => '', 'suffix' => ']]]'), + array('prefix' => '[[[', 'suffix' => ''), + array('prefix' => ':[:', 'suffix' => '--]'), + array('prefix' => '-[-', 'suffix' => ':]:'), + array('prefix' => '[:', 'suffix' => ']'), + array('prefix' => '[site:', 'suffix' => ':name]'), + array('prefix' => '[site:', 'suffix' => ']'), + ); + + // Check if the token is recognized in each of the contexts. + foreach ($tests as $test) { + $input = $test['prefix'] . '[site:name]' . $test['suffix']; + $expected = $test['prefix'] . 'Drupal' . $test['suffix']; + $output = token_replace($input, array(), array('language' => $language)); + $this->assertTrue($output == $expected, t('Token recognized in string %string', array('%string' => $input))); + } + } + /** * Tests the generation of all system site information tokens. */ -- cgit v1.2.3