Skip to content

[PhpUnitBridge] wrong output when trying to quiet deprecations #43371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private function displayDeprecations($groups, $configuration, $isFailing)
fwrite($handle, "\n".self::colorize($deprecationGroupMessage, 'legacy' !== $group && 'indirect' !== $group)."\n");
}

if ('legacy' !== $group && !$configuration->verboseOutput($group) && !$isFailing) {
if ('legacy' !== $group && !$configuration->verboseOutput($group)) {
continue;
}
$notices = $this->deprecationGroups[$group]->notices();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Test DeprecationErrorHandler quiet on everything but self/direct deprecations
--FILE--
<?php

$k = 'SYMFONY_DEPRECATIONS_HELPER';
putenv($k.'='.$_SERVER[$k] = $_ENV[$k] = 'max[self]=0&max[direct]=0&quiet[]=unsilenced&quiet[]=indirect&quiet[]=other');
putenv('ANSICON');
putenv('ConEmuANSI');
putenv('TERM');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
require_once __DIR__.'/../../bootstrap.php';
require __DIR__.'/fake_vendor/autoload.php';
require __DIR__.'/fake_vendor/acme/lib/deprecation_riddled.php';
require __DIR__.'/fake_vendor/acme/outdated-lib/outdated_file.php';

?>
--EXPECTF--
Unsilenced deprecation notices (3)

Remaining direct deprecation notices (2)

1x: root deprecation

1x: silenced bar deprecation
1x in FooTestCase::testNonLegacyBar

Remaining indirect deprecation notices (1)

Legacy deprecation notices (2)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,3 @@ require __DIR__.'/fake_vendor/acme/outdated-lib/outdated_file.php';
?>
--EXPECTF--
Remaining indirect deprecation notices (1)
Copy link
Member Author

@kbond kbond Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was clearly designed to show the below message even when verbose=0 so I'm guessing my "fix" is wrong but at least (hopefully) better demonstrates the problem: when any of the levels has a failure, all level output is verbose again - even levels that are marked as "quiet" that do not cause a failure.


1x: Since acme/lib 3.0: deprecatedApi is deprecated, use deprecatedApi_new instead.
1x in SomeService::deprecatedApi from acme\lib