diff options
Diffstat (limited to 'test/ApiTest.php')
-rw-r--r-- | test/ApiTest.php | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/test/ApiTest.php b/test/ApiTest.php index 158c9dc..0a8290c 100644 --- a/test/ApiTest.php +++ b/test/ApiTest.php @@ -4,10 +4,7 @@ use PHPUnit\Framework\TestCase; class ApiTest extends TestCase { - /** - * @dataProvider generatedDataProvider - */ - public function testRandomResults($input, $expected) { + private function _doTest($input, $expected) { require_once(dirname(__FILE__) . '/../http/api-inc.php'); if (is_string($expected)) { $this->expectException(ParametersException::class); @@ -21,15 +18,29 @@ class ApiTest extends TestCase { /** * @dataProvider generatedDataProvider */ + public function testRandomResults($input, $expected) { + $this->_doTest($input, $expected); + } + + /** + * @dataProvider generatedDataProvider + */ public function testBoardCounts($input, $expected) { $input['boards'] = strval($input['over39_boards'] ? rand(40, 60) : rand(1, 39)); unset($input['over39_boards']); - $this->testRandomResults($input, $expected); + $this->_doTest($input, $expected); } - public function generatedDataProvider() { - $contents = file(dirname(__FILE__) . '/tests.txt'); - $count = count($contents) / 2; + /** + * @dataProvider bridgenetDataProvider + */ + public function testBridgenet($input, $expected) { + $this->_doTest($input, $expected); + } + + private function _fileDataProvider($file) { + $contents = file(dirname(__FILE__) . '/' . $file); + $count = count($contents); for ($i = 0; $i < $count; $i += 2) { $input = []; parse_str(http_build_query(json_decode($contents[$i], TRUE)), $input); @@ -37,6 +48,14 @@ class ApiTest extends TestCase { } } + public function generatedDataProvider() { + yield from $this->_fileDataProvider('tests.txt'); + } + + public function bridgenetDataProvider() { + yield from $this->_fileDataProvider('bridgenet.txt'); + } + } ?> |