当我尝试在symfony项目上运行phpunit时,我遇到以下错误:
$ phpunit -c app
1) [...]\DefaultControllerTest::testIndex
Symfony\Component\Config\Exception\FileLoaderLoadException: Cannot import resource "/srv/http/typeform/app/config/config.yml" from "/srv/http/typeform/app/config/config_dev.yml".
/srv/http/typeform/vendor/symfony/src/Symfony/Component/Config/Loader/FileLoader.php:89
[...]
/srv/http/typeform/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:39
/srv/http/typeform/src/QuickyForm/PublicBundle/Tests/Controller/DefaultControllerTest.php:11
Caused by
Symfony\Component\Yaml\Exception\ParseException: You cannot define a mapping item when in a sequence in "\/srv\/http\/typeform\/app\/config\/config.yml"
/usr/share/pear/Symfony/Component/Yaml/Parser.php:116
[...]
/srv/http/typeform/app/bootstrap.php.cache:520
/srv/http/typeform/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:39
/srv/http/typeform/src/QuickyForm/PublicBundle/Tests/Controller/DefaultControllerTest.php:11
调用static::createClient();
时好像死机了
这是我的config_test.yml
imports:
- { resource: config_dev.yml }
2条答案
按热度按时间b1uwtaje1#
您收到的错误表明应用程序无法解析您的“config.yml”,因为“您无法在序列中定义Map项”。
这意味着在yml文件中定义数组值时,不能以“key:value”和“- item”形式的序列条目-所有值必须是其中一种形式。
所以,这样就可以了:
这样也行:
这是不行的:
这些错误表明在config.yml中出现了最后一个表单,尽管如果是这种情况,在浏览器中运行应用程序时应该会出现问题,而不仅仅是在phpunit下。
e0bqpujr2#
另外,对于redbirdo的答案,你应该知道你可能需要在required标记的项下使用'。例如: