diff --git a/src/TextUI/Command.php b/src/TextUI/Command.php index 4b7a788348a..d91c8f893c4 100644 --- a/src/TextUI/Command.php +++ b/src/TextUI/Command.php @@ -724,7 +724,11 @@ protected function handleArguments(array $argv): void break; case '--whitelist': - $this->arguments['whitelist'] = $option[1]; + if (!isset($this->arguments['whitelist'])) { + $this->arguments['whitelist'] = []; + } + + $this->arguments['whitelist'][] = $option[1]; break; diff --git a/src/TextUI/TestRunner.php b/src/TextUI/TestRunner.php index 8372d2c23e3..6fabf739b9a 100644 --- a/src/TextUI/TestRunner.php +++ b/src/TextUI/TestRunner.php @@ -457,7 +457,15 @@ public function doRun(Test $suite, array $arguments = [], bool $exit = true): Te $whitelistFromOption = false; if (isset($arguments['whitelist'])) { - $this->codeCoverageFilter->addDirectoryToWhitelist($arguments['whitelist']); + if (!\is_array($arguments['whitelist'])) { + $whitelistDirectories = [$arguments['whitelist']]; + } else { + $whitelistDirectories = $arguments['whitelist']; + } + + foreach ($whitelistDirectories as $whitelistDirectory) { + $this->codeCoverageFilter->addDirectoryToWhitelist($whitelistDirectory); + } $whitelistFromOption = true; } diff --git a/tests/_files/phpt-for-multiwhitelist-coverage.phpt b/tests/_files/phpt-for-multiwhitelist-coverage.phpt new file mode 100644 index 00000000000..7dff83ea98f --- /dev/null +++ b/tests/_files/phpt-for-multiwhitelist-coverage.phpt @@ -0,0 +1,10 @@ +--TEST-- +PHPT for testing coverage using multiple whitespace arguments +--FILE-- +publicMethod(); +$anotherCoveredClass = new SampleClass(1, 2, 'a'); +$testing = $anotherCoveredClass->a; +--EXPECT-- diff --git a/tests/end-to-end/code-coverage-multiple-whitelist.phpt b/tests/end-to-end/code-coverage-multiple-whitelist.phpt new file mode 100644 index 00000000000..6d8b58742f5 --- /dev/null +++ b/tests/end-to-end/code-coverage-multiple-whitelist.phpt @@ -0,0 +1,46 @@ +--TEST-- +phpunit --colors=never --coverage-text=php://stdout ../../_files/phpt-for-coverage.phpt --whitelist ../../_files/CoveredClass.php +--SKIPIF-- +