Issue #2009670 followup by Eric_A: Fixed Replace theme() with drupal_render() in simpletest module.
parent
7bdc1e61fa
commit
cc1f3fdeda
|
@ -2744,11 +2744,7 @@ abstract class WebTestBase extends TestBase {
|
||||||
* TRUE on pass, FALSE on fail.
|
* TRUE on pass, FALSE on fail.
|
||||||
*/
|
*/
|
||||||
protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') {
|
protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') {
|
||||||
$build = array('#theme' => $callback);
|
$output = theme($callback, $variables);
|
||||||
foreach($variables as $key => $variable) {
|
|
||||||
$build["#$key"] = $variable;
|
|
||||||
}
|
|
||||||
$output = drupal_render($build);
|
|
||||||
$this->verbose('Variables:' . '<pre>' . check_plain(var_export($variables, TRUE)) . '</pre>'
|
$this->verbose('Variables:' . '<pre>' . check_plain(var_export($variables, TRUE)) . '</pre>'
|
||||||
. '<hr />' . 'Result:' . '<pre>' . check_plain(var_export($output, TRUE)) . '</pre>'
|
. '<hr />' . 'Result:' . '<pre>' . check_plain(var_export($output, TRUE)) . '</pre>'
|
||||||
. '<hr />' . 'Expected:' . '<pre>' . check_plain(var_export($expected, TRUE)) . '</pre>'
|
. '<hr />' . 'Expected:' . '<pre>' . check_plain(var_export($expected, TRUE)) . '</pre>'
|
||||||
|
|
|
@ -46,15 +46,15 @@ class ThemeTest extends WebTestBase {
|
||||||
* - any attributes set in the template's preprocessing function
|
* - any attributes set in the template's preprocessing function
|
||||||
*/
|
*/
|
||||||
function testAttributeMerging() {
|
function testAttributeMerging() {
|
||||||
$output = theme('theme_test_render_element', array(
|
$theme_test_render_element = array(
|
||||||
'elements' => array(
|
'elements' => array(
|
||||||
'#attributes' => array('data-foo' => 'bar'),
|
'#attributes' => array('data-foo' => 'bar'),
|
||||||
),
|
),
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'id' => 'bazinga',
|
'id' => 'bazinga',
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
$this->assertIdentical($output, '<div id="bazinga" data-foo="bar" data-variables-are-preprocessed></div>' . "\n");
|
$this->assertThemeOutput('theme_test_render_element', $theme_test_render_element, '<div id="bazinga" data-foo="bar" data-variables-are-preprocessed></div>' . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,7 +222,7 @@ class ThemeTest extends WebTestBase {
|
||||||
* Ensures the theme registry is rebuilt when modules are disabled/enabled.
|
* Ensures the theme registry is rebuilt when modules are disabled/enabled.
|
||||||
*/
|
*/
|
||||||
function testRegistryRebuild() {
|
function testRegistryRebuild() {
|
||||||
$this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), 'a', 'The theme registry contains theme_test_foo.');
|
$this->assertThemeOutput('theme_test_foo', array('foo' => 'a'), 'a', 'The theme registry contains theme_test_foo.');
|
||||||
|
|
||||||
module_disable(array('theme_test'), FALSE);
|
module_disable(array('theme_test'), FALSE);
|
||||||
// After enabling/disabling a module during a test, we need to rebuild the
|
// After enabling/disabling a module during a test, we need to rebuild the
|
||||||
|
@ -230,7 +230,7 @@ class ThemeTest extends WebTestBase {
|
||||||
// throws an exception.
|
// throws an exception.
|
||||||
$this->rebuildContainer();
|
$this->rebuildContainer();
|
||||||
$this->container->get('module_handler')->loadAll();
|
$this->container->get('module_handler')->loadAll();
|
||||||
$this->assertIdentical(theme('theme_test_foo', array('foo' => 'b')), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.');
|
$this->assertThemeOutput('theme_test_foo', array('foo' => 'b'), FALSE, 'The theme registry does not contain theme_test_foo, because the module is disabled.');
|
||||||
|
|
||||||
module_enable(array('theme_test'), FALSE);
|
module_enable(array('theme_test'), FALSE);
|
||||||
// After enabling/disabling a module during a test, we need to rebuild the
|
// After enabling/disabling a module during a test, we need to rebuild the
|
||||||
|
@ -238,7 +238,7 @@ class ThemeTest extends WebTestBase {
|
||||||
// throws an exception.
|
// throws an exception.
|
||||||
$this->rebuildContainer();
|
$this->rebuildContainer();
|
||||||
$this->container->get('module_handler')->loadAll();
|
$this->container->get('module_handler')->loadAll();
|
||||||
$this->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.');
|
$this->assertThemeOutput('theme_test_foo', array('foo' => 'c'), 'c', 'The theme registry contains theme_test_foo again after re-enabling the module.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +251,7 @@ class ThemeTest extends WebTestBase {
|
||||||
'#markup' => 'Foo',
|
'#markup' => 'Foo',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.');
|
$this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', 'drupal_render() avoids #theme recursion loop when rendering a render element.');
|
||||||
|
|
||||||
$element = array(
|
$element = array(
|
||||||
'#theme_wrappers' => array('theme_test_render_element_children'),
|
'#theme_wrappers' => array('theme_test_render_element_children'),
|
||||||
|
@ -259,7 +259,7 @@ class ThemeTest extends WebTestBase {
|
||||||
'#markup' => 'Foo',
|
'#markup' => 'Foo',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$this->assertIdentical(theme('theme_test_render_element_children', $element), 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.');
|
$this->assertThemeOutput('theme_test_render_element_children', $element, 'Foo', 'drupal_render() avoids #theme_wrappers recursion loop when rendering a render element.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue