Completed
Branch develop (b42baf)
by Adrien
11:23
created

MathTrigTest::testPOWER()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 9.4285
1
<?php
2
3
namespace PhpSpreadsheetTests\Calculation;
4
5
use PhpSpreadsheet\Calculation;
6
use PhpSpreadsheet\Calculation\Functions;
7
use PhpSpreadsheet\Calculation\MathTrig;
8
9
class MathTrigTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function setUp()
12
    {
13
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
14
    }
15
16
    /**
17
     * @dataProvider providerATAN2
18
     */
19
    public function testATAN2()
20
    {
21
        $args = func_get_args();
22
        $expectedResult = array_pop($args);
23
        $result = call_user_func_array([MathTrig::class, 'ATAN2'], $args);
24
        $this->assertEquals($expectedResult, $result, null, 1E-12);
25
    }
26
27
    public function providerATAN2()
28
    {
29
        return require 'data/Calculation/MathTrig/ATAN2.php';
30
    }
31
32
    /**
33
     * @dataProvider providerCEILING
34
     */
35
    public function testCEILING()
36
    {
37
        $args = func_get_args();
38
        $expectedResult = array_pop($args);
39
        $result = call_user_func_array([MathTrig::class, 'CEILING'], $args);
40
        $this->assertEquals($expectedResult, $result, null, 1E-12);
41
    }
42
43
    public function providerCEILING()
44
    {
45
        return require 'data/Calculation/MathTrig/CEILING.php';
46
    }
47
48
    /**
49
     * @dataProvider providerCOMBIN
50
     */
51
    public function testCOMBIN()
52
    {
53
        $args = func_get_args();
54
        $expectedResult = array_pop($args);
55
        $result = call_user_func_array([MathTrig::class, 'COMBIN'], $args);
56
        $this->assertEquals($expectedResult, $result, null, 1E-12);
57
    }
58
59
    public function providerCOMBIN()
60
    {
61
        return require 'data/Calculation/MathTrig/COMBIN.php';
62
    }
63
64
    /**
65
     * @dataProvider providerEVEN
66
     */
67
    public function testEVEN()
68
    {
69
        $args = func_get_args();
70
        $expectedResult = array_pop($args);
71
        $result = call_user_func_array([MathTrig::class, 'EVEN'], $args);
72
        $this->assertEquals($expectedResult, $result, null, 1E-12);
73
    }
74
75
    public function providerEVEN()
76
    {
77
        return require 'data/Calculation/MathTrig/EVEN.php';
78
    }
79
80
    /**
81
     * @dataProvider providerODD
82
     */
83
    public function testODD()
84
    {
85
        $args = func_get_args();
86
        $expectedResult = array_pop($args);
87
        $result = call_user_func_array([MathTrig::class, 'ODD'], $args);
88
        $this->assertEquals($expectedResult, $result, null, 1E-12);
89
    }
90
91
    public function providerODD()
92
    {
93
        return require 'data/Calculation/MathTrig/ODD.php';
94
    }
95
96
    /**
97
     * @dataProvider providerFACT
98
     */
99
    public function testFACT()
100
    {
101
        $args = func_get_args();
102
        $expectedResult = array_pop($args);
103
        $result = call_user_func_array([MathTrig::class, 'FACT'], $args);
104
        $this->assertEquals($expectedResult, $result, null, 1E-12);
105
    }
106
107
    public function providerFACT()
108
    {
109
        return require 'data/Calculation/MathTrig/FACT.php';
110
    }
111
112
    /**
113
     * @dataProvider providerFACTDOUBLE
114
     */
115
    public function testFACTDOUBLE()
116
    {
117
        $args = func_get_args();
118
        $expectedResult = array_pop($args);
119
        $result = call_user_func_array([MathTrig::class, 'FACTDOUBLE'], $args);
120
        $this->assertEquals($expectedResult, $result, null, 1E-12);
121
    }
122
123
    public function providerFACTDOUBLE()
124
    {
125
        return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
126
    }
127
128
    /**
129
     * @dataProvider providerFLOOR
130
     */
131
    public function testFLOOR()
132
    {
133
        $args = func_get_args();
134
        $expectedResult = array_pop($args);
135
        $result = call_user_func_array([MathTrig::class, 'FLOOR'], $args);
136
        $this->assertEquals($expectedResult, $result, null, 1E-12);
137
    }
