Completed
Push — master ( ac41f4...7a5cb9 )
by Hannes
02:54
created

LambdaInterpolationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 33
rs 10
1
<?php
2
3
/*
4
 * This file is part of the Runalyze DEM Reader.
5
 *
6
 * (c) RUNALYZE <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Runalyze\DEM\Tests\Interpolation;
13
14
use Runalyze\DEM\Interpolation\LambdaInterpolation;
15
16
class LambdaInterpolationTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @expectedException InvalidArgumentException
20
     */
21
    public function testInvalidClosure()
22
    {
23
        new LambdaInterpolation(function () {
24
            return 1;
25
        });
26
    }
27
28
    /**
29
     * @expectedException InvalidArgumentException
30
     */
31
    public function testThatInvalidCallsAreDetected()
32
    {
33
        $Interpolation = new LambdaInterpolation(function ($x, $y, array $elevationOnBoundingBox) {
34
            return 1;
35
        });
36
37
        $Interpolation->interpolate(0.5, 0.14, [1, 2, 3]);
38
    }
39
40
    public function testConstantClosure()
41
    {
42
        $Interpolation = new LambdaInterpolation(function ($x, $y, array $elevationOnBoundingBox) {
43
            return 42;
44
        });
45
46
        $this->assertEquals(42, $Interpolation->interpolate(0.314, 0.42, [100, 100, 100, 100]));
47
    }
48
}
49