diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc
index 8f140e3..d604ec1 100644
--- a/core/modules/field/tests/modules/field_test/field_test.entity.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc
@@ -43,6 +43,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable
 
 /**
  * Form combining two separate entities.
+ *
+ * @deprecated Use \Drupal\field_test\Form\EntityNestedForm::buildForm()
+ * instead.
  */
 function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2) {
   // First entity.
@@ -83,6 +86,9 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
 
 /**
  * Validate handler for field_test_entity_nested_form().
+ *
+ * @deprecated Use \Drupal\field_test\Form\EntityNestedForm::validateForm()
+ * instead.
  */
 function field_test_entity_nested_form_validate($form, &$form_state) {
   $entity_1 = entity_create('entity_test', array(
@@ -102,6 +108,9 @@ function field_test_entity_nested_form_validate($form, &$form_state) {
 
 /**
  * Submit handler for field_test_entity_nested_form().
+ *
+ * @deprecated Use \Drupal\field_test\Form\EntityNestedForm::submitForm()
+ * instead.
  */
 function field_test_entity_nested_form_submit($form, &$form_state) {
   $entity_1 = entity_create('entity_test', array(
diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module
index 3ab0c7e..3dad8d0 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -43,9 +43,7 @@ function field_test_menu() {
   $items = array();
   $items['test-entity/nested/%entity_test/%entity_test'] = array(
     'title' => 'Nested entity form',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('field_test_entity_nested_form', 2, 3),
-    'access arguments' => array('administer entity_test content'),
+    'route_name' => 'field_test_entity_nested_form',
     'type' => MENU_NORMAL_ITEM,
   );
 
diff --git a/core/modules/field/tests/modules/field_test/field_test.routing.yml b/core/modules/field/tests/modules/field_test/field_test.routing.yml
new file mode 100644
index 0000000..95a9e5d
--- /dev/null
+++ b/core/modules/field/tests/modules/field_test/field_test.routing.yml
@@ -0,0 +1,6 @@
+field_test_entity_nested_form:
+  pattern: 'test-entity/nested/{entity_1}/{entity_2}'
+  defaults:
+    _form: '\Drupal\field_test\Form\EntityNestedForm'
+  requirements:
+    _permission: 'administer entity_test content'
diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/EntityNestedForm.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/EntityNestedForm.php
new file mode 100644
index 0000000..b07f8e9
--- /dev/null
+++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Form/EntityNestedForm.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\field_test\Form\EntityNestedForm.
+ */
+
+namespace Drupal\field_test\Form;
+
+use Drupal\Core\Form\FormBase;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Displays banned IP addresses.
+ */
+class EntityNestedForm extends FormBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static();
+  }
+
+  /**
+   * Constructs an EntityNestedForm object.
+   */
+  public function __construct() {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getFormID() {
+    return 'field_test_entity_nested_form';
+  }
+
+  /**
+   * {@inheritdoc}
+   *
+   * @param int $entity_1
+   *   The first entity.
+   * @param int $entity_2
+   *   The second entity.
+   */
+  public function buildForm(array $form, array &$form_state, $entity_1 = NULL, $entity_2 = NULL) {
+    $entity_1 = entity_load('entity_test', $entity_1);
+    $entity_2 = entity_load('entity_test', $entity_2);
+    module_load_include('entity.inc', 'field_test');
+    return field_test_entity_nested_form($form, $form_state, $entity_1, $entity_2);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateForm(array &$form, array &$form_state) {
+    module_load_include('entity.inc', 'field_test');
+    field_test_entity_nested_form_validate($form, $form_state);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, array &$form_state) {
+    field_test_entity_nested_form_submit($form, $form_state);
+  }
+
+}
