Problem/Motivation

Drupal\KernelTests\Core\DependencyInjection\AutowireTest fails if new services added to core aren't setup to use autowiring but from the failure message it is not obvious what needs to change.

Steps to reproduce

See https://www.drupal.org/pift-ci-job/2783034 for example

Proposed resolution

Improve the failure message

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3394450

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Status: Active » Needs review

Sample output

phpunit -c app/core app/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php --filter=CoreSer
⏳️ Bootstrapped tests in 0 seconds.
🐘 PHP Version 8.1.23.
💧 Drupal Version 11.0-dev.
🗄️  Database engine mysql.
PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

Testing Drupal\KernelTests\Core\DependencyInjection\AutowireTest
F                                                                   1 / 1 (100%)

Time: 00:00.943, Memory: 12.00 MB

There was 1 failure:

1) Drupal\KernelTests\Core\DependencyInjection\AutowireTest::testCoreServiceAliases
The following core services do not have map the class name to an alias. Add the following to core.services.yml in the appropriate place: 

Drupal\Core\Foo: '@foo.class'

Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
     'Drupal\Core\TempStore\SharedTempStoreFactory' => 'tempstore.shared'
     'Drupal\Core\Pager\PagerManagerInterface' => 'pager.manager'
     'Drupal\Core\Pager\PagerParametersInterface' => 'pager.parameters'
-    'Drupal\Core\Foo' => 'foo.class'
 )

/data/app/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php:115


smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Output message seems clear and obviously way more helpful!

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 2402f97b33 to 11.x and 09d7cff72b to 10.2.x and c354872a25 to 10.1.x. Thanks!

  • longwave committed c354872a on 10.1.x
    Issue #3394450 by larowlan: Improve the failure message from Drupal\...

  • longwave committed 09d7cff7 on 10.2.x
    Issue #3394450 by larowlan: Improve the failure message from Drupal\...

  • longwave committed 2402f97b on 11.x
    Issue #3394450 by larowlan: Improve the failure message from Drupal\...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.