Skip to content

Commit

Permalink
Closes #4024
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 22, 2020
1 parent bcf82c2 commit 93dc317
Show file tree
Hide file tree
Showing 18 changed files with 641 additions and 616 deletions.
2 changes: 1 addition & 1 deletion .psalm/baseline.xml
Expand Up @@ -259,7 +259,7 @@
<code>$option['desc']</code>
</PossiblyUndefinedArrayOffset>
</file>
<file src="src/TextUI/ResultPrinter.php">
<file src="src/TextUI/DefaultResultPrinter.php">
<PossiblyUndefinedVariable occurrences="1">
<code>$color</code>
</PossiblyUndefinedVariable>
Expand Down
1 change: 1 addition & 0 deletions ChangeLog-9.0.md
Expand Up @@ -11,6 +11,7 @@ All notable changes of the PHPUnit 9.0 release series are documented in this fil
### Changed

* Implemented [#3746](https://github.com/sebastianbergmann/phpunit/issues/3746): Improve developer experience of global wrapper functions for assertions
* Implemented [#4024](https://github.com/sebastianbergmann/phpunit/issues/4024): Make `PHPUnit\TextUI\ResultPrinter` an interface

### Removed

Expand Down
19 changes: 4 additions & 15 deletions src/TextUI/Command.php
Expand Up @@ -15,7 +15,6 @@
use PharIo\Version\Version as PharIoVersion;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Runner\StandardTestSuiteLoader;
use PHPUnit\Runner\TestSuiteLoader;
Expand Down Expand Up @@ -285,7 +284,7 @@ protected function handleArguments(array $argv): void
foreach ($this->options[0] as $option) {
switch ($option[0]) {
case '--colors':
$this->arguments['colors'] = $option[1] ?: ResultPrinter::COLOR_AUTO;
$this->arguments['colors'] = $option[1] ?: DefaultResultPrinter::COLOR_AUTO;

break;

Expand Down Expand Up @@ -1010,7 +1009,7 @@ protected function handleLoader(string $loaderClass, string $loaderFile = ''): ?
protected function handlePrinter(string $printerClass, string $printerFile = '')
{
if (!\class_exists($printerClass, false)) {
if ($printerFile == '') {
if ($printerFile === '') {
$printerFile = Filesystem::classNameToFilename(
$printerClass
);
Expand Down Expand Up @@ -1044,22 +1043,12 @@ protected function handlePrinter(string $printerClass, string $printerFile = '')
// @codeCoverageIgnoreEnd
}

if (!$class->implementsInterface(TestListener::class)) {
if (!$class->implementsInterface(ResultPrinter::class)) {
$this->exitWithErrorMessage(
\sprintf(
'Could not use "%s" as printer: class does not implement %s',
$printerClass,
TestListener::class
)
);
}

if (!$class->isSubclassOf(Printer::class)) {
$this->exitWithErrorMessage(
\sprintf(
'Could not use "%s" as printer: class does not extend %s',
$printerClass,
Printer::class
ResultPrinter::class
)
);
}
Expand Down

0 comments on commit 93dc317

Please sign in to comment.