Passed
Push — master ( 50d78c...560e67 )
by Adrien
11:11 queued 05:32
created

providerGenerateFunctionListByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests;
4
5
use PhpOffice\PhpSpreadsheet\Calculation\Category as Cat;
6
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
7
use PhpOffice\PhpSpreadsheet\Calculation\Logical;
8
use PhpOffice\PhpSpreadsheet\DocumentGenerator;
9
use PHPUnit\Framework\TestCase;
10
11
class DocumentGeneratorTest extends TestCase
12
{
13
    /**
14
     * @dataProvider providerGenerateFunctionListByName
15
     *
16
     * @param array $phpSpreadsheetFunctions
17
     * @param string $expected
18
     *
19
     * @throws \ReflectionException
20
     */
21
    public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, string $expected): void
22
    {
23
        self::assertEquals($expected, DocumentGenerator::generateFunctionListByName($phpSpreadsheetFunctions));
24
    }
25
26
    /**
27
     * @dataProvider providerGenerateFunctionListByCategory
28
     *
29
     * @param array $phpSpreadsheetFunctions
30
     * @param string $expected
31
     *
32
     * @throws \ReflectionException
33
     */
34
    public function testGenerateFunctionListByCategory(array $phpSpreadsheetFunctions, string $expected): void
35
    {
36
        self::assertEquals($expected, DocumentGenerator::generateFunctionListByCategory($phpSpreadsheetFunctions));
37
    }
38
39
    public function providerGenerateFunctionListByName(): array
40
    {
41
        return [
42
            [
43
                [
44
                    'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'],
45
                    'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']],
46
                    'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']],
47
                ],
48
                <<<'EXPECTED'
49
# Function list by name
50
51
## A
52
53
Excel Function      | Category                       | PhpSpreadsheet Function
54
--------------------|--------------------------------|-------------------------------------------
55
ABS                 | CATEGORY_MATH_AND_TRIG         | abs
56
AND                 | CATEGORY_LOGICAL               | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd
57
58
## I
59
60
Excel Function      | Category                       | PhpSpreadsheet Function
61
--------------------|--------------------------------|-------------------------------------------
62
IFS                 | CATEGORY_LOGICAL               | **Not yet Implemented**
63
64
EXPECTED
65
66
            ],
67
        ];
68
    }
69
70
    public function providerGenerateFunctionListByCategory(): array
71
    {
72
        return [
73
            [
74
                [
75
                    'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'],
76
                    'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']],
77
                    'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']],
78
                ],
79
                <<<'EXPECTED'
80
# Function list by category
81
82
## CATEGORY_CUBE
83
84
Excel Function      | PhpSpreadsheet Function
85
--------------------|-------------------------------------------
86
87
## CATEGORY_DATABASE
88
89
Excel Function      | PhpSpreadsheet Function
90
--------------------|-------------------------------------------
91
92
## CATEGORY_DATE_AND_TIME
93
94
Excel Function      | PhpSpreadsheet Function
95
--------------------|-------------------------------------------
96
97
## CATEGORY_ENGINEERING
98
99
Excel Function      | PhpSpreadsheet Function
100
--------------------|-------------------------------------------
101
102
## CATEGORY_FINANCIAL
103
104
Excel Function      | PhpSpreadsheet Function
105
--------------------|-------------------------------------------
106
107
## CATEGORY_INFORMATION
108
109
Excel Function      | PhpSpreadsheet Function
110
--------------------|-------------------------------------------
111
112
## CATEGORY_LOGICAL
113
114
Excel Function      | PhpSpreadsheet Function
115
--------------------|-------------------------------------------
116
AND                 | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd
117
IFS                 | **Not yet Implemented**
118
119
## CATEGORY_LOOKUP_AND_REFERENCE
120
121
Excel Function      | PhpSpreadsheet Function
122
--------------------|-------------------------------------------
123
124
## CATEGORY_MATH_AND_TRIG
125
126
Excel Function      | PhpSpreadsheet Function
127
--------------------|-------------------------------------------
128
ABS                 | abs
129
130
## CATEGORY_STATISTICAL
131
132
Excel Function      | PhpSpreadsheet Function
133
--------------------|-------------------------------------------
134
135
## CATEGORY_TEXT_AND_DATA
136
137
Excel Function      | PhpSpreadsheet Function
138
--------------------|-------------------------------------------
139
140
EXPECTED
141
142
            ],
143
        ];
144
    }
145
}
146