diff --git modules/system/system.test modules/system/system.test index 3045569..040fe87 100644 --- modules/system/system.test +++ modules/system/system.test @@ -1577,9 +1577,28 @@ class TokenReplaceTestCase extends DrupalWebTestCase { $result = token_replace($source, array('node' => $node), array('language' => $language, 'clear' => TRUE)); $result = $this->assertFalse(strcmp($target, $result), 'Valid tokens replaced while invalid tokens cleared out.'); - // Test without using the clear parameter (non-existant token untouched). + // Test without using the clear parameter (non-existent token untouched). $target .= '[user:name]'; $target .= '[bogus:token]'; + + // Test whether token-replacement works in various contexts. + $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' => ']'), + ); + foreach ($tests as $test) { + $source .= $test['prefix'] . '[site:name]' . $test['suffix']; + $target .= $test['prefix'] . 'Drupal' . $test['suffix']; + } + $result = token_replace($source, array('node' => $node), array('language' => $language)); $this->assertFalse(strcmp($target, $result), 'Valid tokens replaced while invalid tokens ignored.');