generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Throw PhaseNotStarted exception when phase was not started
- Loading branch information
1 parent
75e490f
commit b795cce
Showing
4 changed files
with
83 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2023 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/phpunit-slow-test-detector | ||
*/ | ||
|
||
namespace Ergebnis\PHPUnit\SlowTestDetector\Exception; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\PhaseIdentifier; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class PhaseNotStarted extends \InvalidArgumentException | ||
{ | ||
public static function fromPhaseIdentifier(PhaseIdentifier $phaseIdentifier): self | ||
{ | ||
return new self(\sprintf( | ||
'Phase identified by "%s" has not been started.', | ||
$phaseIdentifier->toString(), | ||
)); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2023 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/phpunit-slow-test-detector | ||
*/ | ||
|
||
namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Unit\Exception; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\Exception; | ||
use Ergebnis\PHPUnit\SlowTestDetector\PhaseIdentifier; | ||
use Ergebnis\PHPUnit\SlowTestDetector\Test; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Exception\PhaseNotStarted | ||
* | ||
* @uses \Ergebnis\PHPUnit\SlowTestDetector\PhaseIdentifier | ||
*/ | ||
final class PhaseNotStartedTest extends Framework\TestCase | ||
{ | ||
use Test\Util\Helper; | ||
|
||
public function testFromPhaseIdentifierReturnsException(): void | ||
{ | ||
$phaseIdentifier = PhaseIdentifier::fromString(self::faker()->word()); | ||
|
||
$exception = Exception\PhaseNotStarted::fromPhaseIdentifier($phaseIdentifier); | ||
|
||
$message = \sprintf( | ||
'Phase identified by "%s" has not been started.', | ||
$phaseIdentifier->toString(), | ||
); | ||
|
||
self::assertSame($message, $exception->getMessage()); | ||
} | ||
} |
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