Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2020-02-16 17:59:01 +0000
committerDawid Pakuła2020-02-16 17:59:01 +0000
commit88b6b32a254fc27b5e23bf93cf8216c28c195fe8 (patch)
tree55a975d1acdb46de8937259bc30025a546e30c7f
parent97a8ef1599d28dab8f882207d0f98568c4d17772 (diff)
downloadorg.eclipse.pdt-master.tar.gz
org.eclipse.pdt-master.tar.xz
org.eclipse.pdt-master.zip
Bug 559932 - PHPUnit 9 SupportHEADmaster
Change-Id: I870629f6c2d59246757ddadb4c022a886b1a8158 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.phpunit/resources/printer/PHPUnitLogger.php156
1 files changed, 155 insertions, 1 deletions
diff --git a/plugins/org.eclipse.php.phpunit/resources/printer/PHPUnitLogger.php b/plugins/org.eclipse.php.phpunit/resources/printer/PHPUnitLogger.php
index edaedc11b..6225db236 100644
--- a/plugins/org.eclipse.php.phpunit/resources/printer/PHPUnitLogger.php
+++ b/plugins/org.eclipse.php.phpunit/resources/printer/PHPUnitLogger.php
@@ -53,7 +53,161 @@ if (class_exists('PHP_Timer')) {
} elseif(class_exists('PHPUnit\SebastianBergmann\Timer\Timer')) {
class_alias('PHPUnit\SebastianBergmann\Timer\Timer', 'Timer');
}
-if (_RUNNER_VERSION >= 7) {
+if (_RUNNER_VERSION >= 9) {
+ $logger = <<<'LOGGER'
+ class PHPUnitLogger extends \PHPUnit\TextUI\DefaultResultPrinter implements TestListener, \PHPUnit\TextUI\ResultPrinter
+ {
+ protected $loggers = array();
+ public function printResult(\PHPUnit\Framework\TestResult $result): void
+ {
+ }
+
+ /**
+ * Handler for 'start class' event.
+ */
+ protected function startClass(string $name): void
+ {
+ $this->write($this->currentTestClassPrettified . "\n");
+ }
+
+ /**
+ * Handler for 'on test' event.
+ */
+ protected function onTest(string $name, bool $success = true): void
+ {
+ if ($success) {
+ $this->write(' [x] ');
+ } else {
+ $this->write(' [ ] ');
+ }
+
+ $this->write($name . "\n");
+ }
+
+ /**
+ * Handler for 'end class' event.
+ */
+ protected function endClass(string $name): void
+ {
+ $this->write("\n");
+ }
+ public function __construct($out = null)
+ {
+ parent::__construct('php://stdout', true);
+ class_alias('PHPUnit\Framework\ExceptionWrapper', 'ExceptionWrapper');
+ class_alias('PHPUnit\Util\Blacklist', 'Blacklist');
+ $this->loggers = array(
+ new PHPUnitEclipseLogger()
+ );
+ }
+
+ public function setAutoFlush(bool $autoFlush): void
+ {
+ parent::setAutoFlush($autoFlush);
+ foreach ($this->loggers as $logger) {
+ $logger->setAutoFlush($autoFlush);
+ }
+ }
+
+ public function flush(): void
+ {
+ parent::flush();
+ foreach ($this->loggers as $logger) {
+ $logger->flush();
+ }
+ }
+
+ public function incrementalFlush(): void
+ {
+ parent::incrementalFlush();
+ foreach ($this->loggers as $logger) {
+ $logger->incrementalFlush();
+ }
+ }
+
+ public function addError(Test $test, Throwable $t, float $time): void
+ {
+ parent::addError($test, $t, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addError($test, $t, $time);
+ }
+ }
+
+ public function addWarning(Test $test, Warning $e, float $time): void
+ {
+ parent::addWarning($test, $e, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addWarning($test, $e, $time);
+ }
+ }
+
+ public function addFailure(Test $test, AssertionFailedError $e, float $time): void
+ {
+ parent::addFailure($test, $e, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addFailure($test, $e, $time);
+ }
+ }
+
+ public function addIncompleteTest(Test $test, Throwable $t, float $time): void
+ {
+ parent::addIncompleteTest($test, $t, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addIncompleteTest($test, $t, $time);
+ }
+ }
+
+ public function addRiskyTest(Test $test, Throwable $t, float $time): void
+ {
+ parent::addRiskyTest($test, $t, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addRiskyTest($test, $t, $time);
+ }
+ }
+
+ public function addSkippedTest(Test $test, Throwable $t, float $time): void
+ {
+ parent::addSkippedTest($test, $t, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->addSkippedTest($test, $t, $time);
+ }
+ }
+
+ public function startTestSuite(TestSuite $suite): void
+ {
+ parent::startTestSuite($suite);
+ foreach ($this->loggers as $logger) {
+ $logger->startTestSuite($suite);
+ }
+ }
+
+ public function endTestSuite(TestSuite $suite): void
+ {
+ parent::endTestSuite($suite);
+ foreach ($this->loggers as $logger) {
+ $logger->endTestSuite($suite);
+ }
+ }
+
+ public function startTest(Test $test): void
+ {
+ parent::startTest($test);
+
+ foreach ($this->loggers as $logger) {
+ $logger->startTest($test);
+ }
+ }
+
+ public function endTest(Test $test, float $time): void
+ {
+ parent::endTest($test, $time);
+ foreach ($this->loggers as $logger) {
+ $logger->endTest($test, $time);
+ }
+ }
+ }
+LOGGER;
+} elseif (_RUNNER_VERSION >= 7) {
$logger = <<<'LOGGER'
class PHPUnitLogger extends TextPrinter implements TestListener
{

Back to the top