mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-15 17:37:39 +00:00
Cleanup abstractions of "TestCase" class in unittest
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -17,7 +17,7 @@ pipeline:
|
||||
image: php:cli-bookworm
|
||||
commands:
|
||||
- vendor/bin/phpunit tests
|
||||
document:
|
||||
image: phpdoc/phpdoc
|
||||
commands:
|
||||
- phpdoc run
|
||||
# document:
|
||||
# image: phpdoc/phpdoc
|
||||
# commands:
|
||||
# - phpdoc
|
17
tests/FactorGraphs/ScheduleStepTest.php
Normal file
17
tests/FactorGraphs/ScheduleStepTest.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace DNW\Skills\Tests\FactorGraphs;
|
||||
|
||||
use DNW\Skills\FactorGraphs\ScheduleStep;
|
||||
use DNW\Skills\FactorGraphs\Factor;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ScheduleStepTest extends TestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$stub = $this->createStub(Factor::class);
|
||||
$ss = new ScheduleStep('dummy', $stub, 0);
|
||||
$this->assertEquals('dummy', (string)$ss);
|
||||
}
|
||||
}
|
22
tests/FactorGraphs/VariableTest.php
Normal file
22
tests/FactorGraphs/VariableTest.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace DNW\Skills\Tests\FactorGraphs;
|
||||
|
||||
use DNW\Skills\FactorGraphs\Variable;
|
||||
use DNW\Skills\Numerics\GaussianDistribution;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class VariableTest extends TestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$gd_prior = new GaussianDistribution();
|
||||
$var = new Variable('dummy', $gd_prior);
|
||||
$this->assertEquals($gd_prior, $var->getValue());
|
||||
$gd_new = new GaussianDistribution();
|
||||
$this->assertEquals($gd_new, $var->getValue());
|
||||
$var->resetToPrior();
|
||||
$this->assertEquals($gd_prior, $var->getValue());
|
||||
$this->assertEquals('Variable[dummy]', (string)$var);
|
||||
}
|
||||
}
|
@ -4,25 +4,35 @@ namespace DNW\Skills\Tests;
|
||||
|
||||
use DNW\Skills\Guard;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class GuardTest extends TestCase
|
||||
{
|
||||
public function testArgumentNotNull(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('dummy can not be null');
|
||||
Guard::argumentNotNull(null, "dummy");
|
||||
}
|
||||
|
||||
public function testargumentIsValidIndex(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
Guard::argumentIsValidIndex(25, 10, "dummy");
|
||||
$this->expectExceptionMessage('dummy is an invalid index');
|
||||
Guard::argumentIsValidIndex(10, 10, "dummy");
|
||||
}
|
||||
|
||||
public function testargumentIsValidIndex2(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('dummy is an invalid index');
|
||||
Guard::argumentIsValidIndex(-1, 10, "dummy");
|
||||
}
|
||||
|
||||
public function testargumentInRangeInclusive(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('dummy is not in the valid range [0, 100]');
|
||||
Guard::argumentInRangeInclusive(101, 0, 100, "dummy");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace DNW\Skills\Tests\Numerics;
|
||||
|
||||
use DNW\Skills\Numerics\BasicMath;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BasicMathTest extends TestCase
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace DNW\Skills\Tests\Numerics;
|
||||
|
||||
use DNW\Skills\Numerics\BasicMath;
|
||||
use DNW\Skills\Numerics\GaussianDistribution;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class GaussianDistributionTest extends TestCase
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ namespace DNW\Skills\Tests\Numerics;
|
||||
use DNW\Skills\Numerics\IdentityMatrix;
|
||||
use DNW\Skills\Numerics\Matrix;
|
||||
use DNW\Skills\Numerics\SquareMatrix;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Exception;
|
||||
|
||||
// phpcs:disable PSR2.Methods.FunctionCallSignature,Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace DNW\Skills\Tests\Numerics;
|
||||
|
||||
use DNW\Skills\Numerics\Range;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Exception;
|
||||
|
||||
class RangeTest extends TestCase
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace DNW\Skills\Tests;
|
||||
|
||||
use DNW\Skills\RankSorter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RankSorterTest extends TestCase
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace DNW\Skills\Tests;
|
||||
|
||||
use DNW\Skills\Rating;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RatingTest extends TestCase
|
||||
{
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace DNW\Skills\Tests;
|
||||
|
||||
/**
|
||||
* Empty wrapper for Unittests
|
||||
*/
|
||||
class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace DNW\Skills\Tests\TrueSkill;
|
||||
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use DNW\Skills\TrueSkill\DrawMargin;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DrawMarginTest extends TestCase
|
||||
{
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
namespace DNW\Skills\Tests\TrueSkill;
|
||||
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
|
||||
use DNW\Skills\SkillCalculatorSupportedOptions;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FactorGraphTeamTrueSkillCalculatorTest extends TestCase
|
||||
{
|
||||
@ -16,4 +17,10 @@ class FactorGraphTeamTrueSkillCalculatorTest extends TestCase
|
||||
TrueSkillCalculatorTests::testAllMultipleTeamScenarios($this, $calculator);
|
||||
TrueSkillCalculatorTests::testPartialPlayScenarios($this, $calculator);
|
||||
}
|
||||
|
||||
public function testMethodisSupported(): void
|
||||
{
|
||||
$calculator = new FactorGraphTrueSkillCalculator();
|
||||
$this->assertEquals(true, $calculator->isSupported(SkillCalculatorSupportedOptions::PARTIAL_PLAY));
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace DNW\Skills\Tests\TrueSkill;
|
||||
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use DNW\Skills\GameInfo;
|
||||
use DNW\Skills\Player;
|
||||
use DNW\Skills\Team;
|
||||
use DNW\Skills\TrueSkill\FactorGraphTrueSkillCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FactorGraphTrueSkillCalculatorTest extends TestCase
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ use DNW\Skills\Rating;
|
||||
use DNW\Skills\SkillCalculator;
|
||||
use DNW\Skills\Team;
|
||||
use DNW\Skills\Teams;
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TrueSkillCalculatorTests
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace DNW\Skills\Tests\TrueSkill;
|
||||
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use DNW\Skills\TrueSkill\TwoPlayerTrueSkillCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TwoPlayerTrueSkillCalculatorTest extends TestCase
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace DNW\Skills\Tests\TrueSkill;
|
||||
|
||||
use DNW\Skills\Tests\TestCase;
|
||||
use DNW\Skills\TrueSkill\TwoTeamTrueSkillCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TwoTeamTrueSkillCalculatorTest extends TestCase
|
||||
{
|
||||
|
Reference in New Issue
Block a user