“当在序列中时,您不能定义映射项".在symfony中运行phpunit时 [英] "You cannot define a mapping item when in a sequence" when running phpunit in symfony

查看:112
本文介绍了“当在序列中时,您不能定义映射项".在symfony中运行phpunit时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在symfony项目上运行phpunit时,出现以下错误:

I'm getting the following errors when I try to run phpunit on my symfony project:

$ 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

Here's my config_test.yml

imports:
    - { resource: config_dev.yml }

推荐答案

您收到的错误提示该应用无法解析您的"config.yml",因为您无法在序列中定义映射项".

The errors you are getting suggest that the app is failing to parse your 'config.yml' because "You cannot define a mapping item when in a sequence".

这意味着在yml文件中,当定义数组值时,不能同时提供"key:value"形式的映射条目和-item"形式的序列条目-所有值都必须是一个或另一种形式.

This means that in a yml file when defining array values you cannot provide both mapping entries in the form "key: value" and sequence entries in the form "- item" - all values must be either one or the other form.

那么,这没关系:

group: 
  key: value
  key: value

这也可以:

group: 
  - item 
  - item 

这不行:

group: 
  key: value
  - item 

该错误表明config.yml中存在最后一种形式,尽管如果出现这种情况,这可能会导致在浏览器中而不是仅在phpunit下运行应用程序时出现问题.

The errors suggest that there is an occurrence of the last form in your config.yml, although if this is the case it ought to cause problems running your app in the browser and not just under phpunit.

这篇关于“当在序列中时,您不能定义映射项".在symfony中运行phpunit时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