1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Functions; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
class StatisticalTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function setUp() |
12
|
|
|
{ |
13
|
|
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @dataProvider providerAVEDEV |
18
|
|
|
* |
19
|
|
|
* @param mixed $expectedResult |
20
|
|
|
*/ |
21
|
|
|
public function testAVEDEV($expectedResult, ...$args) |
22
|
|
|
{ |
23
|
|
|
$result = Statistical::AVEDEV(...$args); |
24
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function providerAVEDEV() |
28
|
|
|
{ |
29
|
|
|
return require 'data/Calculation/Statistical/AVEDEV.php'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @dataProvider providerAVERAGE |
34
|
|
|
* |
35
|
|
|
* @param mixed $expectedResult |
36
|
|
|
*/ |
37
|
|
|
public function testAVERAGE($expectedResult, ...$args) |
38
|
|
|
{ |
39
|
|
|
$result = Statistical::AVERAGE(...$args); |
40
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function providerAVERAGE() |
44
|
|
|
{ |
45
|
|
|
return require 'data/Calculation/Statistical/AVERAGE.php'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @dataProvider providerAVERAGEA |
50
|
|
|
* |
51
|
|
|
* @param mixed $expectedResult |
52
|
|
|
*/ |
53
|
|
|
public function testAVERAGEA($expectedResult, ...$args) |
54
|
|
|
{ |
55
|
|
|
$result = Statistical::AVERAGEA(...$args); |
56
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function providerAVERAGEA() |
60
|
|
|
{ |
61
|
|
|
return require 'data/Calculation/Statistical/AVERAGEA.php'; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @dataProvider providerAVERAGEIF |
66
|
|
|
* |
67
|
|
|
* @param mixed $expectedResult |
68
|
|
|
*/ |
69
|
|
|
public function testAVERAGEIF($expectedResult, ...$args) |
70
|
|
|
{ |
71
|
|
|
$result = Statistical::AVERAGEIF(...$args); |
72
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function providerAVERAGEIF() |
76
|
|
|
{ |
77
|
|
|
return require 'data/Calculation/Statistical/AVERAGEIF.php'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @dataProvider providerBETADIST |
82
|
|
|
* |
83
|
|
|
* @param mixed $expectedResult |
84
|
|
|
*/ |
85
|
|
|
public function testBETADIST($expectedResult, ...$args) |
86
|
|
|
{ |
87
|
|
|
$result = Statistical::BETADIST(...$args); |
88
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function providerBETADIST() |
92
|
|
|
{ |
93
|
|
|
return require 'data/Calculation/Statistical/BETADIST.php'; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @dataProvider providerBETAINV |
98
|
|
|
* |
99
|
|
|
* @param mixed $expectedResult |
100
|
|
|
*/ |
101
|
|
|
public function testBETAINV($expectedResult, ...$args) |
102
|
|
|
{ |
103
|
|
|
$result = Statistical::BETAINV(...$args); |
104
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function providerBETAINV() |
108
|
|
|
{ |
109
|
|
|
return require 'data/Calculation/Statistical/BETAINV.php'; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @dataProvider providerCOUNTIF |
114
|
|
|
* |
115
|
|
|
* @param mixed $expectedResult |
116
|
|
|
*/ |
117
|
|
|
public function testCOUNTIF($expectedResult, ...$args) |
118
|
|
|
{ |
119
|
|
|
$result = Statistical::COUNTIF(...$args); |
120
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function providerCOUNTIF() |
124
|
|
|
{ |
125
|
|
|
return require 'data/Calculation/Statistical/COUNTIF.php'; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @dataProvider providerCOUNTIFS |
130
|
|
|
* |
131
|
|
|
* @param mixed $expectedResult |
132
|
|
|
*/ |
133
|
|
|
public function testCOUNTIFS($expectedResult, ...$args) |
134
|
|
|
{ |
135
|
|
|
$result = Statistical::COUNTIFS(...$args); |
136
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function providerCOUNTIFS() |
140
|
|
|
{ |
141
|
|
|
return require 'data/Calculation/Statistical/COUNTIFS.php'; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @dataProvider providerMAXIFS |
146
|
|
|
* |
147
|
|
|
* @param mixed $expectedResult |
148
|
|
|
*/ |
149
|
|
|
public function testMAXIFS($expectedResult, ...$args) |
150
|
|
|
{ |
151
|
|
|
$result = Statistical::MAXIFS(...$args); |
152
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function providerMAXIFS() |
156
|
|
|
{ |
157
|
|
|
return require 'data/Calculation/Statistical/MAXIFS.php'; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @dataProvider providerMINIFS |
162
|
|
|
* |
163
|
|
|
* @param mixed $expectedResult |
164
|
|
|
*/ |
165
|
|
|
public function testMINIFS($expectedResult, ...$args) |
166
|
|
|
{ |
167
|
|
|
$result = Statistical::MINIFS(...$args); |
168
|
|
|
self::assertEquals($expectedResult, $result, '', 1E-12); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
public function providerMINIFS() |
172
|
|
|
{ |
173
|
|
|
return require 'data/Calculation/Statistical/MINIFS.php'; |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|