138
139
    public function providerFLOOR()
140
    {
141
        return require 'data/Calculation/MathTrig/FLOOR.php';
142
    }
143
144
    /**
145
     * @dataProvider providerGCD
146
     */
147
    public function testGCD()
148
    {
149
        $args = func_get_args();
150
        $expectedResult = array_pop($args);
151
        $result = call_user_func_array([MathTrig::class, 'GCD'], $args);
152
        $this->assertEquals($expectedResult, $result, null, 1E-12);
153
    }
154
155
    public function providerGCD()
156
    {
157
        return require 'data/Calculation/MathTrig/GCD.php';
158
    }
159
160
    /**
161
     * @dataProvider providerLCM
162
     */
163
    public function testLCM()
164
    {
165
        $args = func_get_args();
166
        $expectedResult = array_pop($args);
167
        $result = call_user_func_array([MathTrig::class, 'LCM'], $args);
168
        $this->assertEquals($expectedResult, $result, null, 1E-12);
169
    }
170
171
    public function providerLCM()
172
    {
173
        return require 'data/Calculation/MathTrig/LCM.php';
174
    }
175
176
    /**
177
     * @dataProvider providerINT
178
     */
179
    public function testINT()
180
    {
181
        $args = func_get_args();
182
        $expectedResult = array_pop($args);
183
        $result = call_user_func_array([MathTrig::class, 'INT'], $args);
184
        $this->assertEquals($expectedResult, $result);
185
    }
186
187
    public function providerINT()
188
    {
189
        return require 'data/Calculation/MathTrig/INT.php';
190
    }
191
192
    /**
193
     * @dataProvider providerSIGN
194
     */
195
    public function testSIGN()
196
    {
197
        $args = func_get_args();
198
        $expectedResult = array_pop($args);
199
        $result = call_user_func_array([MathTrig::class, 'SIGN'], $args);
200
        $this->assertEquals($expectedResult, $result, null, 1E-12);
201
    }
202
203
    public function providerSIGN()
204
    {
205
        return require 'data/Calculation/MathTrig/SIGN.php';
206
    }
207
208
    /**
209
     * @dataProvider providerPOWER
210
     */
211
    public function testPOWER()
212
    {
213
        $args = func_get_args();
214
        $expectedResult = array_pop($args);
215
        $result = call_user_func_array([MathTrig::class, 'POWER'], $args);
216
        $this->assertEquals($expectedResult, $result, null, 1E-12);
217
    }
218
219
    public function providerPOWER()
220
    {
221
        return require 'data/Calculation/MathTrig/POWER.php';
222
    }
223
224
    /**
225
     * @dataProvider providerLOG
226
     */
227
    public function testLOG()
228
    {
229
        $args = func_get_args();
230
        $expectedResult = array_pop($args);
231
        $result = call_user_func_array([MathTrig::class, 'logBase'], $args);
232
        $this->assertEquals($expectedResult, $result, null, 1E-12);
233
    }
234
235
    public function providerLOG()
236
    {
237
        return require 'data/Calculation/MathTrig/LOG.php';
238
    }
239
240
    /**
241
     * @dataProvider providerMOD
242
     */
243
    public function testMOD()
244
    {
245
        $args = func_get_args();
246
        $expectedResult = array_pop($args);
247
        $result = call_user_func_array([MathTrig::class, 'MOD'], $args);
248
        $this->assertEquals($expectedResult, $result, null, 1E-12);
249
    }
250
251
    public function providerMOD()
252
    {
253
        return require 'data/Calculation/MathTrig/MOD.php';
254
    }
255
256
    /**
257
     * @dataProvider providerMDETERM
258
     */
259
    public function testMDETERM()
260
    {
261
        $args = func_get_args();
262
        $expectedResult = array_pop($args);
263
        $result = call_user_func_array([MathTrig::class, 'MDETERM'], $args);
264
        $this->assertEquals($expectedResult, $result, null, 1E-12);
265
    }
266
267
    public function providerMDETERM()
268
    {
269
        return require 'data/Calculation/MathTrig/MDETERM.php';
270
    }
