Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9610800
commit 41c7584
Showing
22 changed files
with
585 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterIncompleteTestHook extends TestHook | ||
{ | ||
public function executeAfterIncompleteTest(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterLastTestHook extends Hook | ||
{ | ||
public function executeAfterLastTest(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterRiskyTestHook extends TestHook | ||
{ | ||
public function executeAfterRiskyTest(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterSkippedTestHook extends TestHook | ||
{ | ||
public function executeAfterSkippedTest(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterSuccessfulTestHook extends TestHook | ||
{ | ||
public function executeAfterSuccessfulTest(string $test, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterTestErrorHook extends TestHook | ||
{ | ||
public function executeAfterTestError(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterTestFailureHook extends TestHook | ||
{ | ||
public function executeAfterTestFailure(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface AfterTestWarningHook extends TestHook | ||
{ | ||
public function executeAfterTestWarning(string $test, string $message, float $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface BeforeFirstTestHook extends Hook | ||
{ | ||
public function executeBeforeFirstTest(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface BeforeTestHook extends TestHook | ||
{ | ||
public function executeBeforeTest(string $test): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface Hook | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
interface TestHook extends Hook | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace PHPUnit\Runner; | ||
|
||
use PHPUnit\Framework\AssertionFailedError; | ||
use PHPUnit\Framework\Test; | ||
use PHPUnit\Framework\TestListener; | ||
use PHPUnit\Framework\TestSuite; | ||
use PHPUnit\Framework\Warning; | ||
use PHPUnit\Util\Test as TestUtil; | ||
|
||
final class TestListenerAdapter implements TestListener | ||
{ | ||
/** | ||
* @var TestHook[] | ||
*/ | ||
private $hooks = []; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $lastTestWasNotSuccessful; | ||
|
||
public function add(TestHook $hook): void | ||
{ | ||
$this->hooks[] = $hook; | ||
} | ||
|
||
public function startTest(Test $test): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof BeforeTestHook) { | ||
$hook->executeBeforeTest(TestUtil::describeAsString($test)); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = false; | ||
} | ||
|
||
public function addError(Test $test, \Throwable $t, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterTestErrorHook) { | ||
$hook->executeAfterTestError(TestUtil::describeAsString($test), $t->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function addWarning(Test $test, Warning $e, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterTestWarningHook) { | ||
$hook->executeAfterTestWarning(TestUtil::describeAsString($test), $e->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function addFailure(Test $test, AssertionFailedError $e, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterTestFailureHook) { | ||
$hook->executeAfterTestFailure(TestUtil::describeAsString($test), $e->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterIncompleteTestHook) { | ||
$hook->executeAfterIncompleteTest(TestUtil::describeAsString($test), $t->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function addRiskyTest(Test $test, \Throwable $t, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterRiskyTestHook) { | ||
$hook->executeAfterRiskyTest(TestUtil::describeAsString($test), $t->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function addSkippedTest(Test $test, \Throwable $t, float $time): void | ||
{ | ||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterSkippedTestHook) { | ||
$hook->executeAfterSkippedTest(TestUtil::describeAsString($test), $t->getMessage(), $time); | ||
} | ||
} | ||
|
||
$this->lastTestWasNotSuccessful = true; | ||
} | ||
|
||
public function endTest(Test $test, float $time): void | ||
{ | ||
if ($this->lastTestWasNotSuccessful === true) { | ||
return; | ||
} | ||
|
||
foreach ($this->hooks as $hook) { | ||
if ($hook instanceof AfterSuccessfulTestHook) { | ||
$hook->executeAfterSuccessfulTest(TestUtil::describeAsString($test), $time); | ||
} | ||
} | ||
} | ||
|
||
public function startTestSuite(TestSuite $suite): void | ||
{ | ||
} | ||
|
||
public function endTestSuite(TestSuite $suite): void | ||
{ | ||
} | ||
} |
Oops, something went wrong.