简体   繁体   English

Symfony2:使test.client在开发环境中可用

[英]Symfony2: Make test.client available in dev environment

When using the test environment symfony2 creates a Symfony\\Bundle\\FrameworkBundle\\Client and registers it as test.client service but it is not registered in dev or prod envs. 使用测试环境时,symfony2创建一个Symfony\\Bundle\\FrameworkBundle\\Client并将其注册为test.client服务,但未在dev或prod envs中注册。 We're writing two kinds of tests: unit tests that use a predefined state of our database and fixtures in the test environment and functional tests that use the local productive database. 我们正在编写两种测试:使用测试状态的数据库和装置的预定义状态的单元测试,以及使用本地生产数据库的功能测试。 When I want to use the Client to test a route's HTTP behaviour I can only do that in the test environment where I don't have access to the dev database. 当我想使用Client测试路由的HTTP行为时,只能在无法访问dev数据库的测试环境中进行操作。

How can we reuse the test.client "service" in our dev environment? 我们如何在开发环境中重用test.client“服务”? BTW: It's working when we're copying the Symfony\\Bundle\\FrameworkBundle\\Resources\\test.xml file into our application and include it in the config_dev. 顺便说一句:当我们将Symfony\\Bundle\\FrameworkBundle\\Resources\\test.xml文件复制到我们的应用程序并将其包含在config_dev中时,它就起作用了。 Could we also include that file directly from the vendors directory? 我们还可以直接从vendors目录中包含该文件吗?

You can add it it any environment as import, 您可以将其添加到任何环境中作为导入,

eg 例如

imports:
    - { resource: "@FrameworkBundle/Resources/config/test.xml" }

UPDATE: Changed it to the correct path. 更新:将其更改为正确的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM