diff -u b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php --- b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php @@ -19,7 +19,7 @@ * * @var array */ - public static $modules = array('theme_test'); + public static $modules = array('theme_test', 'twig_theme_test'); public static function getInfo() { return array( @@ -77,7 +77,7 @@ config('system.theme') ->set('default', 'test_theme_twig') ->save(); - $this->drupalGet('theme-test/template-test'); + $this->drupalGet('twig-theme-test/php-variables'); foreach (_test_theme_twig_php_values() as $type => $value) { $this->assertRaw('
  • ' . $type . ': ' . $value['expected'] . '
  • '); } reverted: --- b/core/modules/system/tests/modules/theme_test/theme_test.module +++ a/core/modules/system/tests/modules/theme_test/theme_test.module @@ -172,41 +172,3 @@ return $variables['foo']; } -/* - * Helper function to test PHP variables in the Twig engine. - */ -function _test_theme_twig_php_values() { - // Prefix each variable with "twig_" so that twig doesn't get confused - // between a variable and a primitive. Arrays are not tested since they should - // be a Drupal render array. - return array( - 'twig_null' => array( - 'value' => NULL, - 'expected' => '', - ), - 'twig_bool_false' => array( - 'value' => FALSE, - 'expected' => '', - ), - 'twig_bool_true' => array( - 'value' => TRUE, - 'expected' => '1', - ), - 'twig_int' => array( - 'value' => 1, - 'expected' => '1', - ), - 'twig_int_0' => array( - 'value' => 0, - 'expected' => '0', - ), - 'twig_float' => array( - 'value' => 122.34343, - 'expected' => '122.34343', - ), - 'twig_string' => array( - 'value' => 'Hello world!', - 'expected' => 'Hello world!', - ), - ); -} diff -u b/core/modules/system/tests/themes/test_theme_twig/test_theme_twig.theme b/core/modules/system/tests/themes/test_theme_twig/test_theme_twig.theme --- b/core/modules/system/tests/themes/test_theme_twig/test_theme_twig.theme +++ b/core/modules/system/tests/themes/test_theme_twig/test_theme_twig.theme @@ -9,5 +9,5 @@ * Implements THEME_preprocess_theme_test_template_test(). */ -function test_theme_twig_preprocess_theme_test_template_test(&$variables) { +function test_theme_twig_preprocess_twig_theme_test_php_variables(&$variables) { $variables['php_values'] = _test_theme_twig_php_values(); } reverted: --- b/core/modules/system/tests/themes/test_theme_twig/theme_test.template_test.html.twig +++ a/core/modules/system/tests/themes/test_theme_twig/theme_test.template_test.html.twig @@ -1,8 +1,2 @@ {# Output for Theme API test #} Success: Template overridden. - - only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.php_variables.html.twig @@ -0,0 +1,6 @@ +{# Output for Twig Theme PHP variables test #} + only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.info.yml @@ -0,0 +1,6 @@ +name: 'Twig theme test' +description: 'Support module for Twig theme system testing.' +package: Testing +version: VERSION +core: 8.x +hidden: true only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -0,0 +1,69 @@ + 'twig_theme_test.php_variables', + ); + return $items; +} + +/** + * Implements hook_menu(). + */ +function twig_theme_test_menu() { + $items['twig-theme-test/php-variables'] = array( + 'page callback' => 'twig_theme_test_php_variables_callback', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); + return $items; +} + +/** + * Menu callback for testing php variables in a twig template. + */ +function twig_theme_test_php_variables_callback() { + return theme('twig_theme_test_php_variables'); +} + +/* + * Helper function to test PHP variables in the Twig engine. + */ +function _test_theme_twig_php_values() { + // Prefix each variable with "twig_" so that twig doesn't get confused + // between a variable and a primitive. Arrays are not tested since they should + // be a Drupal render array. + return array( + 'twig_null' => array( + 'value' => NULL, + 'expected' => '', + ), + 'twig_bool_false' => array( + 'value' => FALSE, + 'expected' => '', + ), + 'twig_bool_true' => array( + 'value' => TRUE, + 'expected' => '1', + ), + 'twig_int' => array( + 'value' => 1, + 'expected' => '1', + ), + 'twig_int_0' => array( + 'value' => 0, + 'expected' => '0', + ), + 'twig_float' => array( + 'value' => 122.34343, + 'expected' => '122.34343', + ), + 'twig_string' => array( + 'value' => 'Hello world!', + 'expected' => 'Hello world!', + ), + ); +}