diff --git a/modules/system/system.test b/modules/system/system.test index f84bc78..195e0bc 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1781,6 +1781,36 @@ class QueueTestCase extends DrupalWebTestCase { } /** + * Test token scanning in strings. + */ +class TokenScanTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Token scanning', + 'description' => 'Scan token-like patterns in a dummy text to check token scanning.', + 'group' => 'System', + ); + } + + /** + * Scan dummy text, then tests the output. + */ + function testTokenScan() { + // Define text with valid and not valid, fake and existing token like + // strings. + $text = 'First a [valid:simple], but dummy token, and a dummy [valid:token with: spaces].'; + $text .= 'Then a [not valid:token].'; + $text .= 'Last an existing token: [node:author:name].'; + $token_wannabes = token_scan($text); + + $this->assertTrue(isset($token_wannabes['valid']['simple']), t('Simle valid token is scanned.')); + $this->assertTrue(isset($token_wannabes['valid']['token with: spaces']), t('Valid token with space characters in the token name is scanned.')); + $this->assertFalse(isset($token_wannabes['not valid']), t('Not valid token with spaces in the token type is not scanned.')); + $this->assertTrue(isset($token_wannabes['node']), t('Existing valid token is scanned')); + } +} + +/** * Test token replacement in strings. */ class TokenReplaceTestCase extends DrupalWebTestCase {