From 499c4cd4bb08e050ba2768657c555833ae3e1389 Mon Sep 17 00:00:00 2001 From: SimonHeimberg Date: Fri, 15 Dec 2017 15:41:54 +0100 Subject: [PATCH 1/2] PhpUnitJson does not fail on empty trace --- src/PHPCensor/Plugin/Util/PhpUnitResultJson.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php b/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php index c99704cb..0551a85d 100644 --- a/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php +++ b/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php @@ -134,6 +134,12 @@ class PhpUnitResultJson extends PhpUnitResult */ protected function getFileAndLine($event) { + if (empty($event['trace'])) { + return [ + 'file' => '', + 'line' => '', + ]; + } $firstTrace = end($event['trace']); reset($event['trace']); From 80e01a7e9eb7c7b41620eda0d233671833fe20aa Mon Sep 17 00:00:00 2001 From: SimonHeimberg Date: Tue, 12 Dec 2017 09:06:25 +0100 Subject: [PATCH 2/2] PhpUnitJson reports an unfinished test as error at the end --- src/PHPCensor/Plugin/Util/PhpUnitResultJson.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php b/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php index 0551a85d..96c932e4 100644 --- a/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php +++ b/src/PHPCensor/Plugin/Util/PhpUnitResultJson.php @@ -40,11 +40,22 @@ class PhpUnitResultJson extends PhpUnitResult $this->failures = 0; if ($events) { + $started = null; foreach ($events as $event) { if (isset($event['event']) && $event['event'] == self::EVENT_TEST) { $this->parseTestcase($event); + $started = null; + } elseif (isset($event['event']) && $event['event'] == self::EVENT_TEST_START) { + $started = $event; } } + if ($started) { + $event = $started; + $event['status'] = 'error'; + $event['message'] = 'Test is not finished'; + $event['output'] = ''; + $this->parseTestcase($event); + } } return $this;