所以感谢 Matteo(symfony2 中的 phpunit - 没有执行测试)我现在可以测试我的功能测试。
现在运行时出现以下错误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。作为一个副作用,这个错误得到了修复。所以我不会有这个问题的解决方案。