diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 3917ffa..80aff57 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -2888,7 +2888,8 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') {
* TRUE on pass, FALSE on fail.
*/
protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') {
- $output = theme($callback, $variables);
+ $theme_output = array('#theme' => $callback, $variables);
+ $output = drupal_render($theme_output);
$this->verbose('Variables:' . '
' . check_plain(var_export($variables, TRUE)) . '
'
. '
' . 'Result:' . '' . check_plain(var_export($output, TRUE)) . '
'
. '
' . 'Expected:' . '' . check_plain(var_export($expected, TRUE)) . '
'
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
index 1a9d3d1..7ba14ae 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php
@@ -27,7 +27,8 @@ public static function getInfo() {
function testThemeTableStickyHeaders() {
$header = array('one', 'two', 'three');
$rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
- $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'sticky' => TRUE));
+ $table = array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#sticky' => TRUE);
+ $this->content = drupal_render($table);
$js = _drupal_add_js();
$this->assertTrue(isset($js['core/misc/tableheader.js']), 'tableheader.js was included when $sticky = TRUE.');
$this->assertRaw('sticky-enabled', 'Table has a class of sticky-enabled when $sticky = TRUE.');
@@ -43,7 +44,8 @@ function testThemeTableNoStickyHeaders() {
$attributes = array();
$caption = NULL;
$colgroups = array();
- $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
+ $table =array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => $attributes, '#caption' => $caption, '#colgroups' => $colgroups, '#sticky' => FALSE);
+ $this->content = drupal_render($table);
$js = _drupal_add_js();
$this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js was not included because $sticky = FALSE.');
$this->assertNoRaw('sticky-enabled', 'Table does not have a class of sticky-enabled because $sticky = FALSE.');
@@ -62,7 +64,8 @@ function testThemeTableWithEmptyMessage() {
'colspan' => 2,
),
);
- $this->content = theme('table', array('header' => $header, 'rows' => array(), 'empty' => t('No strings available.')));
+ $table = array('#theme' => 'table', '#header' => $header, '#rows' => array(), '#empty' => t('No strings available.'));
+ $this->content = drupal_render($table);
$this->assertRaw('No strings available. | ', 'Correct colspan was set on empty message.');
$this->assertRaw('Header 1 | ', 'Table header was printed.');
}
@@ -77,7 +80,8 @@ function testThemeTableWithNoStriping() {
'no_striping' => TRUE,
),
);
- $this->content = theme('table', array('rows' => $rows));
+ $table = array('#theme' => 'table', '#rows' => $rows);
+ $this->content = drupal_render($table);
$this->assertNoRaw('class="odd"', 'Odd/even classes were not added because $no_striping = TRUE.');
$this->assertNoRaw('no_striping', 'No invalid no_striping HTML attribute was printed.');
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
index 492dfd6..374d5ac 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
@@ -41,7 +41,7 @@ function setUp() {
* Render arrays that use a render element and templates (and hence call
* template_preprocess()) must ensure the attributes at different occasions
* are all merged correctly:
- * - $variables['attributes'] as passed in to theme()
+ * - $variables['attributes'] as passed in to drupal_render()
* - the render element's #attributes
* - any attributes set in the template's preprocessing function
*/
@@ -58,21 +58,23 @@ function testAttributeMerging() {
}
/**
- * Test that theme() returns expected data types.
+ * Test that drupal_render() returns expected data types.
*/
function testThemeDataTypes() {
- // theme_test_false is an implemented theme hook so theme() should return a
+ // theme_test_false is an implemented theme hook so drupal_render() 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));
+ $theme_test_foo = array('#theme' => 'theme_test_foo', '#foo' => $example);
+ $output = drupal_render($theme_test_foo);
$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()
+ // suggestionnotimplemented is not an implemented theme hook so drupal_render()
// 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.');
+ $suggestionnotimplemented = array('#theme' => 'suggestionnotimplemented');
+ $output = drupal_render($suggestionnotimplemented);
+ $this->assertIdentical($output, FALSE, 'drupal_render() returns FALSE when a hook suggestion is not implemented.');
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
index 3a26efe..43934ea 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php
@@ -34,7 +34,7 @@ public static function getInfo() {
*/
function testTwigDebugMarkup() {
$extension = twig_extension();
- theme_enable(array('test_theme'));
+ \Drupal::service('theme_handler')->enable(array('test_theme'));
\Drupal::config('system.theme')->set('default', 'test_theme')->save();
// Enable debug, rebuild the service container, and clear all caches.
$this->settingsSet('twig_debug', TRUE);
@@ -48,9 +48,10 @@ function testTwigDebugMarkup() {
// Create a node and test different features of the debug markup.
$node = $this->drupalCreateNode();
- $output = theme('node', node_view($node));
+ $node_output = array('#theme' => 'node', 'node' => node_view($node));
+ $output = drupal_render($node_output);
$this->assertTrue(strpos($output, '') !== FALSE, 'Twig debug markup found in theme output when debug is enabled.');
- $this->assertTrue(strpos($output, "CALL: theme('node')") !== FALSE, 'Theme call information found.');
+ $this->assertTrue(strpos($output, "CALL: drupal_render($node_output)") !== FALSE, 'Theme call information found.');
$this->assertTrue(strpos($output, 'x node--1' . $extension) !== FALSE, 'Node ID specific template shown as current template.');
$this->assertTrue(strpos($output, '* node' . $extension) !== FALSE, 'Base template file found.');
$template_filename = $templates['node__1']['path'] . '/' . $templates['node__1']['template'] . $extension;
@@ -59,7 +60,8 @@ function testTwigDebugMarkup() {
// Create another node and make sure the template suggestions shown in the
// debug markup are correct.
$node2 = $this->drupalCreateNode();
- $output = theme('node', node_view($node2));
+ $node2_output = array('#theme' => 'node', 'node' => node_view($node2));
+ $output = drupal_render($node2_output);
$this->assertTrue(strpos($output, '* node--2' . $extension) !== FALSE, 'Node ID specific template suggestion found.');
$this->assertTrue(strpos($output, 'x node' . $extension) !== FALSE, 'Base template file shown as current template.');
@@ -68,7 +70,8 @@ function testTwigDebugMarkup() {
$this->rebuildContainer();
$this->resetAll();
- $output = theme('node', node_view($node));
+ $node_output2 = array('#theme' => 'node', 'node' => node_view($node));
+ $output = drupal_render($node_output2);
$this->assertFalse(strpos($output, '') !== FALSE, 'Twig debug markup not found in theme output when debug is disabled.');
}
diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
index 2e5417d..1173789 100644
--- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
+++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/EventSubscriber/ThemeTestSubscriber.php
@@ -42,7 +42,8 @@ public function onRequest(GetResponseEvent $event) {
// theme_test_request_listener_page_callback() to test that even when the
// theme system is initialized this early, it is still capable of
// returning output and theming the page as a whole.
- $GLOBALS['theme_test_output'] = theme('more_link', array('url' => 'user', 'title' => 'Themed output generated in a KernelEvents::REQUEST listener'));
+ $themed_text = array('#theme' => 'more_link', 'url' => 'user', 'title' => 'Themed output generated in a KernelEvents::REQUEST listener');
+ $GLOBALS['theme_test_output'] = drupal_render($themed_text);
}
}
diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php
index 29bfa4e..172fd68 100644
--- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php
+++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php
@@ -55,7 +55,8 @@ public function testInfoStylesheets() {
* A render array containing a theme override.
*/
public function testTemplate() {
- return theme('theme_test_template_test');
+ $theme_test_template_test = array('#theme' => 'theme_test_template_test');
+ return drupal_render($theme_test_template_test);
}
/**
@@ -65,7 +66,8 @@ public function testTemplate() {
* An HTML string containing the themed output.
*/
public function testSuggestion() {
- return theme(array('theme_test__suggestion', 'theme_test'), array());
+ $theme_test__suggestion = array('#theme' => 'theme_test__suggestion', 'theme_test' => array());
+ return drupal_render($theme_test__suggestion);
}
/**
diff --git a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
index b46f948..c2a9b2d 100644
--- a/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
+++ b/core/modules/system/tests/modules/twig_theme_test/lib/Drupal/twig_theme_test/TwigThemeTestController.php
@@ -16,7 +16,8 @@ class TwigThemeTestController {
* Menu callback for testing PHP variables in a Twig template.
*/
public function phpVariablesRender() {
- return theme('twig_theme_test_php_variables');
+ $twig_theme_test_php_variables = array('#theme' => 'twig_theme_test_php_variables');
+ return drupal_render($twig_theme_test_php_variables);
}
/**
---|