diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-03-12 14:33:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-03-12 14:33:02 +0000 |
commit | d8e62ff260991b911a05092d285aa6a31cdb8229 (patch) | |
tree | 08f0ca9aa575a37ce6ed0c3f622988e757a8b3fb /modules/system/system.test | |
parent | 4f0e59e1ccc50ed983c348b3917514d6131cc29e (diff) | |
download | brdo-d8e62ff260991b911a05092d285aa6a31cdb8229.tar.gz brdo-d8e62ff260991b911a05092d285aa6a31cdb8229.tar.bz2 |
- Patch #681782 by Dave Reid: 'clean' option in token_replace() does not do anything.
Diffstat (limited to 'modules/system/system.test')
-rw-r--r-- | modules/system/system.test | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index c5366c541..049502194 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1449,26 +1449,30 @@ class TokenReplaceTestCase extends DrupalWebTestCase { $source .= '[node:author:name]'; // Node author's name $source .= '[node:created:since]'; // Time since the node was created $source .= '[current-user:name]'; // Current user's name - $source .= '[user:name]'; // No user passed in, should be untouched $source .= '[date:short]'; // Short date format of REQUEST_TIME - $source .= '[bogus:token]'; // Nonexistent token, should be untouched + $source .= '[user:name]'; // No user passed in, should be untouched + $source .= '[bogus:token]'; // Non-existent token $target = check_plain($node->title); $target .= check_plain($account->name); $target .= format_interval(REQUEST_TIME - $node->created, 2, $language->language); $target .= check_plain($user->name); - $target .= '[user:name]'; $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language->language); - $target .= '[bogus:token]'; + // Test that the clear parameter cleans out non-existent tokens. + $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). + $target .= '[user:name]'; + $target .= '[bogus:token]'; $result = token_replace($source, array('node' => $node), array('language' => $language)); + $this->assertFalse(strcmp($target, $result), 'Valid tokens replaced while invalid tokens ignored.'); // 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 correctly by a 'known' // token, [node:title]. - $this->assertFalse(strcmp($target, $result), t('Basic placeholder tokens replaced.')); - $raw_tokens = array('title' => '[node:title]'); $generated = token_generate('node', $raw_tokens, array('node' => $node)); $this->assertFalse(strcmp($generated['[node:title]'], check_plain($node->title)), t('Token sanitized.')); |