summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http/api-inc.php16
-rw-r--r--test/ApiTest.php9
2 files changed, 24 insertions, 1 deletions
diff --git a/http/api-inc.php b/http/api-inc.php
index c2336af..9cac20e 100644
--- a/http/api-inc.php
+++ b/http/api-inc.php
@@ -235,6 +235,20 @@ class ApiPklV2 extends ApiPklV1 {
}
-class ApiPklV3 extends ApiPklV2 {}
+class ApiPklV3 extends ApiPklV2 {
+
+ function check_parameters() {
+ if (!isset($this->parameters['manual']) || !isset($this->parameters['manual']['min_points']) || !isset($this->parameters['manual']['tournament_weight'])) {
+ if (isset($this->parameters['boards'])) {
+ $this->check_values($this->parameters, array(
+ 'boards' => function($r) { return ctype_digit($r); }
+ ));
+ $this->parameters['over39_boards'] = strval(intval($this->parameters['boards'] > 39));
+ }
+ }
+ return parent::check_parameters();
+ }
+
+}
?>
diff --git a/test/ApiTest.php b/test/ApiTest.php
index 93ed024..158c9dc 100644
--- a/test/ApiTest.php
+++ b/test/ApiTest.php
@@ -18,6 +18,15 @@ class ApiTest extends TestCase {
}
}
+ /**
+ * @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);
+ }
+
public function generatedDataProvider() {
$contents = file(dirname(__FILE__) . '/tests.txt');
$count = count($contents) / 2;