Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit e8528cb

Browse files
ednoDavertMik
authored andcommitted
Improve support of PHPUnit warning status (#22)
1 parent b3d16b1 commit e8528cb

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Listener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function addError(\PHPUnit\Framework\Test $test, \Throwable $e, float $ti
5353
// This method was added in PHPUnit 6
5454
public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, float $time) : void
5555
{
56+
$this->unsuccessfulTests[] = spl_object_hash($test);
57+
$this->fire(Events::TEST_WARNING, new FailEvent($test, $time, $e));
5658
}
5759

5860
public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time) : void

src/ResultPrinter.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass
3333
$this->failed++;
3434
}
3535

36+
/**
37+
* A warning occurred.
38+
*
39+
* @param \PHPUnit\Framework\Test $test
40+
* @param \PHPUnit\Framework\Warning $e
41+
* @param float $time
42+
*/
43+
public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, float $time): void
44+
{
45+
$this->testStatus = \PHPUnit\Runner\BaseTestRunner::STATUS_WARNING;
46+
$this->warned++;
47+
}
48+
3649
/**
3750
* Incomplete test.
3851
*

src/ResultPrinter/UI.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Ass
8383
$this->lastTestFailed = true;
8484
}
8585

86+
public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, float $time) : void
87+
{
88+
$this->lastTestFailed = true;
89+
}
90+
8691
public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time) : void
8792
{
8893
$this->lastTestFailed = true;

0 commit comments

Comments
 (0)