generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Implement TestDescription
- Loading branch information
1 parent
dd37d9c
commit a118f92
Showing
11 changed files
with
216 additions
and
2 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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2024 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; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class InvalidTestDescription extends \InvalidArgumentException | ||
{ | ||
public static function blankOrEmpty(): self | ||
{ | ||
return new self('Value cannot be blank or empty.'); | ||
} | ||
} |
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
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2024 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; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class TestDescription | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $value; | ||
|
||
private function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @throws Exception\InvalidTestIdentifier | ||
*/ | ||
public static function fromString(string $value): self | ||
{ | ||
if ('' === \trim($value)) { | ||
throw Exception\InvalidTestIdentifier::blankOrEmpty(); | ||
} | ||
|
||
return new self($value); | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
return $this->value; | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2024 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 PHPUnit\Framework; | ||
|
||
/** | ||
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidTestDescription | ||
*/ | ||
final class InvalidTestDescriptionTest extends Framework\TestCase | ||
{ | ||
public function testBlankOrEmptyReturnsException() | ||
Check failure on line 24 in test/Unit/Exception/InvalidTestDescriptionTest.php GitHub Actions / Static Code Analysis (7.4, locked)MissingReturnType
|
||
{ | ||
$exception = Exception\InvalidTestDescription::blankOrEmpty(); | ||
|
||
self::assertSame('Value cannot be blank or empty.', $exception->getMessage()); | ||
} | ||
} |
Oops, something went wrong.