簡體   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