In core/modules/system/tests/modules/form_test/form_test.routing.yml, how is it possible that these invalid route definitions (use of controller: with no underscore instead of _controller:) don't cause test failures when form_test is used in general and when the autocomplete test is performed in particular?

form_test.route8:
  path: '/form-test/autocomplete'
  defaults:
    _form: '\Drupal\form_test\FormTestAutocompleteForm'
  requirements:
    _access: 'TRUE'

form_test.autocomplete_1:
  path: '/form-test/autocomplete-1'
  defaults:
    controller: '\Drupal\form_test\AutocompleteController::autocomplete1'
  requirements:
    _permission: 'access autocomplete test'

form_test.autocomplete_2:
  path: '/form-test/autocomplete-2/{param}'
  defaults:
    controller: '\Drupal\form_test\AutocompleteController::autocomplete1'
  requirements:
    _permission: 'access autocomplete test'
Files: 

Comments

TR created an issue. See original summary.

cilefen’s picture

cilefen’s picture

Poking around, it looks as though no tests ever try those routes:

drupal8x (8.1.x *%=)$ ack 'form-test/autocomplete-1' core/
core/modules/system/src/Tests/Form/ElementTest.php
151:    $result = $this->xpath('//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');
163:    $result = $this->xpath('//input[@id="edit-autocomplete-1" and contains(@data-autocomplete-path, "form-test/autocomplete-1")]');

core/modules/system/tests/modules/form_test/form_test.routing.yml
58:  path: '/form-test/autocomplete-1'
drupal8x (8.1.x *%=)$ ack 'form-test/autocomplete-2' core/
core/modules/system/src/Tests/Form/ElementTest.php
153:    $result = $this->xpath('//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');
165:    $result = $this->xpath('//input[@id="edit-autocomplete-2" and contains(@data-autocomplete-path, "form-test/autocomplete-2/value")]');

core/modules/system/tests/modules/form_test/form_test.routing.yml
65:  path: '/form-test/autocomplete-2/{param}'

drupal8x (8.1.x *%=)$ ack form_test.autocomplete_1 core/
core/modules/system/tests/modules/form_test/form_test.routing.yml
57:form_test.autocomplete_1:

core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php
32:      '#autocomplete_route_name' => 'form_test.autocomplete_1',
drupal8x (8.1.x *%=)$ ack form_test.autocomplete_2 core/
core/modules/system/tests/modules/form_test/form_test.routing.yml
64:form_test.autocomplete_2:

core/modules/system/tests/modules/form_test/src/FormTestAutocompleteForm.php
37:      '#autocomplete_route_name' => 'form_test.autocomplete_2',
cilefen’s picture

Priority: Normal » Minor
Status: Active » Needs review
Issue tags: +Quick fix, +Trivial patch of the month
FileSize
951 bytes

Well if we bother patching unused test code (see #3), here it is...

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

surbz’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies clean on 8.2.x-dev.

alexpott’s picture

Priority: Minor » Normal
Status: Reviewed & tested by the community » Needs work
Issue tags: -Quick fix, -Trivial patch of the month +JavaScript

Well the routes are used:

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['autocomplete_1'] = array(
      '#type' => 'textfield',
      '#title' => 'Autocomplete 1',
      '#autocomplete_route_name' => 'form_test.autocomplete_1',
    );
    $form['autocomplete_2'] = array(
      '#type' => 'textfield',
      '#title' => 'Autocomplete 2',
      '#autocomplete_route_name' => 'form_test.autocomplete_2',
      '#autocomplete_route_parameters' => array('param' => 'value'),
    );

    return $form;
  }

So they should be working - in fact maybe the test should be changed to a FunctionalJavascriptTest so we can test the auto complete calling beyond just the existence of the links and autocomplete.js being loaded.

I think we should do that here instead so the trivial fix is actually tested.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.