Completed
Push — develop ( 7fd5ee...fd83c1 )
by Adrien
17:00
created

LookupRefTest::testMATCH()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
6
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
7
8
/**
9
 * Class LookupRefTest.
10
 */
11
class LookupRefTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function setUp()
14
    {
15
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
16
    }
17
18
    /**
19
     * @dataProvider providerHLOOKUP
20
     * @group fail19
21
     *
22
     * @param mixed $expectedResult
23
     */
24
    public function testHLOOKUP($expectedResult, ...$args)
25
    {
26
        $result = LookupRef::HLOOKUP(...$args);
0 ignored issues
show
Bug introduced by
The call to HLOOKUP() misses some required arguments starting with $lookup_array.
Loading history...
Documentation introduced by
$args is of type array<integer,?>, but the function expects a object<PhpOffice\PhpSpreadsheet\Calculation\The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
        $this->assertEquals($expectedResult, $result);
28
    }
29
30
    public function providerHLOOKUP()
31
    {
32
        return require 'data/Calculation/LookupRef/HLOOKUP.php';
33
    }
34
35
    /**
36
     * @dataProvider providerVLOOKUP
37
     * @group fail19
38
     *
39
     * @param mixed $expectedResult
40
     */
41
    public function testVLOOKUP($expectedResult, ...$args)
42
    {
43
        $result = LookupRef::VLOOKUP(...$args);
0 ignored issues
show
Bug introduced by
The call to VLOOKUP() misses some required arguments starting with $lookup_array.
Loading history...
Documentation introduced by
$args is of type array<integer,?>, but the function expects a object<PhpOffice\PhpSpreadsheet\Calculation\The>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44
        $this->assertEquals($expectedResult, $result);
45
    }
46
47
    public function providerVLOOKUP()
48
    {
49
        return require 'data/Calculation/LookupRef/VLOOKUP.php';
50
    }
51
52
    /**
53
     * @dataProvider providerMATCH
54
     * @group fail19
55
     *
56
     * @param mixed $expectedResult
57
     */
58
    public function testMATCH($expectedResult, ...$args)
59
    {
60
        $result = LookupRef::MATCH(...$args);
0 ignored issues
show
Bug introduced by
The call to MATCH() misses a required argument $lookupArray.

This check looks for function calls that miss required arguments.

Loading history...
61
        $this->assertEquals($expectedResult, $result);
62
    }
63
64
    public function providerMATCH()
65
    {
66
        return require 'data/Calculation/LookupRef/MATCH.php';
67
    }
68
}
69