From 7b3fdaf8b6e3a38e5078b006bd2143b8ad1ef9b7 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 7 Jun 2020 08:08:54 +0200 Subject: [PATCH] More work on removing the blacklist/whitelist terminology --- ChangeLog-9.3.md | 2 ++ src/Framework/TestCase.php | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog-9.3.md b/ChangeLog-9.3.md index 4c3ad6f8bfa..26a18c249a3 100644 --- a/ChangeLog-9.3.md +++ b/ChangeLog-9.3.md @@ -7,6 +7,8 @@ All notable changes of the PHPUnit 9.3 release series are documented in this fil ### Changed * [#4264](https://github.com/sebastianbergmann/phpunit/pull/4264): Refactor logical operator constraints +* `PHPUnit\Framework\TestCase::$backupGlobalsBlacklist` is deprecated, use `PHPUnit\Framework\TestCase::$backupGlobalsExcludeList` instead +* `PHPUnit\Framework\TestCase::$backupStaticAttributesBlacklist` is deprecated, use `PHPUnit\Framework\TestCase::$backupStaticAttributesExcludeList` instead * `PHPUnit\Util\Blacklist` is now deprecated, please use `PHPUnit\Util\ExcludeList` instead [9.3.0]: https://github.com/sebastianbergmann/phpunit/compare/9.2...master diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index c08ed36924f..a3401f69d18 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -68,6 +68,13 @@ abstract class TestCase extends Assert implements SelfDescribing, Test /** * @var string[] */ + protected $backupGlobalsExcludeList = []; + + /** + * @var string[] + * + * @deprecated Use $backupGlobalsExcludeList instead + */ protected $backupGlobalsBlacklist = []; /** @@ -78,6 +85,13 @@ abstract class TestCase extends Assert implements SelfDescribing, Test /** * @var array> */ + protected $backupStaticAttributesExcludeList = []; + + /** + * @var array> + * + * @deprecated Use $backupStaticAttributesExcludeList instead + */ protected $backupStaticAttributesBlacklist = []; /** @@ -2167,6 +2181,10 @@ private function createGlobalStateSnapshot(bool $backupGlobals): Snapshot { $excludeList = new ExcludeList; + foreach ($this->backupGlobalsExcludeList as $globalVariable) { + $excludeList->addGlobalVariable($globalVariable); + } + foreach ($this->backupGlobalsBlacklist as $globalVariable) { $excludeList->addGlobalVariable($globalVariable); } @@ -2183,6 +2201,12 @@ private function createGlobalStateSnapshot(bool $backupGlobals): Snapshot $excludeList->addClassNamePrefix('Doctrine\Instantiator'); $excludeList->addClassNamePrefix('Prophecy'); + foreach ($this->backupStaticAttributesExcludeList as $class => $attributes) { + foreach ($attributes as $attribute) { + $excludeList->addStaticAttribute($class, $attribute); + } + } + foreach ($this->backupStaticAttributesBlacklist as $class => $attributes) { foreach ($attributes as $attribute) { $excludeList->addStaticAttribute($class, $attribute);