@@ -2681,3 +2681,34 @@ class SystemIndexPhpTest extends DrupalWebTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token replacement in strings.
|
||||
*/
|
||||
class TokenScanTest 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',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans 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']), 'A simple valid token has been matched.');
|
||||
$this->assertTrue(isset($token_wannabes['valid']['token with: spaces']), 'A valid token with space characters in the token name has been matched.');
|
||||
$this->assertFalse(isset($token_wannabes['not valid']), 'An invalid token with spaces in the token type has not been matched.');
|
||||
$this->assertTrue(isset($token_wannabes['node']), 'An existing valid token has been matched.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user