Skip to content

Commit 026b8b7

Browse files
[PhpUnitBridge] Add weak-verbose mode and match against message instead of test name
1 parent bc642fb commit 026b8b7

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static function register($mode = false)
6464
$group = 'remaining';
6565
}
6666

67-
if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $class.'::'.$method)) {
67+
if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $msg)) {
6868
$e = new \Exception($msg);
6969
$r = new \ReflectionProperty($e, 'trace');
7070
$r->setAccessible(true);
@@ -144,7 +144,7 @@ public static function register($mode = false)
144144
if (!empty($notices)) {
145145
echo "\n";
146146
}
147-
if ('weak' !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
147+
if ('weak' !== $mode && 'weak-verbose' !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
148148
exit(1);
149149
}
150150
});

src/Symfony/Bridge/PhpUnit/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ It comes with the following features:
1414
By default any non-legacy-tagged or any non-@-silenced deprecation notices will
1515
make tests fail.
1616
This can be changed by setting the `SYMFONY_DEPRECATIONS_HELPER` environment
17-
variable to `weak`. This will make the bridge ignore deprecation notices and
18-
is useful to projects that must use deprecated interfaces for backward
19-
compatibility reasons.
17+
variable to `weak` or `weak-versose`. This will make the bridge ignore
18+
deprecation notices and is useful to projects that must use deprecated interfaces
19+
for backward compatibility reasons.
2020

2121
A summary of deprecation notices is displayed at the end of the test suite:
2222

@@ -53,8 +53,8 @@ You have to decide either to:
5353
forward compatibility;
5454
* or move them to the **Legacy** section (by using one of the above way).
5555

56-
In case you need to inspect the stack trace of a particular deprecation triggered by
57-
one of your unit tests, you can set the `SYMFONY_DEPRECATIONS_HELPER` env var to
58-
a regexp that matches this test case's `class::method` name. For example,
59-
`SYMFONY_DEPRECATIONS_HELPER=/^MyTest::testMethod$/ phpunit` will stop your test
60-
suite once a deprecation is triggered by the `MyTest::testMethod` test.
56+
In case you need to inspect the stack trace of a particular deprecation triggered
57+
by your unit tests, you can set the `SYMFONY_DEPRECATIONS_HELPER` env var to a
58+
regexp that matches this depreaction's message. For example,
59+
`SYMFONY_DEPRECATIONS_HELPER=/foobar/ phpunit` will stop your test suite once a
60+
deprecation message is triggered and contains the "foobar" string.

0 commit comments

Comments
 (0)