Additional tests
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Jens True 2024-05-15 12:41:34 +00:00
parent 82a5505438
commit 4b3a328726
2 changed files with 49 additions and 3 deletions

@ -12,24 +12,43 @@ use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(Guard::class)]
class GuardTest extends TestCase
{
public function testargumentIsValidIndex(): void
public function testargumentIsValidIndexArgumentAbove(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is an invalid index');
Guard::argumentIsValidIndex(10, 10, "dummy");
}
public function testargumentIsValidIndex2(): void
public function testargumentIsValidIndexArgumentBelow(): void
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('dummy is an invalid index');
Guard::argumentIsValidIndex(-1, 10, "dummy");
}
public function testargumentInRangeInclusive(): void
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();
}
}

27
tests/PartialPlayTest.php Normal file

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace DNW\Skills\Tests;
use DNW\Skills\PartialPlay;
use DNW\Skills\Player;
use DNW\Skills\Guard;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
#[CoversClass(PartialPlay::class)]
#[UsesClass(Player::class)]
#[UsesClass(Guard::class)]
class PartialPlayTest extends TestCase
{
public function testgetPartialPlayPercentage(): void
{
$p = new Player(1, 0.5);
$this->assertEquals($p->getPartialPlayPercentage(), PartialPlay::getPartialPlayPercentage($p));
$p = new Player(1, 0.000000);
$this->assertNotEquals(0.0, PartialPlay::getPartialPlayPercentage($p));
}
}