function description($record) { global $CONF; //### need to strip tags -- should be under test if (isset($record['summary'])) { $result = $record['summary']; } else { if (isset($record['description'])) { $result = $record['description']; } } if (@$result != '') { return string_truncate($result, $CONF['summary_length'] + 10); } }
function test_string_truncate() { // 134 characters string $string = 'abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz'; $newString = string_truncate($string, 110); $this->assertTrue(strlen($newString) <= 110); }