Skip to content

Commit

Permalink
Remove silent hard dependency on PHPUnit. Fixes sebastianbergmann#820
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Oct 9, 2020
1 parent 53a4b73 commit 76eb873
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
5 changes: 4 additions & 1 deletion src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ public function append(RawCodeCoverageData $rawData, $id = null, bool $append =

$size = 'unknown';
$status = -1;
$fromTestcase = false;

if ($id instanceof TestCase) {
$fromTestcase = true;
$_size = $id->getSize();

if ($_size === Test::SMALL) {
Expand All @@ -294,11 +296,12 @@ public function append(RawCodeCoverageData $rawData, $id = null, bool $append =
$status = $id->getStatus();
$id = get_class($id) . '::' . $id->getName();
} elseif ($id instanceof PhptTestCase) {
$fromTestcase = true;
$size = 'large';
$id = $id->getName();
}

$this->tests[$id] = ['size' => $size, 'status' => $status];
$this->tests[$id] = ['size' => $size, 'status' => $status, 'fromTestcase' => $fromTestcase];

$this->data->markCodeAsExecutedByTestCase($id, $rawData);
}
Expand Down
53 changes: 27 additions & 26 deletions src/Report/Html/Renderer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -990,43 +990,44 @@ private function abbreviateMethodName(string $methodName): string

private function createPopoverContentForTest(string $test, array $testData): string
{
switch ($testData['status']) {
case BaseTestRunner::STATUS_PASSED:
switch ($testData['size']) {
case 'small':
$testCSS = ' class="covered-by-small-tests"';
$testCSS = '';

break;
if ($testData['fromTestcase']) {
switch ($testData['status']) {
case BaseTestRunner::STATUS_PASSED:
switch ($testData['size']) {
case 'small':
$testCSS = ' class="covered-by-small-tests"';

case 'medium':
$testCSS = ' class="covered-by-medium-tests"';
break;

break;
case 'medium':
$testCSS = ' class="covered-by-medium-tests"';

default:
$testCSS = ' class="covered-by-large-tests"';
break;

break;
}
default:
$testCSS = ' class="covered-by-large-tests"';

break;
break;
}

case BaseTestRunner::STATUS_SKIPPED:
case BaseTestRunner::STATUS_INCOMPLETE:
case BaseTestRunner::STATUS_RISKY:
case BaseTestRunner::STATUS_WARNING:
$testCSS = ' class="warning"';
break;

break;
case BaseTestRunner::STATUS_SKIPPED:
case BaseTestRunner::STATUS_INCOMPLETE:
case BaseTestRunner::STATUS_RISKY:
case BaseTestRunner::STATUS_WARNING:
$testCSS = ' class="warning"';

case BaseTestRunner::STATUS_FAILURE:
case BaseTestRunner::STATUS_ERROR:
$testCSS = ' class="danger"';
break;

break;
case BaseTestRunner::STATUS_FAILURE:
case BaseTestRunner::STATUS_ERROR:
$testCSS = ' class="danger"';

default:
$testCSS = '';
break;
}
}

return sprintf(
Expand Down
8 changes: 4 additions & 4 deletions tests/tests/CodeCoverageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public function testCollect(): void

$this->assertEquals(
[
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1],
'BankAccountTest::testBalanceIsInitiallyZero' => ['size' => 'unknown', 'status' => -1, 'fromTestcase' => true],
'BankAccountTest::testBalanceCannotBecomeNegative' => ['size' => 'unknown', 'status' => -1, 'fromTestcase' => true],
'BankAccountTest::testBalanceCannotBecomeNegative2' => ['size' => 'unknown', 'status' => -1, 'fromTestcase' => true],
'BankAccountTest::testDepositWithdrawMoney' => ['size' => 'unknown', 'status' => -1, 'fromTestcase' => true],
],
$coverage->getTests()
);
Expand Down

0 comments on commit 76eb873

Please sign in to comment.