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 a633558..47a8f5f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php
@@ -222,7 +222,7 @@ function testThemeGetSetting() {
    * Ensures the theme registry is rebuilt when modules are disabled/enabled.
    */
   function testRegistryRebuild() {
-    $this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), 'a', 'The theme registry contains theme_test_foo.');
+    $this->assertIdentical(theme('theme_test_foo', array('foo' => 'a')), "a\n", 'The theme registry contains theme_test_foo.');
 
     module_disable(array('theme_test'), FALSE);
     // After enabling/disabling a module during a test, we need to rebuild the
@@ -238,7 +238,7 @@ function testRegistryRebuild() {
     // throws an exception.
     $this->rebuildContainer();
     $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->assertIdentical(theme('theme_test_foo', array('foo' => 'c')), "c\n", 'The theme registry contains theme_test_foo again after re-enabling the module.');
   }
 
   /**
diff --git a/core/modules/system/tests/modules/theme_test/templates/theme-test-foo.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme-test-foo.html.twig
new file mode 100644
index 0000000..4f13c91
--- /dev/null
+++ b/core/modules/system/tests/modules/theme_test/templates/theme-test-foo.html.twig
@@ -0,0 +1,12 @@
+{#
+/**
+ * @file
+ * Default theme implementation for the 'theme_test_foo' theme hook.
+ *
+ * Available variables:
+ * - foo: Dummy text to display.
+ *
+ * @ingroup themeable
+ */
+#}
+{{ foo }}
diff --git a/core/modules/system/tests/modules/theme_test/templates/theme-test.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme-test.html.twig
new file mode 100644
index 0000000..996fcf3
--- /dev/null
+++ b/core/modules/system/tests/modules/theme_test/templates/theme-test.html.twig
@@ -0,0 +1,14 @@
+{#
+/**
+ * @file
+ * Default theme implementation for the 'theme_test' theme hook.
+ *
+ * Available variables:
+ * - foo: Dummy text to display.
+ *
+ * @see template_preprocess_theme_test()
+ *
+ * @ingroup themeable
+ */
+#}
+Theme hook implementor=theme_theme_test(). Foo={{ foo }}
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.inc b/core/modules/system/tests/modules/theme_test/theme_test.inc
index 6cde683..99043fe 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.inc
+++ b/core/modules/system/tests/modules/theme_test/theme_test.inc
@@ -1,14 +1,13 @@
 <?php
 
 /**
- * Returns HTML for the 'theme_test' theme hook used by tests.
- */
-function theme_theme_test($variables) {
-  return 'Theme hook implementor=theme_theme_test(). Foo=' . $variables['foo'];
-}
-
-/**
- * Preprocesses variables for theme_theme_test().
+ * Prepares variables for theme test templates.
+ *
+ * Default template: theme-test.html.twig.
+ *
+ * @param array $variables
+ *   An associative array containing:
+ *   - foo: Dummy text to display.
  */
 function template_preprocess_theme_test(&$variables) {
   $variables['foo'] = 'template_preprocess_theme_test';
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module
index 40a78f3..6718cf6 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.module
+++ b/core/modules/system/tests/modules/theme_test/theme_test.module
@@ -7,6 +7,7 @@ function theme_test_theme($existing, $type, $theme, $path) {
   $items['theme_test'] = array(
     'file' => 'theme_test.inc',
     'variables' => array('foo' => ''),
+    'template' => 'theme-test',
   );
   $items['theme_test_template_test'] = array(
     'template' => 'theme_test.template_test',
@@ -16,6 +17,7 @@ function theme_test_theme($existing, $type, $theme, $path) {
   );
   $items['theme_test_foo'] = array(
     'variables' => array('foo' => NULL),
+    'template' => 'theme-test-foo',
   );
   $items['theme_test_render_element'] = array(
     'render element' => 'elements',
