Search code examples
symfonysymfony4

AutoWire services_test.yaml -> There is no node with id 'service.a'


having trouble to get unit tests working after migrating to AutoWire in SF4.2 normal route works fine.

services.yaml:

services:
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        public: false       # Allows optimizing the container by removing unused services; this also means

# enable AW on controllers
    KRNApiBundle\Controller\:
        resource: '../../Controller'
        tags: ['controller.service_arguments']

# AutoWireAliases
    MyClass: '@service.a'

    service.a:
      class: MyClass

services_test.yaml, has some, but not service.a defined/overloaded

running, any test, it fails at (WebTestCase):

$client = static::createClient();

InvalidArgumentException: There is no node with id "service.a".

when i copy the definition of service.a to services_test.yaml - it works. however i want, and have to avoid, defining all services twice (introduces a huge surface for errors)


Solution

  • Looks like a bug - should be fixed by https://github.com/symfony/symfony/pull/29393