File size: 910 Bytes
a612fa9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php

namespace Piwik\Plugins\ImageGraph\tests\Unit;

use Piwik\Plugins\ImageGraph\API;
use ReflectionMethod;

/**
 * @group ImageGraph
 * @group APITest
 */
class APITest extends \PHPUnit\Framework\TestCase
{
    /**
     * @dataProvider getOrdinateValuesToParse
     */
    public function testParseOrdinateValueReturnsFloat($value, float $expected): void
    {
        $method = new ReflectionMethod(API::class, 'parseOrdinateValue');

        if (PHP_VERSION_ID < 80100) {
            $method->setAccessible(true);
        }

        $actual = $method->invoke(null, $value);

        $this->assertIsFloat($actual);
        $this->assertSame($expected, $actual);
    }

    public function getOrdinateValuesToParse(): array
    {
        return [
            [2.05, 2.05],
            ['2.05', 2.05],
            [205, 205.0],
            ['01:02:03.50', 3723.5],
            ['', 0.0],
        ];
    }
}