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

FactTest::providerFACTGnumeric()   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
c 0
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
class FactTest extends AllSetupTeardown
6
{
7
    /**
8
     * @dataProvider providerFACT
9
     *
10
     * @param mixed $expectedResult
11
     * @param mixed $arg1
12
     */
13
    public function testFACT($expectedResult, $arg1): void
14
    {
15
        $this->mightHaveException($expectedResult);
16
        $sheet = $this->sheet;
17
        if ($arg1 !== null) {
18
            $sheet->getCell('A1')->setValue($arg1);
19
        }
20
        if ($arg1 === 'omitted') {
21
            $sheet->getCell('B1')->setValue('=FACT()');
22
        } else {
23
            $sheet->getCell('B1')->setValue('=FACT(A1)');
24
        }
25
        $result = $sheet->getCell('B1')->getCalculatedValue();
26
        self::assertEquals($expectedResult, $result);
27
    }
28
29
    public function providerFACT()
30
    {
31
        return require 'tests/data/Calculation/MathTrig/FACT.php';
32
    }
33
34
    /**
35
     * @dataProvider providerFACTGnumeric
36
     *
37
     * @param mixed $expectedResult
38
     * @param mixed $arg1
39
     */
40
    public function testFACTGnumeric($expectedResult, $arg1): void
41
    {
42
        $this->mightHaveException($expectedResult);
43
        self::setGnumeric();
44
        $sheet = $this->sheet;
45
        if ($arg1 !== null) {
46
            $sheet->getCell('A1')->setValue($arg1);
47
        }
48
        if ($arg1 === 'omitted') {
49
            $sheet->getCell('B1')->setValue('=FACT()');
50
        } else {
51
            $sheet->getCell('B1')->setValue('=FACT(A1)');
52
        }
53
        $result = $sheet->getCell('B1')->getCalculatedValue();
54
        self::assertEquals($expectedResult, $result);
55
    }
56
57
    public function providerFACTGnumeric()
58
    {
59
        return require 'tests/data/Calculation/MathTrig/FACTGNUMERIC.php';
60
    }
61
}
62