trueskill/tests/GuardTest.php
Jens True 4b3a328726
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Additional tests
2024-05-15 12:41:34 +00:00

55 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace DNW\Skills\Tests;
use DNW\Skills\Guard;
use Exception;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(Guard::class)]
class GuardTest extends TestCase
{
public function testargumentIsValidIndexArgumentAbove(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is an invalid index');
Guard::argumentIsValidIndex(10, 10, "dummy");
}
public function testargumentIsValidIndexArgumentBelow(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is an invalid index');
Guard::argumentIsValidIndex(-1, 10, "dummy");
}
public function testargumentIsValidIndexArgumentValid(): void
{
Guard::argumentIsValidIndex(5, 10, "dummy");
$this->expectNotToPerformAssertions();
}
public function testargumentInRangeInclusiveAbove(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is not in the valid range [0, 100]');
Guard::argumentInRangeInclusive(101, 0, 100, "dummy");
}
public function testargumentInRangeInclusiveBelow(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is not in the valid range [0, 100]');
Guard::argumentInRangeInclusive(-1, 0, 100, "dummy");
}
public function testargumentInRangeInclusiveValid(): void
{
Guard::argumentInRangeInclusive(50, 0, 100, "dummy");
$this->expectNotToPerformAssertions();
}
}