Skip to content

Commit

Permalink
Closes #2261
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 21, 2016
1 parent a57126d commit 7d924a1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-5.5.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 5.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [5.5.6] - 2016-MM-DD

### Fixed

* Fixed [#2261](https://github.com/sebastianbergmann/phpunit/issues/2261): Invalid test listener configuration leads to confusing behavior

## [5.5.5] - 2016-09-21

### Fixed
Expand Down Expand Up @@ -46,6 +52,7 @@ New release of PHPUnit as PHAR with updated dependencies

* An `AssertionError` raised by an `assert()` in the tested code now causes the test to be interpreted as a failure instead of an error

[5.5.6]: https://github.com/sebastianbergmann/phpunit/compare/5.5.5...5.5.6
[5.5.5]: https://github.com/sebastianbergmann/phpunit/compare/5.5.4...5.5.5
[5.5.4]: https://github.com/sebastianbergmann/phpunit/compare/5.5.3...5.5.4
[5.5.3]: https://github.com/sebastianbergmann/phpunit/compare/5.5.2...5.5.3
Expand Down
39 changes: 26 additions & 13 deletions src/TextUI/TestRunner.php
Expand Up @@ -882,22 +882,35 @@ protected function handleConfiguration(array &$arguments)
require_once $listener['file'];
}

if (class_exists($listener['class'])) {
if (count($listener['arguments']) == 0) {
$listener = new $listener['class'];
} else {
$listenerClass = new ReflectionClass(
if (!class_exists($listener['class'])) {
throw new PHPUnit_Framework_Exception(
sprintf(
'Class "%s" does not exist',
$listener['class']
);
$listener = $listenerClass->newInstanceArgs(
$listener['arguments']
);
}
)
);
}

if ($listener instanceof PHPUnit_Framework_TestListener) {
$arguments['listeners'][] = $listener;
}
$listenerClass = new ReflectionClass($listener['class']);

if (!$listenerClass->implementsInterface(PHPUnit_Framework_TestListener::class)) {
throw new PHPUnit_Framework_Exception(
sprintf(
'Class "%s" does not implement the PHPUnit_Framework_TestListener interface',
$listener['class']
)
);
}

if (count($listener['arguments']) == 0) {
$listener = new $listener['class'];
} else {
$listener = $listenerClass->newInstanceArgs(
$listener['arguments']
);
}

$arguments['listeners'][] = $listener;
}

$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
Expand Down

0 comments on commit 7d924a1

Please sign in to comment.