diff options
author | emkael <emkael@tlen.pl> | 2025-02-10 23:45:44 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2025-02-10 23:45:44 +0100 |
commit | 45e7d06b002e0dde3dfb27b2484858b32caed7d3 (patch) | |
tree | e787376d6eb74b711c180c2e5da43671b224d765 /test/ApiTest.php | |
parent | f8f6cfacc2595716d67d70e1a67dce4b1bfe762e (diff) |
Modernizing test suite to PHPUnit 11.x compatibility
Diffstat (limited to 'test/ApiTest.php')
-rw-r--r-- | test/ApiTest.php | 25 |
1 files changed, 10 insertions, 15 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 @@ <?php +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -class ApiTest extends TestCase { +final class ApiTest extends TestCase { private function _doTest($input, $expected) { require_once(dirname(__FILE__) . '/../http/api-inc.php'); @@ -15,30 +16,24 @@ class ApiTest extends TestCase { } } - /** - * @dataProvider generatedDataProvider - */ + #[DataProvider('generatedDataProvider')] public function testRandomResults($input, $expected) { $this->_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'); } } |