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.
- Loading branch information
1 parent
1df12ef
commit 2326604
Showing
9 changed files
with
130 additions
and
60 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
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 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; | ||
|
||
final class MaximumCount | ||
{ | ||
private int $value; | ||
|
||
private function __construct(int $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
/** | ||
* @throws Exception\InvalidMaximumCount | ||
*/ | ||
public static function fromInt(int $value): self | ||
{ | ||
if (0 >= $value) { | ||
throw Exception\InvalidMaximumCount::notGreaterThanZero($value); | ||
} | ||
|
||
return new self($value); | ||
} | ||
|
||
public function toInt(): int | ||
{ | ||
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
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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 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; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\Exception; | ||
use Ergebnis\PHPUnit\SlowTestDetector\MaximumCount; | ||
use Ergebnis\Test\Util; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\PHPUnit\SlowTestDetector\MaximumCount | ||
* | ||
* @uses \Ergebnis\PHPUnit\SlowTestDetector\Exception\InvalidMaximumCount | ||
*/ | ||
final class MaximumCountTest extends Framework\TestCase | ||
{ | ||
use Util\Helper; | ||
|
||
/** | ||
* @dataProvider \Ergebnis\Test\Util\DataProvider\IntProvider::lessThanZero() | ||
* @dataProvider \Ergebnis\Test\Util\DataProvider\IntProvider::zero() | ||
*/ | ||
public function testFromIntRejectsInvalidValue(int $value): void | ||
{ | ||
$this->expectException(Exception\InvalidMaximumCount::class); | ||
|
||
MaximumCount::fromInt($value); | ||
} | ||
|
||
/** | ||
* @dataProvider \Ergebnis\Test\Util\DataProvider\IntProvider::greaterThanZero() | ||
*/ | ||
public function testFromSecondsReturnsMaximumDuration(int $value): void | ||
{ | ||
$maximumCount = MaximumCount::fromInt($value); | ||
|
||
self::assertSame($value, $maximumCount->toInt()); | ||
} | ||
} |
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