【发布时间】:2015-06-08 14:42:14
【问题描述】:
感谢 Matteo (phpunit in symfony2 - No tests executed),我现在可以测试我的功能测试。
现在运行phpunit -c app时出现以下错误:
You must change the main Request object in the front controller (app.php)
in order to use the `host_with_path` strategy.
所以我确实在 app.php 中更改了它,来自:
$request = RequestFactory::createFromGlobals('host_with_path');
到:
$request = Request::createFromGlobals();
我还将我的 swiftmailer-bundle 从版本 2.3 更新到 5.4.0。 不幸的是,这并没有解决我的错误。
这是我的../app/config_test.yml
swiftmailer:
disable_delivery: true
我错过了什么吗?
我似乎在网络上的任何地方都找不到此错误。有人知道我应该如何解决这个错误吗?
经过一番搜索,我发现 app.php 不是问题所在。它是 DefaultControllerTest.php。可以通过从 DefaultControllerTest 中删除以下行来修复该错误:
$crawler = $client->request('GET', '/hello/Fabien');
$this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
由于最近的事态发展,我们的开发团队决定停止使用 Sonata。作为一个副作用,这个错误得到了修复。所以我不会有解决这个问题的办法。
【问题讨论】:
标签: php symfony phpunit functional-testing symfony-2.6