Passed
Push — develop ( ed2185...e3fb16 )
by Adrien
34:19
created

FunctionsTest::providerIfCondition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
6
use PhpOffice\PhpSpreadsheet\Cell\Cell;
7
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
8
use PHPUnit\Framework\TestCase;
9
10
class FunctionsTest extends TestCase
11
{
12
    public function setUp()
13
    {
14
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
15
    }
16
17
    public function testDUMMY()
18
    {
19
        $result = Functions::DUMMY();
20
        self::assertEquals('#Not Yet Implemented', $result);
21
    }
22
23
    public function testDIV0()
24
    {
25
        $result = Functions::DIV0();
26
        self::assertEquals('#DIV/0!', $result);
27
    }
28
29
    public function testNA()
30
    {
31
        $result = Functions::NA();
32
        self::assertEquals('#N/A', $result);
33
    }
34
35
    public function testNAN()
36
    {
37
        $result = Functions::NAN();
38
        self::assertEquals('#NUM!', $result);
39
    }
40
41
    public function testNAME()
42
    {
43
        $result = Functions::NAME();
44
        self::assertEquals('#NAME?', $result);
45
    }
46
47
    public function testREF()
48
    {
49
        $result = Functions::REF();
50
        self::assertEquals('#REF!', $result);
51
    }
52
53
    public function testNULL()
54
    {
55
        $result = Functions::null();
56
        self::assertEquals('#NULL!', $result);
57
    }
58
59
    public function testVALUE()
60
    {
61
        $result = Functions::VALUE();
62
        self::assertEquals('#VALUE!', $result);
63
    }
64
65
    /**
66
     * @dataProvider providerIsBlank
67
     *
68
     * @param mixed $expectedResult
69
     */
70
    public function testIsBlank($expectedResult, ...$args)
71
    {
72
        $result = Functions::isBlank(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...on\Functions::isBlank() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
        $result = Functions::isBlank(/** @scrutinizer ignore-type */ ...$args);
Loading history...
73
        self::assertEquals($expectedResult, $result, null, 1E-8);
74
    }
75
76
    public function providerIsBlank()
77
    {
78
        return require 'data/Calculation/Functions/IS_BLANK.php';
79
    }
80
81
    /**
82
     * @dataProvider providerIsErr
83
     *
84
     * @param mixed $expectedResult
85
     */
86
    public function testIsErr($expectedResult, ...$args)
87
    {
88
        $result = Functions::isErr(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...tion\Functions::isErr() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
        $result = Functions::isErr(/** @scrutinizer ignore-type */ ...$args);
Loading history...
89
        self::assertEquals($expectedResult, $result, null, 1E-8);
90
    }
91
92
    public function providerIsErr()
93
    {
94
        return require 'data/Calculation/Functions/IS_ERR.php';
95
    }
96
97
    /**
98
     * @dataProvider providerIsError
99
     *
100
     * @param mixed $expectedResult
101
     */
102
    public function testIsError($expectedResult, ...$args)
103
    {
104
        $result = Functions::isError(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...on\Functions::isError() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

104
        $result = Functions::isError(/** @scrutinizer ignore-type */ ...$args);
Loading history...
105
        self::assertEquals($expectedResult, $result, null, 1E-8);
106
    }
107
108
    public function providerIsError()
109
    {
110
        return require 'data/Calculation/Functions/IS_ERROR.php';
111
    }
112
113
    /**
114
     * @dataProvider providerErrorType
115
     *
116
     * @param mixed $expectedResult
117
     */
118
    public function testErrorType($expectedResult, ...$args)
119
    {
120
        $result = Functions::errorType(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...\Functions::errorType() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

120
        $result = Functions::errorType(/** @scrutinizer ignore-type */ ...$args);
Loading history...
121
        self::assertEquals($expectedResult, $result, null, 1E-8);
122
    }
123
124
    public function providerErrorType()
125
    {
126
        return require 'data/Calculation/Functions/ERROR_TYPE.php';
127
    }
128
129
    /**
130
     * @dataProvider providerIsLogical
131
     *
132
     * @param mixed $expectedResult
133
     */
134
    public function testIsLogical($expectedResult, ...$args)
135
    {
136
        $result = Functions::isLogical(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...\Functions::isLogical() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

136
        $result = Functions::isLogical(/** @scrutinizer ignore-type */ ...$args);
Loading history...
137
        self::assertEquals($expectedResult, $result, null, 1E-8);
138
    }
139
140
    public function providerIsLogical()
141
    {
142
        return require 'data/Calculation/Functions/IS_LOGICAL.php';
143
    }
144
145
    /**
146
     * @dataProvider providerIsNa
147
     *
148
     * @param mixed $expectedResult
149
     */
150
    public function testIsNa($expectedResult, ...$args)
151
    {
152
        $result = Functions::isNa(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ation\Functions::isNa() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

152
        $result = Functions::isNa(/** @scrutinizer ignore-type */ ...$args);
Loading history...
153
        self::assertEquals($expectedResult, $result, null, 1E-8);
154
    }
155
156
    public function providerIsNa()
157
    {
158
        return require 'data/Calculation/Functions/IS_NA.php';
159
    }
160
161
    /**
162
     * @dataProvider providerIsNumber
163
     *
164
     * @param mixed $expectedResult
165
     */
166
    public function testIsNumber($expectedResult, ...$args)
167
    {
168
        $result = Functions::isNumber(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...n\Functions::isNumber() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

168
        $result = Functions::isNumber(/** @scrutinizer ignore-type */ ...$args);
Loading history...
169
        self::assertEquals($expectedResult, $result, null, 1E-8);
170
    }
171
172
    public function providerIsNumber()
173
    {
174
        return require 'data/Calculation/Functions/IS_NUMBER.php';
175
    }
176
177
    /**
178
     * @dataProvider providerIsText
179
     *
180
     * @param mixed $expectedResult
181
     */
182
    public function testIsText($expectedResult, ...$args)
183
    {
184
        $result = Functions::isText(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ion\Functions::isText() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

184
        $result = Functions::isText(/** @scrutinizer ignore-type */ ...$args);
Loading history...
185
        self::assertEquals($expectedResult, $result, null, 1E-8);
186
    }
187
188
    public function providerIsText()
189
    {
190
        return require 'data/Calculation/Functions/IS_TEXT.php';
191
    }
192
193
    /**
194
     * @dataProvider providerIsNonText
195
     *
196
     * @param mixed $expectedResult
197
     */
198
    public function testIsNonText($expectedResult, ...$args)
199
    {
200
        $result = Functions::isNonText(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...\Functions::isNonText() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

200
        $result = Functions::isNonText(/** @scrutinizer ignore-type */ ...$args);
Loading history...
201
        self::assertEquals($expectedResult, $result, null, 1E-8);
202
    }
203
204
    public function providerIsNonText()
205
    {
206
        return require 'data/Calculation/Functions/IS_NONTEXT.php';
207
    }
208
209
    /**
210
     * @dataProvider providerIsEven
211
     *
212
     * @param mixed $expectedResult
213
     */
214
    public function testIsEven($expectedResult, ...$args)
215
    {
216
        $result = Functions::isEven(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ion\Functions::isEven() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

216
        $result = Functions::isEven(/** @scrutinizer ignore-type */ ...$args);
Loading history...
217
        self::assertEquals($expectedResult, $result, null, 1E-8);
218
    }
219
220
    public function providerIsEven()
221
    {
222
        return require 'data/Calculation/Functions/IS_EVEN.php';
223
    }
224
225
    /**
226
     * @dataProvider providerIsOdd
227
     *
228
     * @param mixed $expectedResult
229
     */
230
    public function testIsOdd($expectedResult, ...$args)
231
    {
232
        $result = Functions::isOdd(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...tion\Functions::isOdd() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

232
        $result = Functions::isOdd(/** @scrutinizer ignore-type */ ...$args);
Loading history...
233
        self::assertEquals($expectedResult, $result, null, 1E-8);
234
    }
235
236
    public function providerIsOdd()
237
    {
238
        return require 'data/Calculation/Functions/IS_ODD.php';
239
    }
240
241
    /**
242
     * @dataProvider providerTYPE
243
     *
244
     * @param mixed $expectedResult
245
     */
246
    public function testTYPE($expectedResult, ...$args)
247
    {
248
        $result = Functions::TYPE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ation\Functions::TYPE() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

248
        $result = Functions::TYPE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
249
        self::assertEquals($expectedResult, $result, null, 1E-8);
250
    }
251
252
    public function providerTYPE()
253
    {
254
        return require 'data/Calculation/Functions/TYPE.php';
255
    }
256
257
    /**
258
     * @dataProvider providerN
259
     *
260
     * @param mixed $expectedResult
261
     */
262
    public function testN($expectedResult, ...$args)
263
    {
264
        $result = Functions::n(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...culation\Functions::n() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

264
        $result = Functions::n(/** @scrutinizer ignore-type */ ...$args);
Loading history...
265
        self::assertEquals($expectedResult, $result, null, 1E-8);
266
    }
267
268
    public function providerN()
269
    {
270
        return require 'data/Calculation/Functions/N.php';
271
    }
272
273
    /**
274
     * @dataProvider providerIsFormula
275
     *
276
     * @param mixed $expectedResult
277
     * @param mixed $value
278
     */
279
    public function testIsFormula($expectedResult, $value = 'undefined')
280
    {
281
        $ourCell = null;
282
        if ($value !== 'undefined') {
283
            $remoteCell = $this->getMockBuilder(Cell::class)
284
                ->disableOriginalConstructor()
285
                ->getMock();
286
            $remoteCell->method('getValue')
287
                ->will($this->returnValue($value));
288
289
            $sheet = $this->getMockBuilder(Worksheet::class)
290
                ->disableOriginalConstructor()
291
                ->getMock();
292
            $sheet->method('getCell')
293
                ->will($this->returnValue($remoteCell));
294
295
            $ourCell = $this->getMockBuilder(Cell::class)
296
                ->disableOriginalConstructor()
297
                ->getMock();
298
            $ourCell->method('getWorksheet')
299
                ->will($this->returnValue($sheet));
300
        }
301
302
        $result = Functions::isFormula($value, $ourCell);
303
        self::assertEquals($expectedResult, $result, null, 1E-8);
304
    }
305
306
    public function providerIsFormula()
307
    {
308
        return require 'data/Calculation/Functions/ISFORMULA.php';
309
    }
310
311
    /**
312
     * @dataProvider providerIfCondition
313
     *
314
     * @param mixed $expectedResult
315
     */
316
    public function testIfCondition($expectedResult, ...$args)
317
    {
318
        $result = Functions::ifCondition(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $condition of PhpOffice\PhpSpreadsheet...unctions::ifCondition() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

318
        $result = Functions::ifCondition(/** @scrutinizer ignore-type */ ...$args);
Loading history...
319
        self::assertEquals($expectedResult, $result);
320
    }
321
322
    public function providerIfCondition()
323
    {
324
        return require 'data/Calculation/Functions/IF_CONDITION.php';
325
    }
326
}
327