Completed
Push — develop ( 216cba...064076 )
by Adrien
34:22
created

MathTrigTest::testCOMBIN()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
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 providerTRUNC
445
     *
446
     * @param mixed $expectedResult
447
     */
448
    public function testTRUNC($expectedResult, ...$args)
449
    {
450
        $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

450
        $result = MathTrig::TRUNC(/** @scrutinizer ignore-type */ ...$args);
Loading history...
451
        self::assertEquals($expectedResult, $result, null, 1E-12);
452
    }
453
454
    public function providerTRUNC()
455
    {
456
        return require 'data/Calculation/MathTrig/TRUNC.php';
457
    }
458
459
    /**
460
     * @dataProvider providerROMAN
461
     *
462
     * @param mixed $expectedResult
463
     */
464
    public function testROMAN($expectedResult, ...$args)
465
    {
466
        $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

466
        $result = MathTrig::ROMAN(/** @scrutinizer ignore-type */ ...$args);
Loading history...
467
        self::assertEquals($expectedResult, $result);
468
    }
469
470
    public function providerROMAN()
471
    {
472
        return require 'data/Calculation/MathTrig/ROMAN.php';
473
    }
474
475
    /**
476
     * @dataProvider providerSQRTPI
477
     *
478
     * @param mixed $expectedResult
479
     */
480
    public function testSQRTPI($expectedResult, ...$args)
481
    {
482
        $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

482
        $result = MathTrig::SQRTPI(/** @scrutinizer ignore-type */ ...$args);
Loading history...
483
        self::assertEquals($expectedResult, $result, null, 1E-12);
484
    }
485
486
    public function providerSQRTPI()
487
    {
488
        return require 'data/Calculation/MathTrig/SQRTPI.php';
489
    }
490
491
    /**
492
     * @dataProvider providerSUMIF
493
     *
494
     * @param mixed $expectedResult
495
     */
496
    public function testSUMIF($expectedResult, ...$args)
497
    {
498
        $result = MathTrig::SUMIF(...$args);
499
        self::assertEquals($expectedResult, $result, null, 1E-12);
500
    }
501
502
    public function providerSUMIF()
503
    {
504
        return require 'data/Calculation/MathTrig/SUMIF.php';
505
    }
506
507
    /**
508
     * @dataProvider providerSUBTOTAL
509
     *
510
     * @param mixed $expectedResult
511
     */
512
    public function testSUBTOTAL($expectedResult, ...$args)
513
    {
514
        $cell = $this->getMockBuilder(Cell::class)
515
            ->setMethods(['getValue'])
516
            ->disableOriginalConstructor()
517
            ->getMock();
518
        $cell->method('getValue')
519
            ->willReturn(null);
520
        $worksheet = $this->getMockBuilder(Worksheet::class)
521
            ->setMethods(['cellExists', 'getCell'])
522
            ->disableOriginalConstructor()
523
            ->getMock();
524
        $worksheet->method('cellExists')
525
            ->willReturn(true);
526
        $worksheet->method('getCell')
527
            ->willReturn($cell);
528
        $cellReference = $this->getMockBuilder(Cell::class)
529
            ->setMethods(['getWorksheet'])
530
            ->disableOriginalConstructor()
531
            ->getMock();
532
        $cellReference->method('getWorksheet')
533
            ->willReturn($worksheet);
534
535
        array_push($args, $cellReference);
536
        $result = MathTrig::SUBTOTAL(...$args);
537
        self::assertEquals($expectedResult, $result, null, 1E-12);
538
    }
539
540
    public function providerSUBTOTAL()
541
    {
542
        return require 'data/Calculation/MathTrig/SUBTOTAL.php';
543
    }
544
545
    protected function rowVisibility()
546
    {
547
        $data = [1 => false, 2 => true, 3 => false, 4 => true, 5 => false, 6 => false, 7 => false, 8 => true, 9 => false, 10 => true, 11 => true];
548
        foreach ($data as $k => $v) {
549
            yield $k => $v;
550
        }
551
    }
552
553
    /**
554
     * @dataProvider providerHiddenSUBTOTAL
555
     *
556
     * @param mixed $expectedResult
557
     */
558
    public function testHiddenSUBTOTAL($expectedResult, ...$args)
