繁体   English   中英

使用Symfony2 + PHPUnit的问题

[英]Problems using Symfony2 + PHPUnit

我使用Symfony2完成了我的第一个“真正的”Web应用程序。 到目前为止还没有单元测试 - 因为项目增长非常快 - 我需要添加它们以在每次发布之前检查错误。 (目前我手动测试一切)

当我第一次使用“phpunit -c app /”时,我得到了这个弃用消息:

其余弃用通知(37)

Symfony \\ Component \\ DependencyInjection \\ Definition :: setFactoryMethod(createNamed)自2.6版以来不推荐使用,将在3.0中删除。 使用Definition :: setFactory()代替:myControllerTest中的4x 4x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

Symfony \\ Component \\ DependencyInjection \\ Definition :: setFactoryService(form.factory)自2.6版以来不推荐使用,将在3.0中删除。 使用Definition :: setFactory()代替:myControllerTest中的4x 4x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config/routing/security.xml”中的“pattern”选项自版本2.2起不再使用,将在3.0中删除。 改为使用路径定义中的“path”选项:myControllerTest中的3x 3x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

不推荐使用Twig函数“form_enctype”。 使用“form_start”代替FOSUserBundle:Profile:edit_content.html.twig at line 1:1x 1x in myControllerTest :: testMyAction from MyNamespace \\ XYZBundle \\ Tests \\ Controller

从版本1.21开始,不推荐使用函数“vich_uploader_asset”的“Twig_Function_Method”实例。 使用Twig_SimpleFunction:myxtrollerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

Twig_Function类自版本1.12起不推荐使用,将在2.0中删除。 使用Twig_SimpleFunction:myxtrollerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/resetting”中服务“fos_user.resetting.form.handler.default”的“范围”属性.xml“从版本2.8开始不推荐使用,将在myControllerTest中删除3.0:1x 1x:myNamespace \\ XYZBundle \\ Tests \\ Controller中的testMyAction

Twig_Function_Method类自版本1.12起不推荐使用,将在2.0中删除。 使用Twig_SimpleFunction:myxtrollerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

不推荐使用Twig函数“form_enctype”。 在FOSUserBundle中使用“form_start”:第1行中的group:new_content.html.twig:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

不推荐使用Twig函数“form_enctype”。 在FOSUserBundle中使用“form_start”:Group:edit_content.html.twig at line 1:1x 1x in myControllerTest :: testMyAction from MyNamespace \\ XYZBundle \\ Tests \\ Controller

不推荐使用Twig函数“form_enctype”。 在FOSUserBundle中使用“form_start”:注册:第1行的register_content.html.twig:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

不推荐使用Twig函数“form_enctype”。 使用“form_start”代替FOSUserBundle:ChangePassword:changePassword_content.html.twig at line 1:1x 1x in myControllerTest :: testMyAction from MyNamespace \\ XYZBundle \\ Tests \\ Controller

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config/routing/security.xml”中路由“fos_user_security_check”的“_method”要求自版本2.2起不再使用,并且将是在3.0中删除。 改为使用“methods”属性:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

不推荐使用Twig函数“form_enctype”。 在FOSUserBundle中使用“form_start”:重置:第1行的reset_content.html.twig:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/resetting.xml”中服务“fos_user.resetting.form”的“factory-service”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/change_password”中服务“fos_user.change_password.form.handler.default”的“范围”属性.xml“从版本2.8开始不推荐使用,将在myControllerTest中删除3.0:1x 1x:myNamespace \\ XYZBundle \\ Tests \\ Controller中的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/profile.xml”中服务“fos_user.profile.form”的“factory-method”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/profile.xml”中服务“fos_user.profile.form”的“factory-service”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

Symfony \\ Component \\ DependencyInjection \\ Definition :: setFactoryService(doctrine)自2.6版以来不推荐使用,将在3.0中删除。 使用Definition :: setFactory()代替:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/orm.xml”中服务“fos_user.entity_manager”的“factory-service”属性是自2.6版以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

Symfony \\ Component \\ DependencyInjection \\ Definition :: setFactoryMethod(getManager)自2.6版以来不推荐使用,将在3.0中删除。 使用Definition :: setFactory()代替:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/profile”中服务“fos_user.profile.form.handler.default”的“范围”属性.xml“从版本2.8开始不推荐使用,将在myControllerTest中删除3.0:1x 1x:myNamespace \\ XYZBundle \\ Tests \\ Controller中的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/registration.xml”中服务“fos_user.registration.form”的“factory-method”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/change_password.xml”中服务“fos_user.change_password.form”的“factory-service”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/orm.xml”中服务“fos_user.entity_manager”的“factory-method”属性是自2.6版以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/change_password.xml”中服务“fos_user.change_password.form”的“factory-method”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/registration”中服务“fos_user.registration.form.handler.default”的“范围”属性.xml“从版本2.8开始不推荐使用,将在myControllerTest中删除3.0:1x 1x:myNamespace \\ XYZBundle \\ Tests \\ Controller中的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/registration.xml”中服务“fos_user.registration.form”的“factory-service”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

文件“/var/www/myproject/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/DependencyInjection/../Resources/config/resetting.xml”中服务“fos_user.resetting.form”的“factory-method”属性“自版本2.6以来已弃用,将在3.0中删除。 改为使用“factory”元素:myControllerTest中的1x 1x ::来自MyNamespace \\ XYZBundle \\ Tests \\ Controller的testMyAction

在第一次(缓存得到构建)之后,只剩下这个:

剩余的弃用通知(320)

“Symfony \\ Bundle \\ AsseticBundle \\ Config \\ AsseticResource”类正在通过ResourceInterface :: isFresh()执行资源检查,自2.8以来不推荐使用它,并将在myControllerTest中删除3.0:320x 320x :: myM空间中的testMyAction \\ XYZBundle \\ Tests \\控制器

我搜索了如何抑制已弃用的警告,因为它们来自依赖项,而不是来自我的代码。 我发现这个解决方案:

<php>
<ini name="error_reporting" value="-16385" />
</php>      

所以我把它添加到我的phpunit.xml但它没有解决问题。 希望你能帮帮我吧!

这个弃用摘要由Symfony PHPunit桥显示。 它有一个弃用助手,它存储所有已触发的弃用通知,并在所有测试运行后显示它们。

可以使用SYMFONY_DEPRECATIONS_HELPER env变量配置弃用助手。 这可以有几个不同的值:

  • weak - 表示当前的弃用通知是由第三方库引起的。 它现在只显示Remaining deprecation notices (320) ,测试脚本将返回0 (成功)。
  • 任何数字 - 表示允许的弃用通知数。 在您的情况下,您知道320弃用通知是由Assetic而不是您的代码引起的。 如果将SYMFONY_DEPRECATIONS_HELPER设置为320 ,只要通知数低于320 ,构建就会通过。这非常有用,因为它会在您引入新的弃用时立即发出警告。
  • 正则表达式 - 只要触发与正则表达式匹配的弃用,就会停止构建。 这对于调试弃用通知很有用。

设置env变量可以在命令行上完成:

# unix
$ SYMFONY_DEPRECATIONS_HELPER=320 phpunit -c app
# windows
> set SYMFONY_DEPRECATIONS_HELPER=320
> phpunit -c app

或者在phpunit.xml(.dist)文件中:

<php>
    <env name="SYMFONY_DEPRECATIONS_HELPER" value="320"/>
</php>

暂无
暂无

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

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