1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class LookupRefTest. |
11
|
|
|
*/ |
12
|
|
|
class LookupRefTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
public function setUp() |
15
|
|
|
{ |
16
|
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @dataProvider providerHLOOKUP |
21
|
|
|
* |
22
|
|
|
* @param mixed $expectedResult |
23
|
|
|
*/ |
24
|
|
|
public function testHLOOKUP($expectedResult, ...$args) |
25
|
|
|
{ |
26
|
|
|
$result = LookupRef::HLOOKUP(...$args); |
|
|
|
|
27
|
|
|
self::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
|
|
|
* |
38
|
|
|
* @param mixed $expectedResult |
39
|
|
|
*/ |
40
|
|
|
public function testVLOOKUP($expectedResult, ...$args) |
41
|
|
|
{ |
42
|
|
|
$result = LookupRef::VLOOKUP(...$args); |
|
|
|
|
43
|
|
|
self::assertEquals($expectedResult, $result); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function providerVLOOKUP() |
47
|
|
|
{ |
48
|
|
|
return require 'data/Calculation/LookupRef/VLOOKUP.php'; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @dataProvider providerMATCH |
53
|
|
|
* |
54
|
|
|
* @param mixed $expectedResult |
55
|
|
|
*/ |
56
|
|
|
public function testMATCH($expectedResult, ...$args) |
57
|
|
|
{ |
58
|
|
|
$result = LookupRef::MATCH(...$args); |
|
|
|
|
59
|
|
|
self::assertEquals($expectedResult, $result); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function providerMATCH() |
63
|
|
|
{ |
64
|
|
|
return require 'data/Calculation/LookupRef/MATCH.php'; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @dataProvider providerINDEX |
69
|
|
|
* |
70
|
|
|
* @param mixed $expectedResult |
71
|
|
|
*/ |
72
|
|
|
public function testINDEX($expectedResult, ...$args) |
73
|
|
|
{ |
74
|
|
|
$result = LookupRef::INDEX(...$args); |
|
|
|
|
75
|
|
|
self::assertEquals($expectedResult, $result); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function providerINDEX() |
79
|
|
|
{ |
80
|
|
|
return require 'data/Calculation/LookupRef/INDEX.php'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @dataProvider providerCOLUMNS |
85
|
|
|
* |
86
|
|
|
* @param mixed $expectedResult |
87
|
|
|
*/ |
88
|
|
|
public function testCOLUMNS($expectedResult, ...$args) |
89
|
|
|
{ |
90
|
|
|
$result = LookupRef::COLUMNS(...$args); |
|
|
|
|
91
|
|
|
self::assertEquals($expectedResult, $result); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function providerCOLUMNS() |
95
|
|
|
{ |
96
|
|
|
return require 'data/Calculation/LookupRef/COLUMNS.php'; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @dataProvider providerROWS |
101
|
|
|
* |
102
|
|
|
* @param mixed $expectedResult |
103
|
|
|
*/ |
104
|
|
|
public function testROWS($expectedResult, ...$args) |
105
|
|
|
{ |
106
|
|
|
$result = LookupRef::ROWS(...$args); |
|
|
|
|
107
|
|
|
self::assertEquals($expectedResult, $result); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function providerROWS() |
111
|
|
|
{ |
112
|
|
|
return require 'data/Calculation/LookupRef/ROWS.php'; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.