diff options
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/common.test | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 177e45733..5f696733e 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -345,14 +345,14 @@ class CommonURLUnitTest extends DrupalWebTestCase { } /** - * Tests for the check_plain() and filter_xss() functions. + * Tests for the check_plain(), filter_xss() and format_string() functions. */ class CommonXssUnitTest extends DrupalUnitTestCase { public static function getInfo() { return array( 'name' => 'String filtering tests', - 'description' => 'Confirm that check_plain(), filter_xss(), and check_url() work correctly, including invalid multi-byte sequences.', + 'description' => 'Confirm that check_plain(), filter_xss(), format_string() and check_url() work correctly, including invalid multi-byte sequences.', 'group' => 'System', ); } @@ -386,6 +386,22 @@ class CommonXssUnitTest extends DrupalUnitTestCase { } /** + * Test t() and format_string() replacement functionality. + */ + function testFormatStringAndT() { + foreach (array('format_string', 't') as $function) { + $text = $function('Simple text'); + $this->assertEqual($text, 'Simple text', $function . ' leaves simple text alone.'); + $text = $function('Escaped text: @value', array('@value' => '<script>')); + $this->assertEqual($text, 'Escaped text: <script>', $function . ' replaces and escapes string.'); + $text = $function('Placeholder text: %value', array('%value' => '<script>')); + $this->assertEqual($text, 'Placeholder text: <em class="placeholder"><script></em>', $function . ' replaces, escapes and themes string.'); + $text = $function('Verbatim text: !value', array('!value' => '<script>')); + $this->assertEqual($text, 'Verbatim text: <script>', $function . ' replaces verbatim string as-is.'); + } + } + + /** * Check that harmful protocols are stripped. */ function testBadProtocolStripping() { |