Passed
Push — master ( c380b2...9239b3 )
by Adrien
10:06
created

SeriesSumTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
6
7
class SeriesSumTest extends AllSetupTeardown
8
{
9
    /**
10
     * @dataProvider providerSERIESSUM
11
     *
12
     * @param mixed $expectedResult
13
     * @param mixed $arg1
14
     * @param mixed $arg2
15
     * @param mixed $arg3
16
     */
17
    public function testSERIESSUM($expectedResult, $arg1, $arg2, $arg3, ...$args): void
18
    {
19
        $sheet = $this->sheet;
20
        if ($arg1 !== null) {
21
            $sheet->getCell('C1')->setValue($arg1);
22
        }
23
        if ($arg2 !== null) {
24
            $sheet->getCell('C2')->setValue($arg2);
25
        }
26
        if ($arg3 !== null) {
27
            $sheet->getCell('C3')->setValue($arg3);
28
        }
29
        $row = 0;
30
        $aArgs = Functions::flattenArray($args);
31
        foreach ($aArgs as $arg) {
32
            ++$row;
33
            if ($arg !== null) {
34
                $sheet->getCell("A$row")->setValue($arg);
35
            }
36
        }
37
        $sheet->getCell('B1')->setValue("=SERIESSUM(C1, C2, C3, A1:A$row)");
38
        $result = $sheet->getCell('B1')->getCalculatedValue();
39
        self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
40
    }
41
42
    public function providerSERIESSUM()
43
    {
44
        return require 'tests/data/Calculation/MathTrig/SERIESSUM.php';
45
    }
46
}
47