@@ -59,17 +59,17 @@ more confidence.
59
59
Deprecations in PHPUnit
60
60
~~~~~~~~~~~~~~~~~~~~~~~
61
61
62
- By default, PHPUnit will handle deprecation notices as real errors. This means
63
- that all tests are aborted because it uses a BC layer.
62
+ When you run your tests using PHPUnit, no deprecation notices are shown.
63
+ To help you here, Symfony provides a PHPUnit bridge. This bridge will show
64
+ you a nice summary of all deprecation notices at the end of the test report.
64
65
65
- To make sure this doesn't happen, you can install the PHPUnit bridge:
66
+ All you need to do is install the PHPUnit bridge:
66
67
67
68
.. code-block :: bash
68
69
69
70
$ composer require --dev symfony/phpunit-bridge
70
71
71
- Now, your tests execute normally and a nice summary of the deprecation notices
72
- is displayed at the end of the test report:
72
+ Now, you can start fixing the notices:
73
73
74
74
.. code-block :: text
75
75
@@ -87,12 +87,36 @@ is displayed at the end of the test report:
87
87
2x in PageAdminTest::testPageList from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
88
88
1x in PageAdminTest::testPageEdit from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin
89
89
90
+ Once you fixed them all, the command ends with ``0 `` (success) and you're
91
+ done!
92
+
93
+ .. sidebar :: Using the Weak Deprecations Mode
94
+
95
+ Sometimes, you can't fix all deprecations (e.g. something was deprecated
96
+ in 2.6 and you still need to support 2.3). In these cases, you can still
97
+ use the bridge to fix as many deprecations as possible and then switch
98
+ to the weak test mode to make your tests pass again. You can do this by
99
+ using the ``SYMFONY_DEPRECATIONS_HELPER `` env variable:
100
+
101
+ .. code-block :: xml
102
+
103
+ <!-- phpunit.xml.dist -->
104
+ <phpunit >
105
+ <!-- ... -->
106
+
107
+ <php >
108
+ <env name =" SYMFONY_DEPRECATIONS_HELPER" value =" weak" />
109
+ </php >
110
+ </phpunit >
111
+
112
+ (you can also execute the command like ``SYMFONY_DEPRECATIONS_HELPER=weak phpunit ``).
113
+
90
114
.. _upgrade-major-symfony-composer :
91
115
92
116
2) Update to the New Major Version via Composer
93
117
-----------------------------------------------
94
118
95
- If your code is deprecation free, you can update the Symfony library via
119
+ Once your code is deprecation free, you can update the Symfony library via
96
120
Composer by modifying your ``composer.json `` file:
97
121
98
122
.. code-block :: json
@@ -103,14 +127,14 @@ Composer by modifying your ``composer.json`` file:
103
127
"require" : {
104
128
"symfony/symfony" : " 3.0.*" ,
105
129
},
106
- "..." : " ..." ,
130
+ "..." : " ..."
107
131
}
108
132
109
133
Next, use Composer to download new versions of the libraries:
110
134
111
135
.. code-block :: bash
112
136
113
- $ composer update symfony/symfony
137
+ $ composer update --with-dependencies symfony/symfony
114
138
115
139
.. include :: /cookbook/upgrade/_update_dep_errors.rst.inc
116
140
0 commit comments