1 unicode.test | UnicodeUnitTest::runTruncateTests($cases, $wordsafe, $ellipsis) |
Runs test cases for helperTestTruncate().
Runs each test case through truncate_utf8() and compares the output to the expected output.
Parameters
$cases: Cases array. Each case is an array with the input string, length to truncate to, and expected output.
$wordsafe: TRUE to use word-safe truncation, FALSE to not use word-safe truncation.
$ellipsis: TRUE to append ... if the input is truncated, FALSE to not append ....
File
- core/
modules/ simpletest/ tests/ unicode.test, line 307 - Various unicode handling tests.
Class
- UnicodeUnitTest
- Test unicode handling features implemented in unicode.inc.
Code
function runTruncateTests($cases, $wordsafe, $ellipsis) {
foreach ($cases as $case) {
list($input, $max_length, $expected) = $case;
$output = truncate_utf8($input, $max_length, $wordsafe, $ellipsis);
$this->assertEqual($output, $expected, format_string('%input truncate to %length characters with %wordsafe, %ellipsis is %expected (got %output)', array('%input' => $input, '%length' => $max_length, '%output' => $output, '%expected' => $expected, '%wordsafe' => ($wordsafe ? 'word-safe' : 'not word-safe'), '%ellipsis' => ($ellipsis ? 'ellipsis' : 'not ellipsis'))));
}
}