Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a670ff1

Browse filesBrowse files
[PhpUnitBridge] Add weak-verbose mode and match against message instead of test name
1 parent bc642fb commit a670ff1
Copy full SHA for a670ff1

File tree

Expand file treeCollapse file tree

2 files changed

+15
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-11
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
class DeprecationErrorHandler
2020
{
21+
const MODE_WEAK = 'weak';
22+
const MODE_WEAK_VERBOSE = 'weak-verbose';
23+
2124
private static $isRegistered = false;
2225

2326
public static function register($mode = false)
@@ -64,7 +67,7 @@ public static function register($mode = false)
6467
$group = 'remaining';
6568
}
6669

67-
if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $class.'::'.$method)) {
70+
if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $msg)) {
6871
$e = new \Exception($msg);
6972
$r = new \ReflectionProperty($e, 'trace');
7073
$r->setAccessible(true);
@@ -78,7 +81,7 @@ public static function register($mode = false)
7881

7982
exit(1);
8083
}
81-
if ('legacy' !== $group && 'weak' !== $mode) {
84+
if ('legacy' !== $group && self::MODE_WEAK !== $mode) {
8285
$ref = &$deprecations[$group][$msg]['count'];
8386
++$ref;
8487
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
@@ -144,7 +147,7 @@ public static function register($mode = false)
144147
if (!empty($notices)) {
145148
echo "\n";
146149
}
147-
if ('weak' !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
150+
if (self::MODE_WEAK !== $mode && self::MODE_WEAK_VERBOSE !== $mode && ($deprecations['unsilenced'] || $deprecations['remaining'] || $deprecations['other'])) {
148151
exit(1);
149152
}
150153
});

‎src/Symfony/Bridge/PhpUnit/README.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/README.md
+9-8Lines changed: 9 additions & 8 deletions
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-verbose`. 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,9 @@ 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+
regular expression that matches this deprecation's message, encapsed between `/`.
59+
For example, `SYMFONY_DEPRECATIONS_HELPER=/foobar/ phpunit` will stop your test
60+
suite once a deprecation notice is triggered whose message contains the "foobar"
61+
string.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.