559
    {
560
        $visibilityGenerator = $this->rowVisibility();
561
562
        $rowDimension = $this->getMockBuilder(RowDimension::class)
563
            ->setMethods(['getVisible'])
564
            ->disableOriginalConstructor()
565
            ->getMock();
566
        $rowDimension->method('getVisible')
567
            ->will($this->returnCallback(function () use ($visibilityGenerator) {
568
                $result = $visibilityGenerator->current();
569
                $visibilityGenerator->next();
570
571
                return $result;
572
            }));
573
        $columnDimension = $this->getMockBuilder(ColumnDimension::class)
574
            ->setMethods(['getVisible'])
575
            ->disableOriginalConstructor()
576
            ->getMock();
577
        $columnDimension->method('getVisible')
578
            ->willReturn(true);
579
        $cell = $this->getMockBuilder(Cell::class)
580
            ->setMethods(['getValue'])
581
            ->disableOriginalConstructor()
582
            ->getMock();
583
        $cell->method('getValue')
584
            ->willReturn('');
585
        $worksheet = $this->getMockBuilder(Worksheet::class)
586
            ->setMethods(['cellExists', 'getCell', 'getRowDimension', 'getColumnDimension'])
587
            ->disableOriginalConstructor()
588
            ->getMock();
589
        $worksheet->method('cellExists')
590
            ->willReturn(true);
591
        $worksheet->method('getCell')
592
            ->willReturn($cell);
593
        $worksheet->method('getRowDimension')
594
            ->willReturn($rowDimension);
595
        $worksheet->method('getColumnDimension')
596
            ->willReturn($columnDimension);
597
        $cellReference = $this->getMockBuilder(Cell::class)
598
            ->setMethods(['getWorksheet'])
599
            ->disableOriginalConstructor()
600
            ->getMock();
601
        $cellReference->method('getWorksheet')
602
            ->willReturn($worksheet);
603
604
        array_push($args, $cellReference);
605
        $result = MathTrig::SUBTOTAL(...$args);
606
        self::assertEquals($expectedResult, $result, null, 1E-12);
607
    }
608
609
    public function providerHiddenSUBTOTAL()
610
    {
611
        return require 'data/Calculation/MathTrig/SUBTOTALHIDDEN.php';
612
    }
613
614
    protected function cellValues(array $cellValues)
615
    {
616
        foreach ($cellValues as $k => $v) {
617
            yield $k => $v;
618
        }
619
    }
620
621
    protected function cellIsFormula(array $cellValues)
622
    {
623
        foreach ($cellValues as $cellValue) {
624
            yield $cellValue[0] === '=';
625
        }
626
    }
627
628
    /**
629
     * @dataProvider providerNestedSUBTOTAL
630
     *
631
     * @param mixed $expectedResult
632
     */
633
    public function testNestedSUBTOTAL($expectedResult, ...$args)
634
    {
635
        $cellValueGenerator = $this->cellValues(Functions::flattenArray(array_slice($args, 1)));
636
        $cellIsFormulaGenerator = $this->cellIsFormula(Functions::flattenArray(array_slice($args, 1)));
637
638
        $cell = $this->getMockBuilder(Cell::class)
639
            ->setMethods(['getValue', 'isFormula'])
640
            ->disableOriginalConstructor()
641
            ->getMock();
642
        $cell->method('getValue')
643
            ->will($this->returnCallback(function () use ($cellValueGenerator) {
644
                $result = $cellValueGenerator->current();
645
                $cellValueGenerator->next();
646
647
                return $result;
648
            }));
649
        $cell->method('isFormula')
650
            ->will($this->returnCallback(function () use ($cellIsFormulaGenerator) {
651
                $result = $cellIsFormulaGenerator->current();
652
                $cellIsFormulaGenerator->next();
653
654
                return $result;
655
            }));
656
        $worksheet = $this->getMockBuilder(Worksheet::class)
657
            ->setMethods(['cellExists', 'getCell'])
658
            ->disableOriginalConstructor()
659
            ->getMock();
660
        $worksheet->method('cellExists')
661
            ->willReturn(true);
662
        $worksheet->method('getCell')
663
            ->willReturn($cell);
664
        $cellReference = $this->getMockBuilder(Cell::class)
665
            ->setMethods(['getWorksheet'])
666
            ->disableOriginalConstructor()
667
            ->getMock();
668
        $cellReference->method('getWorksheet')
669
            ->willReturn($worksheet);
670
671
        array_push($args, $cellReference);
672
673
        $result = MathTrig::SUBTOTAL(...$args);
674
        self::assertEquals($expectedResult, $result, null, 1E-12);
675
    }
676
677
    public function providerNestedSUBTOTAL()
678
    {
679
        return require 'data/Calculation/MathTrig/SUBTOTALNESTED.php';
680
    }
681
}
682