diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index cf259df2ead4df6ad8c2de1f4ef3c65bee56daf0..093f3b83203ef853670785f9b8dd43073d7b2943 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -52,32 +52,6 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheabl
   $cacheability->addCacheTags(['kittens:dwarf-cat']);
 }
 
-/**
- * Page callback: Tests the theme negotiation functionality.
- *
- * @param bool $inherited
- *   (optional) TRUE when the requested page is intended to inherit
- *   the theme of its parent.
- *
- * @return string
- *   A string describing the requested custom theme and actual theme being used
- *   for the current page request.
- *
- * @see menu_test_menu().
- *
- * @deprecated Use \Drupal\menu_test\Controller\MenuTestController::themePage()
- */
-function menu_test_theme_page_callback($inherited = FALSE) {
-  $theme_key = \Drupal::theme()->getActiveTheme()->getName();
-  // Now we check what the theme negotiator service returns.
-  $active_theme = \Drupal::service('theme.negotiator')->determineActiveTheme(\Drupal::routeMatch());
-  $output = "Active theme: $active_theme. Actual theme: $theme_key.";
-  if ($inherited) {
-    $output .= ' Theme negotiation inheritance is being tested.';
-  }
-  return ['#markup' => $output];
-}
-
 /**
  * Sets a static variable for the testMenuName() test.
  *
diff --git a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
index eb7bec5852d054cb0112841f8b3fcada1ba85b11..c5088e80c3f8f2412cc5a07bf20cd82e4697eded 100644
--- a/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
+++ b/core/modules/system/tests/modules/menu_test/src/Controller/MenuTestController.php
@@ -7,10 +7,64 @@
 
 namespace Drupal\menu_test\Controller;
 
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Theme\ThemeManagerInterface;
+use Drupal\Core\Theme\ThemeNegotiatorInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
 /**
  * Controller routines for menu_test routes.
  */
-class MenuTestController {
+class MenuTestController extends ControllerBase {
+
+  /**
+   * The theme manager.
+   *
+   * @var \Drupal\Core\Theme\ThemeManagerInterface
+   */
+  protected $themeManager;
+
+  /**
+   * The theme negotiator.
+   *
+   * @var \Drupal\Core\Theme\ThemeNegotiatorInterface
+   */
+  protected $themeNegotiator;
+
+  /**
+   * The active route match.
+   *
+   * @var \Drupal\Core\Routing\RouteMatchInterface
+   */
+  protected $routeMatch;
+
+  /**
+   * Constructs the MenuTestController object.
+   *
+   * @param \Drupal\menu_test\Controller\ThemeManagerInterface $theme_manager
+   *   The theme manager.
+   * @param \Drupal\menu_test\Controller\ThemeNegotiatorInterface $theme_negotiator
+   *   The theme negotiator.
+   * @param \Drupal\menu_test\Controller\RouteMatchInterface $route_match
+   *   The current route match.
+   */
+  public function __construct(ThemeManagerInterface $theme_manager, ThemeNegotiatorInterface $theme_negotiator, RouteMatchInterface $route_match) {
+    $this->themeManager = $theme_manager;
+    $this->themeNegotiator = $theme_negotiator;
+    $this->routeMatch = $route_match;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('theme.manager'),
+      $container->get('theme.negotiator'),
+      $container->get('current_route_match')
+    );
+  }
 
   /**
    * Some known placeholder content which can be used for testing.
@@ -40,10 +94,27 @@ public function titleCallback(array $_title_arguments = array(), $_title = '') {
   }
 
   /**
-   * @todo Remove menu_test_theme_page_callback().
+   * Page callback: Tests the theme negotiation functionality.
+   *
+   * @param bool $inherited
+   *   TRUE when the requested page is intended to inherit
+   *   the theme of its parent.
+   *
+   * @return string
+   *   A string describing the requested custom theme and actual
+   *   theme being used
+   *   for the current page request.
    */
   public function themePage($inherited) {
-    return menu_test_theme_page_callback($inherited);
+    $theme_key = $this->themeManager->getActiveTheme()->getName();
+    // Now we check what the theme negotiator service returns.
+    $active_theme = $this->themeNegotiator
+      ->determineActiveTheme($this->routeMatch);
+    $output = "Active theme: $active_theme. Actual theme: $theme_key.";
+    if ($inherited) {
+      $output .= ' Theme negotiation inheritance is being tested.';
+    }
+    return ['#markup' => $output];
   }
 
   /**