Passed
Push — develop ( ed6a3a...98d104 )
by Adrien
43:30 queued 16:18
created

MathTrigTest::testNestedSUBTOTAL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 33
nc 1
nop 2
dl 0
loc 42
rs 9.392
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
6
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
8
use PhpOffice\PhpSpreadsheet\Cell\Cell;
9
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension;
10
use PhpOffice\PhpSpreadsheet\Worksheet\RowDimension;
11
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
12
use PHPUnit\Framework\TestCase;
13
14
class MathTrigTest extends TestCase
15
{
16
    public function setUp()
17
    {
18
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
19
    }
20
21
    /**
22
     * @dataProvider providerATAN2
23
     *
24
     * @param mixed $expectedResult
25
     */
26
    public function testATAN2($expectedResult, ...$args)
27
    {
28
        $result = MathTrig::ATAN2(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $xCoordinate of PhpOffice\PhpSpreadsheet...ation\MathTrig::ATAN2() 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

28
        $result = MathTrig::ATAN2(/** @scrutinizer ignore-type */ ...$args);
Loading history...
29
        self::assertEquals($expectedResult, $result, null, 1E-12);
30
    }
31
32
    public function providerATAN2()
33
    {
34
        return require 'data/Calculation/MathTrig/ATAN2.php';
35
    }
36
37
    /**
38
     * @dataProvider providerCEILING
39
     *
40
     * @param mixed $expectedResult
41
     */
42
    public function testCEILING($expectedResult, ...$args)
43
    {
44
        $result = MathTrig::CEILING(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...ion\MathTrig::CEILING() 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

44
        $result = MathTrig::CEILING(/** @scrutinizer ignore-type */ ...$args);
Loading history...
45
        self::assertEquals($expectedResult, $result, null, 1E-12);
46
    }
47
48
    public function providerCEILING()
49
    {
50
        return require 'data/Calculation/MathTrig/CEILING.php';
51
    }
52
53
    /**
54
     * @dataProvider providerCOMBIN
55
     *
56
     * @param mixed $expectedResult
57
     */
58
    public function testCOMBIN($expectedResult, ...$args)
59
    {
60
        $result = MathTrig::COMBIN(...$args);
61
        self::assertEquals($expectedResult, $result, null, 1E-12);
62
    }
63
64
    public function providerCOMBIN()
65
    {
66
        return require 'data/Calculation/MathTrig/COMBIN.php';
67
    }
68
69
    /**
70
     * @dataProvider providerEVEN
71
     *
72
     * @param mixed $expectedResult
73
     */
74
    public function testEVEN($expectedResult, ...$args)
75
    {
76
        $result = MathTrig::EVEN(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...lation\MathTrig::EVEN() 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

76
        $result = MathTrig::EVEN(/** @scrutinizer ignore-type */ ...$args);
Loading history...
77
        self::assertEquals($expectedResult, $result, null, 1E-12);
78
    }
79
80
    public function providerEVEN()
81
    {
82
        return require 'data/Calculation/MathTrig/EVEN.php';
83
    }
84
85
    /**
86
     * @dataProvider providerODD
87
     *
88
     * @param mixed $expectedResult
89
     */
90
    public function testODD($expectedResult, ...$args)
91
    {
92
        $result = MathTrig::ODD(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...ulation\MathTrig::ODD() 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

92
        $result = MathTrig::ODD(/** @scrutinizer ignore-type */ ...$args);
Loading history...
93
        self::assertEquals($expectedResult, $result, null, 1E-12);
94
    }
95
96
    public function providerODD()
97
    {
98
        return require 'data/Calculation/MathTrig/ODD.php';
99
    }
100
101
    /**
102
     * @dataProvider providerFACT
103
     *
104
     * @param mixed $expectedResult
105
     */
106
    public function testFACT($expectedResult, ...$args)
107
    {
108
        $result = MathTrig::FACT(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $factVal of PhpOffice\PhpSpreadsheet...lation\MathTrig::FACT() 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

108
        $result = MathTrig::FACT(/** @scrutinizer ignore-type */ ...$args);
Loading history...
109
        self::assertEquals($expectedResult, $result, null, 1E-12);
110
    }
111
112
    public function providerFACT()
113
    {
114
        return require 'data/Calculation/MathTrig/FACT.php';
115
    }
116
117
    /**
118
     * @dataProvider providerFACTDOUBLE
119
     *
120
     * @param mixed $expectedResult
121
     */
122
    public function testFACTDOUBLE($expectedResult, ...$args)
123
    {
124
        $result = MathTrig::FACTDOUBLE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $factVal of PhpOffice\PhpSpreadsheet...\MathTrig::FACTDOUBLE() 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

124
        $result = MathTrig::FACTDOUBLE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
125
        self::assertEquals($expectedResult, $result, null, 1E-12);
126
    }
127
128
    public function providerFACTDOUBLE()
129
    {
130
        return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
131
    }
132
133
    /**
134
     * @dataProvider providerFLOOR
135
     *
136
     * @param mixed $expectedResult
137
     */
138
    public function testFLOOR($expectedResult, ...$args)
139
    {
140
        $result = MathTrig::FLOOR(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...ation\MathTrig::FLOOR() 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

140
        $result = MathTrig::FLOOR(/** @scrutinizer ignore-type */ ...$args);
Loading history...
141
        self::assertEquals($expectedResult, $result, null, 1E-12);
142
    }
143
144
    public function providerFLOOR()
145
    {
146
        return require 'data/Calculation/MathTrig/FLOOR.php';
147
    }
148
149
    /**
150
     * @dataProvider providerGCD
151
     *
152
     * @param mixed $expectedResult
153
     */
154
    public function testGCD($expectedResult, ...$args)
155
    {
156
        $result = MathTrig::GCD(...$args);
157
        self::assertEquals($expectedResult, $result, null, 1E-12);
158
    }
159
160
    public function providerGCD()
161
    {
162
        return require 'data/Calculation/MathTrig/GCD.php';
163
    }
164
165
    /**
166
     * @dataProvider providerLCM
167
     *
168
     * @param mixed $expectedResult
169
     */
170
    public function testLCM($expectedResult, ...$args)
171
    {
172
        $result = MathTrig::LCM(...$args);
173
        self::assertEquals($expectedResult, $result, null, 1E-12);
174
    }
175
176
    public function providerLCM()
177
    {
178
        return require 'data/Calculation/MathTrig/LCM.php';
179
    }
180
181
    /**
182
     * @dataProvider providerINT
183
     *
184
     * @param mixed $expectedResult
185
     */
186
    public function testINT($expectedResult, ...$args)
187
    {
188
        $result = MathTrig::INT(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...ulation\MathTrig::INT() 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

188
        $result = MathTrig::INT(/** @scrutinizer ignore-type */ ...$args);
Loading history...
189
        self::assertEquals($expectedResult, $result);
190
    }
191
192
    public function providerINT()
193
    {
194
        return require 'data/Calculation/MathTrig/INT.php';
195
    }
196
197
    /**
198
     * @dataProvider providerSIGN
199
     *
200
     * @param mixed $expectedResult
201
     */
202
    public function testSIGN($expectedResult, ...$args)
203
    {
204
        $result = MathTrig::SIGN(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...lation\MathTrig::SIGN() 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

204
        $result = MathTrig::SIGN(/** @scrutinizer ignore-type */ ...$args);
Loading history...
205
        self::assertEquals($expectedResult, $result, null, 1E-12);
206
    }
207
208
    public function providerSIGN()
209
    {
210
        return require 'data/Calculation/MathTrig/SIGN.php';
211
    }
212
213
    /**
214
     * @dataProvider providerPOWER
215
     *
216
     * @param mixed $expectedResult
217
     */
218
    public function testPOWER($expectedResult, ...$args)
219
    {
220
        $result = MathTrig::POWER(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $x of PhpOffice\PhpSpreadsheet...ation\MathTrig::POWER() 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

220
        $result = MathTrig::POWER(/** @scrutinizer ignore-type */ ...$args);
Loading history...
221
        self::assertEquals($expectedResult, $result, null, 1E-12);
222
    }
223
224
    public function providerPOWER()
225
    {
226
        return require 'data/Calculation/MathTrig/POWER.php';
227
    }
228
229
    /**
230
     * @dataProvider providerLOG
231
     *
232
     * @param mixed $expectedResult
233
     */
234
    public function testLOG($expectedResult, ...$args)
235
    {
236
        $result = MathTrig::logBase(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...ion\MathTrig::logBase() 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

236
        $result = MathTrig::logBase(/** @scrutinizer ignore-type */ ...$args);
Loading history...
237
        self::assertEquals($expectedResult, $result, null, 1E-12);
238
    }
239
240
    public function providerLOG()
241
    {
242
        return require 'data/Calculation/MathTrig/LOG.php';
243
    }
244
245
    /**
246
     * @dataProvider providerMOD
247
     *
248
     * @param mixed $expectedResult
249
     */
250
    public function testMOD($expectedResult, ...$args)
251
    {
252
        $result = MathTrig::MOD(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $a of PhpOffice\PhpSpreadsheet...ulation\MathTrig::MOD() 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

252
        $result = MathTrig::MOD(/** @scrutinizer ignore-type */ ...$args);
Loading history...
253
        self::assertEquals($expectedResult, $result, null, 1E-12);
254
    }
255
256
    public function providerMOD()
257
    {
258
        return require 'data/Calculation/MathTrig/MOD.php';
259
    }
260
261
    /**
262
     * @dataProvider providerMDETERM
263
     *
264
     * @param mixed $expectedResult
265
     */
266
    public function testMDETERM($expectedResult, ...$args)
267
    {
268
        $result = MathTrig::MDETERM(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $matrixValues of PhpOffice\PhpSpreadsheet...ion\MathTrig::MDETERM() 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

268
        $result = MathTrig::MDETERM(/** @scrutinizer ignore-type */ ...$args);
Loading history...
269
        self::assertEquals($expectedResult, $result, null, 1E-12);
270
    }
271
272
    public function providerMDETERM()
273
    {
274
        return require 'data/Calculation/MathTrig/MDETERM.php';
275
    }
276
277
    /**
278
     * @dataProvider providerMINVERSE
279
     *
280
     * @param mixed $expectedResult
281
     */
282
    public function testMINVERSE($expectedResult, ...$args)
283
    {
284
        $this->markTestIncomplete('TODO: This test should be fixed');
285
286
        $result = MathTrig::MINVERSE(...$args);
287
        self::assertEquals($expectedResult, $result, null, 1E-12);
288
    }
289
290
    public function providerMINVERSE()
291
    {
292
        return require 'data/Calculation/MathTrig/MINVERSE.php';
293
    }
294
295
    /**
296
     * @dataProvider providerMMULT
297
     *
298
     * @param mixed $expectedResult
299
     */
300
    public function testMMULT($expectedResult, ...$args)
301
    {
302
        $this->markTestIncomplete('TODO: This test should be fixed');
303
304
        $result = MathTrig::MMULT(...$args);
305
        self::assertEquals($expectedResult, $result, null, 1E-12);
306
    }
307
308
    public function providerMMULT()
309
    {
310
        return require 'data/Calculation/MathTrig/MMULT.php';
311
    }
312
313
    /**
314
     * @dataProvider providerMULTINOMIAL
315
     *
316
     * @param mixed $expectedResult
317
     */
318
    public function testMULTINOMIAL($expectedResult, ...$args)
319
    {
320
        $result = MathTrig::MULTINOMIAL(...$args);
321
        self::assertEquals($expectedResult, $result, null, 1E-12);
322
    }
323
324
    public function providerMULTINOMIAL()
325
    {
326
        return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
327
    }
328
329
    /**
330
     * @dataProvider providerMROUND
331
     *
332
     * @param mixed $expectedResult
333
     */
334
    public function testMROUND($expectedResult, ...$args)
335
    {
336
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
337
        $result = MathTrig::MROUND(...$args);
338
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
339
        self::assertEquals($expectedResult, $result, null, 1E-12);
340
    }
341
342
    public function providerMROUND()
343
    {
344
        return require 'data/Calculation/MathTrig/MROUND.php';
345
    }
346
347
    /**
348
     * @dataProvider providerPRODUCT
349
     *
350
     * @param mixed $expectedResult
351
     */
352
    public function testPRODUCT($expectedResult, ...$args)
353
    {
354
        $result = MathTrig::PRODUCT(...$args);
355
        self::assertEquals($expectedResult, $result, null, 1E-12);
356
    }
357
358
    public function providerPRODUCT()
359
    {
360
        return require 'data/Calculation/MathTrig/PRODUCT.php';
361
    }
362
363
    /**
364
     * @dataProvider providerQUOTIENT
365
     *
366
     * @param mixed $expectedResult
367
     */
368
    public function testQUOTIENT($expectedResult, ...$args)
369
    {
370
        $result = MathTrig::QUOTIENT(...$args);
371
        self::assertEquals($expectedResult, $result, null, 1E-12);
372
    }
373
374
    public function providerQUOTIENT()
375
    {
376
        return require 'data/Calculation/MathTrig/QUOTIENT.php';
377
    }
378
379
    /**
380
     * @dataProvider providerROUNDUP
381
     *
382
     * @param mixed $expectedResult
383
     */
384
    public function testROUNDUP($expectedResult, ...$args)
385
    {
386
        $result = MathTrig::ROUNDUP(...$args);
387
        self::assertEquals($expectedResult, $result, null, 1E-12);
388
    }
389
390
    public function providerROUNDUP()
391
    {
392
        return require 'data/Calculation/MathTrig/ROUNDUP.php';
393
    }
394
395
    /**
396
     * @dataProvider providerROUNDDOWN
397
     *
398
     * @param mixed $expectedResult
399
     */
400
    public function testROUNDDOWN($expectedResult, ...$args)
401
    {
402
        $result = MathTrig::ROUNDDOWN(...$args);
403
        self::assertEquals($expectedResult, $result, null, 1E-12);
404
    }
405
406
    public function providerROUNDDOWN()
407
    {
408
        return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
409
    }
410
411
    /**
412
     * @dataProvider providerSERIESSUM
413
     *
414
     * @param mixed $expectedResult
415
     */
416
    public function testSERIESSUM($expectedResult, ...$args)
417
    {
418
        $result = MathTrig::SERIESSUM(...$args);
419
        self::assertEquals($expectedResult, $result, null, 1E-12);
420
    }
421
422
    public function providerSERIESSUM()
423
    {
424
        return require 'data/Calculation/MathTrig/SERIESSUM.php';
425
    }
426
427
    /**
428
     * @dataProvider providerSUMSQ
429
     *
430
     * @param mixed $expectedResult
431
     */
432
    public function testSUMSQ($expectedResult, ...$args)
433
    {
434
        $result = MathTrig::SUMSQ(...$args);
435
        self::assertEquals($expectedResult, $result, null, 1E-12);
436
    }
437
438
    public function providerSUMSQ()
439
    {
440
        return require 'data/Calculation/MathTrig/SUMSQ.php';
441
    }
442
443
    /**
444
     * @dataProvider providerSUMPRODUCT
445
     *
446
     * @param mixed $expectedResult
447
     */
448
    public function testSUMPRODUCT($expectedResult, ...$args)
449
    {
450
        $result = MathTrig::SUMPRODUCT(...$args);
451
        self::assertEquals($expectedResult, $result, null, 1E-12);
452
    }
453
454
    public function providerSUMPRODUCT()
455
    {
456
        return require 'data/Calculation/MathTrig/SUMPRODUCT.php';
457
    }
458
459
    /**
460
     * @dataProvider providerSUMX2MY2
461
     *
462
     * @param mixed $expectedResult
463
     */
464
    public function testSUMX2MY2($expectedResult, ...$args)
465
    {
466
        $result = MathTrig::SUMX2MY2(...$args);
467
        self::assertEquals($expectedResult, $result, null, 1E-12);
468
    }
469
470
    public function providerSUMX2MY2()
471
    {
472
        return require 'data/Calculation/MathTrig/SUMX2MY2.php';
473
    }
474
475
    /**
476
     * @dataProvider providerSUMX2PY2
477
     *
478
     * @param mixed $expectedResult
479
     */
480
    public function testSUMX2PY2($expectedResult, ...$args)
481
    {
482
        $result = MathTrig::SUMX2PY2(...$args);
483
        self::assertEquals($expectedResult, $result, null, 1E-12);
484
    }
485
486
    public function providerSUMX2PY2()
487
    {
488
        return require 'data/Calculation/MathTrig/SUMX2PY2.php';
489
    }
490
491
    /**
492
     * @dataProvider providerSUMXMY2
493
     *
494
     * @param mixed $expectedResult
495
     */
496
    public function testSUMXMY2($expectedResult, ...$args)
497
    {
498
        $result = MathTrig::SUMXMY2(...$args);
499
        self::assertEquals($expectedResult, $result, null, 1E-12);
500
    }
501
502
    public function providerSUMXMY2()
503
    {
504
        return require 'data/Calculation/MathTrig/SUMXMY2.php';
505
    }
506
507
    /**
508
     * @dataProvider providerTRUNC
509
     *
510
     * @param mixed $expectedResult
511
     */
512
    public function testTRUNC($expectedResult, ...$args)
513
    {
514
        $result = MathTrig::TRUNC(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ation\MathTrig::TRUNC() 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

514
        $result = MathTrig::TRUNC(/** @scrutinizer ignore-type */ ...$args);
Loading history...
515
        self::assertEquals($expectedResult, $result, null, 1E-12);
516
    }
517
518
    public function providerTRUNC()
519
    {
520
        return require 'data/Calculation/MathTrig/TRUNC.php';
521
    }
522
523
    /**
524
     * @dataProvider providerROMAN
525
     *
526
     * @param mixed $expectedResult
527
     */
528
    public function testROMAN($expectedResult, ...$args)
529
    {
530
        $result = MathTrig::ROMAN(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $aValue of PhpOffice\PhpSpreadsheet...ation\MathTrig::ROMAN() 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

530
        $result = MathTrig::ROMAN(/** @scrutinizer ignore-type */ ...$args);
Loading history...
531
        self::assertEquals($expectedResult, $result);
532
    }
533
534
    public function providerROMAN()
535
    {
536
        return require 'data/Calculation/MathTrig/ROMAN.php';
537
    }
538
539
    /**
540
     * @dataProvider providerSQRTPI
541
     *
542
     * @param mixed $expectedResult
543
     */
544
    public function testSQRTPI($expectedResult, ...$args)
545
    {
546
        $result = MathTrig::SQRTPI(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $number of PhpOffice\PhpSpreadsheet...tion\MathTrig::SQRTPI() 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

546
        $result = MathTrig::SQRTPI(/** @scrutinizer ignore-type */ ...$args);
Loading history...
547
        self::assertEquals($expectedResult, $result, null, 1E-12);
548
    }
549
550
    public function providerSQRTPI()
551
    {
552
        return require 'data/Calculation/MathTrig/SQRTPI.php';
553
    }
554
555
    /**
556
     * @dataProvider providerSUMIF
557
     *
558
     * @param mixed $expectedResult
559
     */
560
    public function testSUMIF($expectedResult, ...$args)
561
    {
562
        $result = MathTrig::SUMIF(...$args);
563
        self::assertEquals($expectedResult, $result, '', 1E-12);
564
    }
565
566
    public function providerSUMIF()
567
    {
568
        return require 'data/Calculation/MathTrig/SUMIF.php';
569
    }
570
571
    /**
572
     * @dataProvider providerSUMIFS
573
     *
574
     * @param mixed $expectedResult
575
     */
576
    public function testSUMIFS($expectedResult, ...$args)
577
    {
578
        $result = MathTrig::SUMIFS(...$args);
579
        self::assertEquals($expectedResult, $result, '', 1E-12);
580
    }
581
582
    public function providerSUMIFS()
583
    {
584
        return require 'data/Calculation/MathTrig/SUMIFS.php';
585
    }
586
587
    /**
588
     * @dataProvider providerSUBTOTAL
589
     *
590
     * @param mixed $expectedResult
591
     */
592
    public function testSUBTOTAL($expectedResult, ...$args)
593
    {
594
        $cell = $this->getMockBuilder(Cell::class)
595
            ->setMethods(['getValue'])
596
            ->disableOriginalConstructor()
597
            ->getMock();
598
        $cell->method('getValue')
599
            ->willReturn(null);
600
        $worksheet = $this->getMockBuilder(Worksheet::class)
601
            ->setMethods(['cellExists', 'getCell'])
602
            ->disableOriginalConstructor()
603
            ->getMock();
604
        $worksheet->method('cellExists')
605
            ->willReturn(true);
606
        $worksheet->method('getCell')
607
            ->willReturn($cell);
608
        $cellReference = $this->getMockBuilder(Cell::class)
609
            ->setMethods(['getWorksheet'])
610
            ->disableOriginalConstructor()
611
            ->getMock();
612
        $cellReference->method('getWorksheet')
613
            ->willReturn($worksheet);
614
615
        array_push($args, $cellReference);
616
        $result = MathTrig::SUBTOTAL(...$args);
617
        self::assertEquals($expectedResult, $result, null, 1E-12);
618
    }
619
620
    public function providerSUBTOTAL()
621
    {
622
        return require 'data/Calculation/MathTrig/SUBTOTAL.php';
623
    }
624
625
    protected function rowVisibility()
626
    {
627
        $data = [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 => true];
628
        foreach ($data as $k => $v) {
629
            yield $k => $v;
630
        }
631
    }
632
633
    /**
634
     * @dataProvider providerHiddenSUBTOTAL
635
     *
636
     * @param mixed $expectedResult
637
     */
638
    public function testHiddenSUBTOTAL($expectedResult, ...$args)
639
    {
640
        $visibilityGenerator = $this->rowVisibility();
641
642
        $rowDimension = $this->getMockBuilder(RowDimension::class)
643
            ->setMethods(['getVisible'])
644
            ->disableOriginalConstructor()
645
            ->getMock();
646
        $rowDimension->method('getVisible')
647
            ->will($this->returnCallback(function () use ($visibilityGenerator) {
648
                $result = $visibilityGenerator->current();
649
                $visibilityGenerator->next();
650
651
                return $result;
652
            }));
653
        $columnDimension = $this->getMockBuilder(ColumnDimension::class)
654
            ->setMethods(['getVisible'])
655
            ->disableOriginalConstructor()
656
            ->getMock();
657
        $columnDimension->method('getVisible')
658
            ->willReturn(true);
659
        $cell = $this->getMockBuilder(Cell::class)
660
            ->setMethods(['getValue'])
661
            ->disableOriginalConstructor()
662
            ->getMock();
663
        $cell->method('getValue')
664
            ->willReturn('');
665
        $worksheet = $this->getMockBuilder(Worksheet::class)
666
            ->setMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
667
            ->disableOriginalConstructor()
668
            ->getMock();
669
        $worksheet->method('cellExists')
670
            ->willReturn(true);
671
        $worksheet->method('getCell')
672
            ->willReturn($cell);
673
        $worksheet->method('getRowDimension')
674
            ->willReturn($rowDimension);
675
        $worksheet->method('getColumnDimension')
676
            ->willReturn($columnDimension);
677
        $cellReference = $this->getMockBuilder(Cell::class)
678
            ->setMethods(['getWorksheet'])
679
            ->disableOriginalConstructor()
680
            ->getMock();
681
        $cellReference->method('getWorksheet')
682
            ->willReturn($worksheet);
683
684
        array_push($args, $cellReference);
685
        $result = MathTrig::SUBTOTAL(...$args);
686
        self::assertEquals($expectedResult, $result, null, 1E-12);
687
    }
688
689
    public function providerHiddenSUBTOTAL()
690
    {
691
        return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
692
    }
693
694
    protected function cellValues(array $cellValues)
695
    {
696
        foreach ($cellValues as $k => $v) {
697
            yield $k => $v;
698
        }
699
    }
700
701
    protected function cellIsFormula(array $cellValues)
702
    {
703
        foreach ($cellValues as $cellValue) {
704
            yield $cellValue[0] === '=';
705
        }
706
    }
707
708
    /**
709
     * @dataProvider providerNestedSUBTOTAL
710
     *
711
     * @param mixed $expectedResult
712
     */
713
    public function testNestedSUBTOTAL($expectedResult, ...$args)
714
    {
715
        $cellValueGenerator = $this->cellValues(Functions::flattenArray(array_slice($args, 1)));
716
        $cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1)));
717
718
        $cell = $this->getMockBuilder(Cell::class)
719
            ->setMethods(['getValue', 'isFormula'])
720
            ->disableOriginalConstructor()
721
            ->getMock();
722
        $cell->method('getValue')
723
            ->will($this->returnCallback(function () use ($cellValueGenerator) {
724
                $result = $cellValueGenerator->current();
725
                $cellValueGenerator->next();
726
727
                return $result;
728
            }));
729
        $cell->method('isFormula')
730
            ->will($this->returnCallback(function () use ($cellIsFormulaGenerator) {
731
                $result = $cellIsFormulaGenerator->current();
732
                $cellIsFormulaGenerator->next();
733
734
                return $result;
735
            }));
736
        $worksheet = $this->getMockBuilder(Worksheet::class)
737
            ->setMethods(['cellExists', 'getCell'])
738
            ->disableOriginalConstructor()
739
            ->getMock();
740
        $worksheet->method('cellExists')
741
            ->willReturn(true);
742
        $worksheet->method('getCell')
743
            ->willReturn($cell);
744
        $cellReference = $this->getMockBuilder(Cell::class)
745
            ->setMethods(['getWorksheet'])
746
            ->disableOriginalConstructor()
747
            ->getMock();
748
        $cellReference->method('getWorksheet')
749
            ->willReturn($worksheet);
750
751
        array_push($args, $cellReference);
752
753
        $result = MathTrig::SUBTOTAL(...$args);
754
        self::assertEquals($expectedResult, $result, null, 1E-12);
755
    }
756
757
    public function providerNestedSUBTOTAL()
758
    {
759
        return require 'data/Calculation/MathTrig/SUBTOTALNESTED.php';
760
    }
761
762
    /**
763
     * @dataProvider providerSEC
764
     *
765
     * @param mixed $expectedResult
766
     * @param mixed $angle
767
     */
768
    public function testSEC($expectedResult, $angle)
769
    {
770
        $result = MathTrig::SEC($angle);
771
        self::assertEquals($expectedResult, $result, null, 1E-12);
772
    }
773
774
    public function providerSEC()
775
    {
776
        return require 'data/Calculation/MathTrig/SEC.php';
777
    }
778
779
    /**
780
     * @dataProvider providerSECH
781
     *
782
     * @param mixed $expectedResult
783
     * @param mixed $angle
784
     */
785
    public function testSECH($expectedResult, $angle)
786
    {
787
        $result = MathTrig::SECH($angle);
788
        self::assertEquals($expectedResult, $result, null, 1E-12);
789
    }
790
791
    public function providerSECH()
792
    {
793
        return require 'data/Calculation/MathTrig/SECH.php';
794
    }
795
796
    /**
797
     * @dataProvider providerCSC
798
     *
799
     * @param mixed $expectedResult
800
     * @param mixed $angle
801
     */
802
    public function testCSC($expectedResult, $angle)
803
    {
804
        $result = MathTrig::CSC($angle);
805
        self::assertEquals($expectedResult, $result, null, 1E-12);
806
    }
807
808
    public function providerCSC()
809
    {
810
        return require 'data/Calculation/MathTrig/CSC.php';
811
    }
812
813
    /**
814
     * @dataProvider providerCSCH
815
     *
816
     * @param mixed $expectedResult
817
     * @param mixed $angle
818
     */
819
    public function testCSCH($expectedResult, $angle)
820
    {
821
        $result = MathTrig::CSCH($angle);
822
        self::assertEquals($expectedResult, $result, null, 1E-12);
823
    }
824
825
    public function providerCSCH()
826
    {
827
        return require 'data/Calculation/MathTrig/CSCH.php';
828
    }
829
830
    /**
831
     * @dataProvider providerCOT
832
     *
833
     * @param mixed $expectedResult
834
     * @param mixed $angle
835
     */
836
    public function testCOT($expectedResult, $angle)
837
    {
838
        $result = MathTrig::COT($angle);
839
        self::assertEquals($expectedResult, $result, null, 1E-12);
840
    }
841
842
    public function providerCOT()
843
    {
844
        return require 'data/Calculation/MathTrig/COT.php';
845
    }
846
847
    /**
848
     * @dataProvider providerCOTH
849
     *
850
     * @param mixed $expectedResult
851
     * @param mixed $angle
852
     */
853
    public function testCOTH($expectedResult, $angle)
854
    {
855
        $result = MathTrig::COTH($angle);
856
        self::assertEquals($expectedResult, $result, null, 1E-12);
857
    }
858
859
    public function providerCOTH()
860
    {
861
        return require 'data/Calculation/MathTrig/COTH.php';
862
    }
863
864
    /**
865
     * @dataProvider providerACOT
866
     *
867
     * @param mixed $expectedResult
868
     * @param mixed $number
869
     */
870
    public function testACOT($expectedResult, $number)
871
    {
872
        $result = MathTrig::ACOT($number);
873
        self::assertEquals($expectedResult, $result, null, 1E-12);
874
    }
875
876
    public function providerACOT()
877
    {
878
        return require 'data/Calculation/MathTrig/ACOT.php';
879
    }
880
881
    /**
882
     * @dataProvider providerACOTH
883
     *
884
     * @param mixed $expectedResult
885
     * @param mixed $number
886
     */
887
    public function testACOTH($expectedResult, $number)
888
    {
889
        $result = MathTrig::ACOTH($number);
890
        self::assertEquals($expectedResult, $result, null, 1E-12);
891
    }
892
893
    public function providerACOTH()
894
    {
895
        return require 'data/Calculation/MathTrig/ACOTH.php';
896
    }
897
}
898