Commit 85963a78 authored by alexpott's avatar alexpott
Browse files

Issue #2061835 by thedavidmeister, Cottser: Fixed theme() doesn't enforce that...

Issue #2061835 by thedavidmeister, Cottser: Fixed theme() doesn't enforce that what it returns is a string or FALSE.
parent 06ca120b
......@@ -1123,7 +1123,7 @@ function theme($hook, $variables = array()) {
// restore path_to_theme()
$theme_path = $temp;
return $output;
return (string) $output;
}
/**
......
......@@ -57,6 +57,24 @@ function testAttributeMerging() {
$this->assertIdentical($output, '<div id="bazinga" data-foo="bar" data-variables-are-preprocessed></div>' . "\n");
}
/**
* Test that theme() returns expected data types.
*/
function testThemeDataTypes() {
// theme_test_false is an implemented theme hook so theme() should return a
// string, even though the theme function itself can return anything.
$foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo');
foreach ($foos as $type => $example) {
$output = theme('theme_test_foo', array('foo' => $example));
$this->assertTrue(is_string($output), format_string('theme() returns a string for data type !type.', array('!type' => $type)));
}
// suggestionnotimplemented is not an implemented theme hook so theme()
// should return FALSE instead of a string.
$output = theme(array('suggestionnotimplemented'));
$this->assertIdentical($output, FALSE, 'theme() returns FALSE when a hook suggestion is not implemented.');
}
/**
* Test function theme_get_suggestions() for SA-CORE-2009-003.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment