From 45e7d06b002e0dde3dfb27b2484858b32caed7d3 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 10 Feb 2025 23:45:44 +0100 Subject: Modernizing test suite to PHPUnit 11.x compatibility --- test/ApiTest.php | 25 ++++++++++--------------- test/DoublePointsTest.php | 10 ++++------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/test/ApiTest.php b/test/ApiTest.php index 0a8290c..0786af0 100644 --- a/test/ApiTest.php +++ b/test/ApiTest.php @@ -1,8 +1,9 @@ _doTest($input, $expected); } - /** - * @dataProvider generatedDataProvider - */ + #[DataProvider('generatedDataProvider')] public function testBoardCounts($input, $expected) { $input['boards'] = strval($input['over39_boards'] ? rand(40, 60) : rand(1, 39)); unset($input['over39_boards']); $this->_doTest($input, $expected); } - /** - * @dataProvider bridgenetDataProvider - */ + #[DataProvider('bridgenetDataProvider')] public function testBridgenet($input, $expected) { $this->_doTest($input, $expected); } - private function _fileDataProvider($file) { + private static function _fileDataProvider($file) { $contents = file(dirname(__FILE__) . '/' . $file); $count = count($contents); for ($i = 0; $i < $count; $i += 2) { @@ -48,12 +43,12 @@ class ApiTest extends TestCase { } } - public function generatedDataProvider() { - yield from $this->_fileDataProvider('tests.txt'); + public static function generatedDataProvider() { + yield from self::_fileDataProvider('tests.txt'); } - public function bridgenetDataProvider() { - yield from $this->_fileDataProvider('bridgenet.txt'); + public static function bridgenetDataProvider() { + yield from self::_fileDataProvider('bridgenet.txt'); } } diff --git a/test/DoublePointsTest.php b/test/DoublePointsTest.php index a98a5b4..f94423c 100644 --- a/test/DoublePointsTest.php +++ b/test/DoublePointsTest.php @@ -1,15 +1,13 @@ 2, @@ -32,7 +30,7 @@ class DoublePointsTest extends TestCase { $this->assertEquals($stretchFunctionResults, $doubleContestantsResults); } - public function dataGenerator() { + public static function dataGenerator() { for ($maxPoints = 10; $maxPoints <= 250; $maxPoints += 5) { for ($players = 10; $players < $maxPoints; $players += 1) { yield [$maxPoints, $players]; -- cgit v1.2.3