Skip to content

Commit 7d924a1

Browse files
1 parent a57126d commit 7d924a1

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

ChangeLog-5.5.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## [5.5.6] - 2016-MM-DD
6+
7+
### Fixed
8+
9+
* Fixed [#2261](https://github.com/sebastianbergmann/phpunit/issues/2261): Invalid test listener configuration leads to confusing behavior
10+
511
## [5.5.5] - 2016-09-21
612

713
### Fixed
@@ -46,6 +52,7 @@ New release of PHPUnit as PHAR with updated dependencies
4652

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

55+
[5.5.6]: https://github.com/sebastianbergmann/phpunit/compare/5.5.5...5.5.6
4956
[5.5.5]: https://github.com/sebastianbergmann/phpunit/compare/5.5.4...5.5.5
5057
[5.5.4]: https://github.com/sebastianbergmann/phpunit/compare/5.5.3...5.5.4
5158
[5.5.3]: https://github.com/sebastianbergmann/phpunit/compare/5.5.2...5.5.3

src/TextUI/TestRunner.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -882,22 +882,35 @@ protected function handleConfiguration(array &$arguments)
882882
require_once $listener['file'];
883883
}
884884

885-
if (class_exists($listener['class'])) {
886-
if (count($listener['arguments']) == 0) {
887-
$listener = new $listener['class'];
888-
} else {
889-
$listenerClass = new ReflectionClass(
885+
if (!class_exists($listener['class'])) {
886+
throw new PHPUnit_Framework_Exception(
887+
sprintf(
888+
'Class "%s" does not exist',
890889
$listener['class']
891-
);
892-
$listener = $listenerClass->newInstanceArgs(
893-
$listener['arguments']
894-
);
895-
}
890+
)
891+
);
892+
}
896893

897-
if ($listener instanceof PHPUnit_Framework_TestListener) {
898-
$arguments['listeners'][] = $listener;
899-
}
894+
$listenerClass = new ReflectionClass($listener['class']);
895+
896+
if (!$listenerClass->implementsInterface(PHPUnit_Framework_TestListener::class)) {
897+
throw new PHPUnit_Framework_Exception(
898+
sprintf(
899+
'Class "%s" does not implement the PHPUnit_Framework_TestListener interface',
900+
$listener['class']
901+
)
902+
);
903+
}
904+
905+
if (count($listener['arguments']) == 0) {
906+
$listener = new $listener['class'];
907+
} else {
908+
$listener = $listenerClass->newInstanceArgs(
909+
$listener['arguments']
910+
);
900911
}
912+
913+
$arguments['listeners'][] = $listener;
901914
}
902915

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

0 commit comments

Comments
 (0)