Keep getting 'You have requested a non-existent service “test.client”' in Symfony2 Beta3

后端 未结 4 1949
花落未央
花落未央 2021-02-05 00:53

I\'m trying to setup a unit test but whenever I run \"phpunit -c app\" I get this error:

Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFou

相关标签:
4条回答
  • 2021-02-05 01:22

    Have you enabled the framework.test option in config_test.yml?

    framework:
      test: ~
    
    0 讨论(0)
  • 2021-02-05 01:23

    I had same issue with remote builds of my project. This issue was connected with empty symfony.lock file in the root of my project. This file is for preventing symfony recipes execution twice. But my symfony.lock was corrupted and empty so framework-bundle executed it's recipe and replaced my APP_ENV variable in phpunit.xml.dist from test to dev. The reason why it happened was repositories node in composer.json (https://github.com/symfony/flex/issues/347)

    I'm fixing this situation by adding dependencies in symfony.lock by my hands

    0 讨论(0)
  • 2021-02-05 01:29

    I had this problem with symfony version 3.3.13.

    The config_test.yml file was fine, but I did the same mistake.

    I solved adding the <server name ="APP_ENV" value="test" /> option under php in the phpunit.xml file

    0 讨论(0)
  • 2021-02-05 01:35

    In phpunit.xml you should have env variable like:

    <env name="APP_ENV" value="test"/>
    
    0 讨论(0)
提交回复
热议问题