271
272
    /**
273
     * @dataProvider providerMINVERSE
274
     * @group fail19
275
     */
276
    public function testMINVERSE()
277
    {
278
        $this->markTestIncomplete('TODO: This test should be fixed');
279
280
        $args = func_get_args();
281
        $expectedResult = array_pop($args);
282
        $result = call_user_func_array([MathTrig::class, 'MINVERSE'], $args);
283
        $this->assertEquals($expectedResult, $result, null, 1E-12);
284
    }
285
286
    public function providerMINVERSE()
287
    {
288
        return require 'data/Calculation/MathTrig/MINVERSE.php';
289
    }
290
291
    /**
292
     * @dataProvider providerMMULT
293
     * @group fail19
294
     */
295
    public function testMMULT()
296
    {
297
        $this->markTestIncomplete('TODO: This test should be fixed');
298
299
        $args = func_get_args();
300
        $expectedResult = array_pop($args);
301
        $result = call_user_func_array([MathTrig::class, 'MMULT'], $args);
302
        $this->assertEquals($expectedResult, $result, null, 1E-12);
303
    }
304
305
    public function providerMMULT()
306
    {
307
        return require 'data/Calculation/MathTrig/MMULT.php';
308
    }
309
310
    /**
311
     * @dataProvider providerMULTINOMIAL
312
     */
313
    public function testMULTINOMIAL()
314
    {
315
        $args = func_get_args();
316
        $expectedResult = array_pop($args);
317
        $result = call_user_func_array([MathTrig::class, 'MULTINOMIAL'], $args);
318
        $this->assertEquals($expectedResult, $result, null, 1E-12);
319
    }
320
321
    public function providerMULTINOMIAL()
322
    {
323
        return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
324
    }
325
326
    /**
327
     * @dataProvider providerMROUND
328
     */
329
    public function testMROUND()
330
    {
331
        $args = func_get_args();
332
        $expectedResult = array_pop($args);
333
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
334
        $result = call_user_func_array([MathTrig::class, 'MROUND'], $args);
335
        Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
336
        $this->assertEquals($expectedResult, $result, null, 1E-12);
337
    }
338
339
    public function providerMROUND()
340
    {
341
        return require 'data/Calculation/MathTrig/MROUND.php';
342
    }
343
344
    /**
345
     * @dataProvider providerPRODUCT
346
     */
347
    public function testPRODUCT()
348
    {
349
        $args = func_get_args();
350
        $expectedResult = array_pop($args);
351
        $result = call_user_func_array([MathTrig::class, 'PRODUCT'], $args);
352
        $this->assertEquals($expectedResult, $result, null, 1E-12);
353
    }
354
355
    public function providerPRODUCT()
356
    {
357
        return require 'data/Calculation/MathTrig/PRODUCT.php';
358
    }
359
360
    /**
361
     * @dataProvider providerQUOTIENT
362
     */
363
    public function testQUOTIENT()
364
    {
365
        $args = func_get_args();
366
        $expectedResult = array_pop($args);
367
        $result = call_user_func_array([MathTrig::class, 'QUOTIENT'], $args);
368
        $this->assertEquals($expectedResult, $result, null, 1E-12);
369
    }
370
371
    public function providerQUOTIENT()
372
    {
373
        return require 'data/Calculation/MathTrig/QUOTIENT.php';
374
    }
375
376
    /**
377
     * @dataProvider providerROUNDUP
378
     */
379
    public function testROUNDUP()
380
    {
381
        $args = func_get_args();
382
        $expectedResult = array_pop($args);
383
        $result = call_user_func_array([MathTrig::class, 'ROUNDUP'], $args);
384
        $this->assertEquals($expectedResult, $result, null, 1E-12);
385
    }
386
387
    public function providerROUNDUP()
388
    {
389
        return require 'data/Calculation/MathTrig/ROUNDUP.php';
390
    }
391
392
    /**
393
     * @dataProvider providerROUNDDOWN
394
     */
395
    public function testROUNDDOWN()
396
    {
397
        $args = func_get_args();
398
        $expectedResult = array_pop($args);
399
        $result = call_user_func_array([MathTrig::class, 'ROUNDDOWN'], $args);
400
        $this->assertEquals($expectedResult, $result, null, 1E-12);
401
    }
402
403
    public function providerROUNDDOWN()
