summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2025-02-10 23:45:44 +0100
committeremkael <emkael@tlen.pl>2025-02-10 23:45:44 +0100
commit45e7d06b002e0dde3dfb27b2484858b32caed7d3 (patch)
treee787376d6eb74b711c180c2e5da43671b224d765
parentf8f6cfacc2595716d67d70e1a67dce4b1bfe762e (diff)
Modernizing test suite to PHPUnit 11.x compatibility
-rw-r--r--test/ApiTest.php25
-rw-r--r--test/DoublePointsTest.php10
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 @@
<?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');
}
}
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 @@
<?php
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
require_once(dirname(__FILE__) . '/../http/api-inc.php');
-class DoublePointsTest extends TestCase {
+final class DoublePointsTest extends TestCase {
-
- /**
- * @dataProvider dataGenerator
- */
+ #[DataProvider('dataGenerator')]
public function testPointStretch($points, $players) {
$params = [
'type' => 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];