mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
This commit is contained in:
@ -12,24 +12,43 @@ use PHPUnit\Framework\Attributes\CoversClass;
|
|||||||
#[CoversClass(Guard::class)]
|
#[CoversClass(Guard::class)]
|
||||||
class GuardTest extends TestCase
|
class GuardTest extends TestCase
|
||||||
{
|
{
|
||||||
public function testargumentIsValidIndex(): void
|
public function testargumentIsValidIndexArgumentAbove(): void
|
||||||
{
|
{
|
||||||
$this->expectException(Exception::class);
|
$this->expectException(Exception::class);
|
||||||
$this->expectExceptionMessage('dummy is an invalid index');
|
$this->expectExceptionMessage('dummy is an invalid index');
|
||||||
Guard::argumentIsValidIndex(10, 10, "dummy");
|
Guard::argumentIsValidIndex(10, 10, "dummy");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testargumentIsValidIndex2(): void
|
public function testargumentIsValidIndexArgumentBelow(): void
|
||||||
{
|
{
|
||||||
$this->expectException(Exception::class);
|
$this->expectException(Exception::class);
|
||||||
$this->expectExceptionMessage('dummy is an invalid index');
|
$this->expectExceptionMessage('dummy is an invalid index');
|
||||||
Guard::argumentIsValidIndex(-1, 10, "dummy");
|
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->expectException(Exception::class);
|
||||||
$this->expectExceptionMessage('dummy is not in the valid range [0, 100]');
|
$this->expectExceptionMessage('dummy is not in the valid range [0, 100]');
|
||||||
Guard::argumentInRangeInclusive(101, 0, 100, "dummy");
|
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
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));
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user