Skip to content

Commit

Permalink
Add workaround for fatal error in php-code-coverage library
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 4, 2020
1 parent e888f49 commit 6e7f292
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/php/unittest/coverage/impl/Coverage9.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace unittest\coverage\impl;

use PHPUnit\Runner\BaseTestRunner;
use SebastianBergmann\CodeCoverage\Driver\Selector;
use SebastianBergmann\CodeCoverage\Report\Clover;
use SebastianBergmann\CodeCoverage\Report\Html\Facade;
Expand All @@ -8,6 +9,24 @@
class Coverage9 implements Implementation {
private $filter, $backing;

static function __static() {

// Workaround for fatal error in php-code-coverage when PHPUnit is not loaded
// See https://github.com/sebastianbergmann/php-code-coverage/issues/820
if (!class_exists(BaseTestRunner::class)) {
eval('namespace PHPUnit\Runner; class BaseTestRunner {
const STATUS_UNKNOWN = -1;
const STATUS_PASSED = 0;
const STATUS_SKIPPED = 1;
const STATUS_INCOMPLETE = 2;
const STATUS_FAILURE = 3;
const STATUS_ERROR = 4;
const STATUS_RISKY = 5;
const STATUS_WARNING = 6;
}');
}
}

/** Creates a new coverage implementation for php-code-coverage >= 9.0 */
public function __construct() {
$this->filter= new Filter();
Expand Down

0 comments on commit 6e7f292

Please sign in to comment.