From affde2589fc09e8f25ad3ec27bd3752389ec96c6 Mon Sep 17 00:00:00 2001 From: Jens True Date: Fri, 4 Aug 2023 07:22:05 +0000 Subject: [PATCH] CodeStandards on Tests --- composer.json | 2 +- tests/Numerics/GaussianDistributionTest.php | 2 +- tests/Numerics/MatrixTest.php | 2 ++ tests/TrueSkill/DrawMarginTest.php | 2 +- tests/TrueSkill/TrueSkillCalculatorTests.php | 31 +++++++++++++++----- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 851f56f..afeb1b7 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "@analyze-psalm" ], "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" } } diff --git a/tests/Numerics/GaussianDistributionTest.php b/tests/Numerics/GaussianDistributionTest.php index 03b28aa..cdc24a8 100644 --- a/tests/Numerics/GaussianDistributionTest.php +++ b/tests/Numerics/GaussianDistributionTest.php @@ -8,7 +8,7 @@ use DNW\Skills\Tests\TestCase; class GaussianDistributionTest extends TestCase { - const ERROR_TOLERANCE = 0.000001; + private const ERROR_TOLERANCE = 0.000001; public function testCumulativeTo(): void { diff --git a/tests/Numerics/MatrixTest.php b/tests/Numerics/MatrixTest.php index 447c088..74d8054 100644 --- a/tests/Numerics/MatrixTest.php +++ b/tests/Numerics/MatrixTest.php @@ -7,6 +7,7 @@ use DNW\Skills\Numerics\Matrix; use DNW\Skills\Numerics\SquareMatrix; use DNW\Skills\Tests\TestCase; +// phpcs:disable PSR2.Methods.FunctionCallSignature,Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma class MatrixTest extends TestCase { public function testTwoByTwoDeterminant(): void @@ -185,3 +186,4 @@ class MatrixTest extends TestCase $this->assertTrue($identity3x3->equals($ccInverse)); } } +// phpcs:enable diff --git a/tests/TrueSkill/DrawMarginTest.php b/tests/TrueSkill/DrawMarginTest.php index ae773ce..c419a62 100644 --- a/tests/TrueSkill/DrawMarginTest.php +++ b/tests/TrueSkill/DrawMarginTest.php @@ -7,7 +7,7 @@ use DNW\Skills\TrueSkill\DrawMargin; class DrawMarginTest extends TestCase { - const ERROR_TOLERANCE = 0.000001; + private const ERROR_TOLERANCE = 0.000001; public function testGetDrawMarginFromDrawProbability(): void { diff --git a/tests/TrueSkill/TrueSkillCalculatorTests.php b/tests/TrueSkill/TrueSkillCalculatorTests.php index 3938ff5..9d39573 100644 --- a/tests/TrueSkill/TrueSkillCalculatorTests.php +++ b/tests/TrueSkill/TrueSkillCalculatorTests.php @@ -12,9 +12,9 @@ use DNW\Skills\Tests\TestCase; 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 @@ -849,14 +849,29 @@ class TrueSkillCalculatorTests $team16 = new Team($player16, $gameInfo->getDefaultRating()); $teams = Teams::concat( - $team1, $team2, $team3, $team4, $team5, - $team6, $team7, $team8, $team9, $team10, - $team11, $team12, $team13, $team14, $team15, - $team16); + $team1, + $team2, + $team3, + $team4, + $team5, + $team6, + $team7, + $team8, + $team9, + $team10, + $team11, + $team12, + $team13, + $team14, + $team15, + $team16 + ); $newRatings = $calculator->calculateNewRatings( - $gameInfo, $teams, - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + $gameInfo, + $teams, + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + ); $player1NewRating = $newRatings->getRating($player1); self::assertRating($testClass, 40.53945776946920, 5.27581643889050, $player1NewRating);