404
    {
405
        return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
406
    }
407
408
    /**
409
     * @dataProvider providerSERIESSUM
410
     */
411
    public function testSERIESSUM()
412
    {
413
        $args = func_get_args();
414
        $expectedResult = array_pop($args);
415
        $result = call_user_func_array([MathTrig::class, 'SERIESSUM'], $args);
416
        $this->assertEquals($expectedResult, $result, null, 1E-12);
417
    }
418
419
    public function providerSERIESSUM()
420
    {
421
        return require 'data/Calculation/MathTrig/SERIESSUM.php';
422
    }
423
424
    /**
425
     * @dataProvider providerSUMSQ
426
     */
427
    public function testSUMSQ()
428
    {
429
        $args = func_get_args();
430
        $expectedResult = array_pop($args);
431
        $result = call_user_func_array([MathTrig::class, 'SUMSQ'], $args);
432
        $this->assertEquals($expectedResult, $result, null, 1E-12);
433
    }
434
435
    public function providerSUMSQ()
436
    {
437
        return require 'data/Calculation/MathTrig/SUMSQ.php';
438
    }
439
440
    /**
441
     * @dataProvider providerTRUNC
442
     */
443
    public function testTRUNC()
444
    {
445
        $args = func_get_args();
446
        $expectedResult = array_pop($args);
447
        $result = call_user_func_array([MathTrig::class, 'TRUNC'], $args);
448
        $this->assertEquals($expectedResult, $result, null, 1E-12);
449
    }
450
451
    public function providerTRUNC()
452
    {
453
        return require 'data/Calculation/MathTrig/TRUNC.php';
454
    }
455
456
    /**
457
     * @dataProvider providerROMAN
458
     */
459
    public function testROMAN()
460
    {
461
        $args = func_get_args();
462
        $expectedResult = array_pop($args);
463
        $result = call_user_func_array([MathTrig::class, 'ROMAN'], $args);
464
        $this->assertEquals($expectedResult, $result);
465
    }
466
467
    public function providerROMAN()
468
    {
469
        return require 'data/Calculation/MathTrig/ROMAN.php';
470
    }
471
472
    /**
473
     * @dataProvider providerSQRTPI
474
     */
475
    public function testSQRTPI()
476
    {
477
        $args = func_get_args();
478
        $expectedResult = array_pop($args);
479
        $result = call_user_func_array([MathTrig::class, 'SQRTPI'], $args);
480
        $this->assertEquals($expectedResult, $result, null, 1E-12);
481
    }
482
483
    public function providerSQRTPI()
484
    {
485
        return require 'data/Calculation/MathTrig/SQRTPI.php';
486
    }
487
488
    /**
489
     * @dataProvider providerSUMIF
490
     */
491
    public function testSUMIF()
492
    {
493
        $args = func_get_args();
494
        $expectedResult = array_pop($args);
495
        $result = call_user_func_array([MathTrig::class, 'SUMIF'], $args);
496
        $this->assertEquals($expectedResult, $result, null, 1E-12);
497
    }
498
499
    public function providerSUMIF()
500
    {
501
        return [
502
            [
503
                [
504
                    [1],
505
                    [5],
506
                    [10],
507
                ],
508
                '>=5',
509
                15,
510
            ],
511
            [
512
                [
513
                    ['text'],
514
                    [2],
515
                ],
516
                '=text',
517
                [
518
                    [10],
519
                    [100],
520
                ],
521
                10,
522
            ],
523
            [
524
                [
525
                    ['"text with quotes"'],
526
                    [2],
527
                ],
528
                '="text with quotes"',
529
                [
530
                    [10],
531
                    [100],
532
                ],
533
                10,
534
            ],
535
            [
536
                [
537
                    ['"text with quotes"'],
538
                    [''],
539
                ],
540
                '>"', // Compare to the single characater " (double quote)
541
                [
542
                    [10],
543
                    [100],
544
                ],
545
                10,
546
            ],
547
            [
548
                [
549
                    [''],
550
                    ['anything'],
551
                ],
552
                '>"', // Compare to the single characater " (double quote)
553
                [
554
                    [10],
555
                    [100],
556
                ],
557
                100,
558
            ],
559
        ];
560
    }
561
}
562