diff options
Diffstat (limited to 'test/ApiTest.php')
-rw-r--r-- | test/ApiTest.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ApiTest.php b/test/ApiTest.php new file mode 100644 index 0000000..93ed024 --- /dev/null +++ b/test/ApiTest.php @@ -0,0 +1,33 @@ +<?php + +use PHPUnit\Framework\TestCase; + +class ApiTest extends TestCase { + + /** + * @dataProvider generatedDataProvider + */ + public function testRandomResults($input, $expected) { + require_once(dirname(__FILE__) . '/../http/api-inc.php'); + if (is_string($expected)) { + $this->expectException(ParametersException::class); + run($input); + } else { + $output = run($input); + $this->assertEquals($expected, $output); + } + } + + public function generatedDataProvider() { + $contents = file(dirname(__FILE__) . '/tests.txt'); + $count = count($contents) / 2; + for ($i = 0; $i < $count; $i += 2) { + $input = []; + parse_str(http_build_query(json_decode($contents[$i], TRUE)), $input); + yield [$input, json_decode($contents[$i+1], TRUE)]; + } + } + +} + +?> |