@@ -45,17 +45,19 @@ in your browser, these notices are shown in the web dev toolbar:
45
45
Deprecations in PHPUnit
46
46
~~~~~~~~~~~~~~~~~~~~~~~
47
47
48
- By default, PHPUnit will handle deprecation notices as real errors. This means
49
- that all tests are aborted because it uses a BC layer.
48
+ By default, deprecations that are triggered by Symfony are silenced. This means
49
+ that, unless you use Xdebug or a custom error handler, your tests will still
50
+ pass without a problem.
50
51
51
- To make sure this doesn't happen, you can install the PHPUnit bridge:
52
+ If you want to make sure you don't use any deprecated features, you can install
53
+ the Symfony PHPunit bridge:
52
54
53
55
.. code-block :: bash
54
56
55
57
$ composer require symfony/phpunit-bridge
56
58
57
- Now, your tests execute normally and a nice summary of the deprecation notices
58
- is displayed at the end of the test report :
59
+ This bridge registers a custom error handler that will report a nice summary of
60
+ the deprecation notices at the end of the tests :
59
61
60
62
.. code-block :: text
61
63
@@ -73,12 +75,36 @@ is displayed at the end of the test report:
73
75
2x in PageAdminTest::testPageList from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
74
76
1x in PageAdminTest::testPageEdit from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
75
77
78
+ Now, you can work on fixing these errors. Once you fixed them all, the command
79
+ will end with ``0 `` (success) and you're save!
80
+
81
+ .. sidebar :: Using the Weak Deprecations Mode
82
+
83
+ Sometimes, you can't fix all deprecations (e.g. something that is
84
+ deprecated in 2.6 and you still need to support 2.3). In these cases, you
85
+ can still use the bridge to fix as many deprecations as possible and then
86
+ switch to the weak test mode to make your tests pass again. You can do this
87
+ by using the ``SYMFONY_DEPRECATIONS_HELPER `` env variable:
88
+
89
+ .. code-block :: xml
90
+
91
+ <!-- phpunit.xml.dist -->
92
+ <phpunit >
93
+ <!-- ... -->
94
+
95
+ <php >
96
+ <env name =" SYMFONY_DEPRECATIONS_HELPER" value =" weak" />
97
+ </php >
98
+ </phpunit >
99
+
100
+ (you can also execute the command like ``SYMFONY_DEPRECATIONS_HELPER=weak phpunit ``).
101
+
76
102
.. _upgrade-major-symfony-composer :
77
103
78
104
2) Update to the New Major Version via Composer
79
105
-----------------------------------------------
80
106
81
- If your code is deprecation free, you can update the Symfony library via
107
+ Once your code is deprecation free, you can update the Symfony library via
82
108
Composer by modifying your ``composer.json `` file:
83
109
84
110
.. code-block :: json
@@ -89,14 +115,14 @@ Composer by modifying your ``composer.json`` file:
89
115
"require" : {
90
116
"symfony/symfony" : " 3.0.*" ,
91
117
},
92
- "..." : " ..." ,
118
+ "..." : " ..."
93
119
}
94
120
95
121
Next, use Composer to download new versions of the libraries:
96
122
97
123
.. code-block :: bash
98
124
99
- $ composer update symfony/symfony
125
+ $ composer update --with-dependencies symfony/symfony
100
126
101
127
.. include :: /cookbook/upgrade/_update_all_packages.rst.inc
102
128
0 commit comments