CodeStandards on Tests

This commit is contained in:
Jens True 2023-08-04 07:22:05 +00:00
parent 9acc3bbeab
commit affde2589f
5 changed files with 28 additions and 11 deletions

@ -32,7 +32,7 @@
"@analyze-psalm" "@analyze-psalm"
], ],
"analyze-phpstan":"vendor/bin/phpstan analyze --error-format=raw", "analyze-phpstan":"vendor/bin/phpstan analyze --error-format=raw",
"analyze-phpcs": "vendor/bin/phpcs --report=emacs --standard=PSR12 --exclude=Generic.Files.LineLength src", "analyze-phpcs": "vendor/bin/phpcs --report=emacs --standard=PSR12 --exclude=Generic.Files.LineLength src tests",
"analyze-psalm": "vendor/bin/psalm" "analyze-psalm": "vendor/bin/psalm"
} }
} }

@ -8,7 +8,7 @@ use DNW\Skills\Tests\TestCase;
class GaussianDistributionTest extends TestCase class GaussianDistributionTest extends TestCase
{ {
const ERROR_TOLERANCE = 0.000001; private const ERROR_TOLERANCE = 0.000001;
public function testCumulativeTo(): void public function testCumulativeTo(): void
{ {

@ -7,6 +7,7 @@ use DNW\Skills\Numerics\Matrix;
use DNW\Skills\Numerics\SquareMatrix; use DNW\Skills\Numerics\SquareMatrix;
use DNW\Skills\Tests\TestCase; use DNW\Skills\Tests\TestCase;
// phpcs:disable PSR2.Methods.FunctionCallSignature,Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma
class MatrixTest extends TestCase class MatrixTest extends TestCase
{ {
public function testTwoByTwoDeterminant(): void public function testTwoByTwoDeterminant(): void
@ -185,3 +186,4 @@ class MatrixTest extends TestCase
$this->assertTrue($identity3x3->equals($ccInverse)); $this->assertTrue($identity3x3->equals($ccInverse));
} }
} }
// phpcs:enable

@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\DrawMargin;
class DrawMarginTest extends TestCase class DrawMarginTest extends TestCase
{ {
const ERROR_TOLERANCE = 0.000001; private const ERROR_TOLERANCE = 0.000001;
public function testGetDrawMarginFromDrawProbability(): void public function testGetDrawMarginFromDrawProbability(): void
{ {

@ -12,9 +12,9 @@ use DNW\Skills\Tests\TestCase;
class TrueSkillCalculatorTests class TrueSkillCalculatorTests
{ {
const ERROR_TOLERANCE_TRUESKILL = 0.085; private const ERROR_TOLERANCE_TRUESKILL = 0.085;
const ERROR_TOLERANCE_MATCH_QUALITY = 0.0005; private const ERROR_TOLERANCE_MATCH_QUALITY = 0.0005;
// These are the roll-up ones // These are the roll-up ones
@ -849,14 +849,29 @@ class TrueSkillCalculatorTests
$team16 = new Team($player16, $gameInfo->getDefaultRating()); $team16 = new Team($player16, $gameInfo->getDefaultRating());
$teams = Teams::concat( $teams = Teams::concat(
$team1, $team2, $team3, $team4, $team5, $team1,
$team6, $team7, $team8, $team9, $team10, $team2,
$team11, $team12, $team13, $team14, $team15, $team3,
$team16); $team4,
$team5,
$team6,
$team7,
$team8,
$team9,
$team10,
$team11,
$team12,
$team13,
$team14,
$team15,
$team16
);
$newRatings = $calculator->calculateNewRatings( $newRatings = $calculator->calculateNewRatings(
$gameInfo, $teams, $gameInfo,
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); $teams,
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
);
$player1NewRating = $newRatings->getRating($player1); $player1NewRating = $newRatings->getRating($player1);
self::assertRating($testClass, 40.53945776946920, 5.27581643889050, $player1NewRating); self::assertRating($testClass, 40.53945776946920, 5.27581643889050, $player1NewRating);