summaryrefslogtreecommitdiff
path: root/test/DoublePointsTest.php
blob: a98a5b49aef51471ed6961efc81c959908185486 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

use PHPUnit\Framework\TestCase;

require_once(dirname(__FILE__) . '/../http/api-inc.php');

class DoublePointsTest extends TestCase {


    /**
     * @dataProvider dataGenerator
     */
    public function testPointStretch($points, $players) {
        $params = [
            'type' => 2,
            'contestants' => $players,
            'manual' => [
                'min_points' => $points
            ]
        ];
        $doubleContestants = $params;
        $doubleContestants['contestants'] *= 2;
        $doubleContestantsResults = run($doubleContestants);
        $doubleContestantsResults['points'] = array_slice(
            $doubleContestantsResults['points'], 0, $players, TRUE);
        $doubleContestantsResults['sum'] = array_sum($doubleContestantsResults['points']) * 2;
        $stretchFunction = $params;
        $stretchFunction['manual']['points_cutoffs'] = [
            [0.04, 0.9], [0.4, 0.2], [1.0, 0.0]
        ];
        $stretchFunctionResults = run($stretchFunction);
        $this->assertEquals($stretchFunctionResults, $doubleContestantsResults);
    }

    public function dataGenerator() {
        for ($maxPoints = 10; $maxPoints <= 250; $maxPoints += 5) {
            for ($players = 10; $players < $maxPoints; $players += 1) {
                yield [$maxPoints, $players];
            }
        }
    }

}

?>