summaryrefslogtreecommitdiff
path: root/test/DoublePointsTest.php
blob: f94423ce0d789f91c4392c912fe1ed2e291e48f9 (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
<?php

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

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

final 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 static function dataGenerator() {
        for ($maxPoints = 10; $maxPoints <= 250; $maxPoints += 5) {
            for ($players = 10; $players < $maxPoints; $players += 1) {
                yield [$maxPoints, $players];
            }
        }
    }

}

?>