diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 73afaa6..cffc740 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2284,6 +2284,32 @@ abstract class WebTestBase extends TestBase { } /** + * Asserts themed output. + * + * @param $callback + * The name of the theme function to invoke; e.g. 'links' for theme_links(). + * @param $variables + * An array of variables to pass to the theme function. + * @param $expected + * The expected themed output string. + * @param $message + * (optional) An assertion message. + */ + protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '') { + $output = theme($callback, $variables); + $this->verbose('Variables:' . '
' .  check_plain(var_export($variables, TRUE)) . '
' + . '
' . 'Result:' . '
' .  check_plain(var_export($output, TRUE)) . '
' + . '
' . 'Expected:' . '
' .  check_plain(var_export($expected, TRUE)) . '
' + . '
' . $output + ); + if (!$message) { + $message = '%callback rendered correctly.'; + } + $message = format_string($message, array('%callback' => 'theme_' . $callback . '()')); + $this->assertIdentical($output, $expected, $message); + } + + /** * Asserts that a field exists in the current page by the given XPath. * * @param $xpath diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php index a8a66f6..4e94e37 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php @@ -144,32 +144,6 @@ class FunctionsTest extends WebTestBase { } /** - * Asserts themed output. - * - * @param $callback - * The name of the theme function to invoke; e.g. 'links' for theme_links(). - * @param $variables - * An array of variables to pass to the theme function. - * @param $expected - * The expected themed output string. - * @param $message - * (optional) An assertion message. - */ - protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '') { - $output = theme($callback, $variables); - $this->verbose('Variables:' . '
' .  check_plain(var_export($variables, TRUE)) . '
' - . '
' . 'Result:' . '
' .  check_plain(var_export($output, TRUE)) . '
' - . '
' . 'Expected:' . '
' .  check_plain(var_export($expected, TRUE)) . '
' - . '
' . $output - ); - if (!$message) { - $message = '%callback rendered correctly.'; - } - $message = t($message, array('%callback' => 'theme_' . $callback . '()')); - $this->assertIdentical($output, $expected, $message); - } - - /** * Test the use of drupal_pre_render_links() on a nested array of links. */ function testDrupalPreRenderLinks() {