Passed
Push — develop ( 043327...eb3189 )
by Adrien
24:31
created

TextDataTest::testEXACT()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
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\TextData;
8
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
9
use PHPUnit\Framework\TestCase;
10
11
class TextDataTest extends TestCase
12
{
13
    public function setUp()
14
    {
15
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
16
    }
17
18
    /**
19
     * @dataProvider providerCHAR
20
     *
21
     * @param mixed $expectedResult
22
     */
23
    public function testCHAR($expectedResult, ...$args)
24
    {
25
        $result = TextData::CHARACTER(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $character of PhpOffice\PhpSpreadsheet...n\TextData::CHARACTER() 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

25
        $result = TextData::CHARACTER(/** @scrutinizer ignore-type */ ...$args);
Loading history...
26
        self::assertEquals($expectedResult, $result);
27
    }
28
29
    public function providerCHAR()
30
    {
31
        return require 'data/Calculation/TextData/CHAR.php';
32
    }
33
34
    /**
35
     * @dataProvider providerCODE
36
     *
37
     * @param mixed $expectedResult
38
     */
39
    public function testCODE($expectedResult, ...$args)
40
    {
41
        $result = TextData::ASCIICODE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $characters of PhpOffice\PhpSpreadsheet...n\TextData::ASCIICODE() 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

41
        $result = TextData::ASCIICODE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
42
        self::assertEquals($expectedResult, $result);
43
    }
44
45
    public function providerCODE()
46
    {
47
        return require 'data/Calculation/TextData/CODE.php';
48
    }
49
50
    /**
51
     * @dataProvider providerCONCATENATE
52
     *
53
     * @param mixed $expectedResult
54
     */
55
    public function testCONCATENATE($expectedResult, ...$args)
56
    {
57
        $result = TextData::CONCATENATE(...$args);
58
        self::assertEquals($expectedResult, $result);
59
    }
60
61
    public function providerCONCATENATE()
62
    {
63
        return require 'data/Calculation/TextData/CONCATENATE.php';
64
    }
65
66
    /**
67
     * @dataProvider providerLEFT
68
     *
69
     * @param mixed $expectedResult
70
     */
71
    public function testLEFT($expectedResult, ...$args)
72
    {
73
        $result = TextData::LEFT(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...lation\TextData::LEFT() 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

73
        $result = TextData::LEFT(/** @scrutinizer ignore-type */ ...$args);
Loading history...
74
        self::assertEquals($expectedResult, $result);
75
    }
76
77
    public function providerLEFT()
78
    {
79
        return require 'data/Calculation/TextData/LEFT.php';
80
    }
81
82
    /**
83
     * @dataProvider providerMID
84
     *
85
     * @param mixed $expectedResult
86
     */
87
    public function testMID($expectedResult, ...$args)
88
    {
89
        $result = TextData::MID(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ulation\TextData::MID() 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

89
        $result = TextData::MID(/** @scrutinizer ignore-type */ ...$args);
Loading history...
90
        self::assertEquals($expectedResult, $result);
91
    }
92
93
    public function providerMID()
94
    {
95
        return require 'data/Calculation/TextData/MID.php';
96
    }
97
98
    /**
99
     * @dataProvider providerRIGHT
100
     *
101
     * @param mixed $expectedResult
102
     */
103
    public function testRIGHT($expectedResult, ...$args)
104
    {
105
        $result = TextData::RIGHT(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ation\TextData::RIGHT() 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

105
        $result = TextData::RIGHT(/** @scrutinizer ignore-type */ ...$args);
Loading history...
106
        self::assertEquals($expectedResult, $result);
107
    }
108
109
    public function providerRIGHT()
110
    {
111
        return require 'data/Calculation/TextData/RIGHT.php';
112
    }
113
114
    /**
115
     * @dataProvider providerLOWER
116
     *
117
     * @param mixed $expectedResult
118
     */
119
    public function testLOWER($expectedResult, ...$args)
120
    {
121
        $result = TextData::LOWERCASE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $mixedCaseString of PhpOffice\PhpSpreadsheet...n\TextData::LOWERCASE() 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

121
        $result = TextData::LOWERCASE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
122
        self::assertEquals($expectedResult, $result);
123
    }
124
125
    public function providerLOWER()
126
    {
127
        return require 'data/Calculation/TextData/LOWER.php';
128
    }
129
130
    /**
131
     * @dataProvider providerUPPER
132
     *
133
     * @param mixed $expectedResult
134
     */
135
    public function testUPPER($expectedResult, ...$args)
136
    {
137
        $result = TextData::UPPERCASE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $mixedCaseString of PhpOffice\PhpSpreadsheet...n\TextData::UPPERCASE() 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

137
        $result = TextData::UPPERCASE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
138
        self::assertEquals($expectedResult, $result);
139
    }
140
141
    public function providerUPPER()
142
    {
143
        return require 'data/Calculation/TextData/UPPER.php';
144
    }
145
146
    /**
147
     * @dataProvider providerPROPER
148
     *
149
     * @param mixed $expectedResult
150
     */
151
    public function testPROPER($expectedResult, ...$args)
152
    {
153
        $result = TextData::PROPERCASE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $mixedCaseString of PhpOffice\PhpSpreadsheet...\TextData::PROPERCASE() 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

153
        $result = TextData::PROPERCASE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
154
        self::assertEquals($expectedResult, $result);
155
    }
156
157
    public function providerPROPER()
158
    {
159
        return require 'data/Calculation/TextData/PROPER.php';
160
    }
161
162
    /**
163
     * @dataProvider providerLEN
164
     *
165
     * @param mixed $expectedResult
166
     */
167
    public function testLEN($expectedResult, ...$args)
168
    {
169
        $result = TextData::STRINGLENGTH(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...extData::STRINGLENGTH() 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

169
        $result = TextData::STRINGLENGTH(/** @scrutinizer ignore-type */ ...$args);
Loading history...
170
        self::assertEquals($expectedResult, $result);
171
    }
172
173
    public function providerLEN()
174
    {
175
        return require 'data/Calculation/TextData/LEN.php';
176
    }
177
178
    /**
179
     * @dataProvider providerSEARCH
180
     *
181
     * @param mixed $expectedResult
182
     */
183
    public function testSEARCH($expectedResult, ...$args)
184
    {
185
        $result = TextData::SEARCHINSENSITIVE(...$args);
186
        self::assertEquals($expectedResult, $result);
187
    }
188
189
    public function providerSEARCH()
190
    {
191
        return require 'data/Calculation/TextData/SEARCH.php';
192
    }
193
194
    /**
195
     * @dataProvider providerFIND
196
     *
197
     * @param mixed $expectedResult
198
     */
199
    public function testFIND($expectedResult, ...$args)
200
    {
201
        $result = TextData::SEARCHSENSITIVE(...$args);
202
        self::assertEquals($expectedResult, $result);
203
    }
204
205
    public function providerFIND()
206
    {
207
        return require 'data/Calculation/TextData/FIND.php';
208
    }
209
210
    /**
211
     * @dataProvider providerREPLACE
212
     *
213
     * @param mixed $expectedResult
214
     */
215
    public function testREPLACE($expectedResult, ...$args)
216
    {
217
        $result = TextData::REPLACE(...$args);
218
        self::assertEquals($expectedResult, $result);
219
    }
220
221
    public function providerREPLACE()
222
    {
223
        return require 'data/Calculation/TextData/REPLACE.php';
224
    }
225
226
    /**
227
     * @dataProvider providerSUBSTITUTE
228
     *
229
     * @param mixed $expectedResult
230
     */
231
    public function testSUBSTITUTE($expectedResult, ...$args)
232
    {
233
        $result = TextData::SUBSTITUTE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $text of PhpOffice\PhpSpreadsheet...\TextData::SUBSTITUTE() 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

233
        $result = TextData::SUBSTITUTE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
234
        self::assertEquals($expectedResult, $result);
235
    }
236
237
    public function providerSUBSTITUTE()
238
    {
239
        return require 'data/Calculation/TextData/SUBSTITUTE.php';
240
    }
241
242
    /**
243
     * @dataProvider providerTRIM
244
     *
245
     * @param mixed $expectedResult
246
     */
247
    public function testTRIM($expectedResult, ...$args)
248
    {
249
        $result = TextData::TRIMSPACES(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $stringValue of PhpOffice\PhpSpreadsheet...\TextData::TRIMSPACES() 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

249
        $result = TextData::TRIMSPACES(/** @scrutinizer ignore-type */ ...$args);
Loading history...
250
        self::assertEquals($expectedResult, $result);
251
    }
252
253
    public function providerTRIM()
254
    {
255
        return require 'data/Calculation/TextData/TRIM.php';
256
    }
257
258
    /**
259
     * @dataProvider providerCLEAN
260
     *
261
     * @param mixed $expectedResult
262
     */
263
    public function testCLEAN($expectedResult, ...$args)
264
    {
265
        $result = TextData::TRIMNONPRINTABLE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $stringValue of PhpOffice\PhpSpreadsheet...ata::TRIMNONPRINTABLE() 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

265
        $result = TextData::TRIMNONPRINTABLE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
266
        self::assertEquals($expectedResult, $result);
267
    }
268
269
    public function providerCLEAN()
270
    {
271
        return require 'data/Calculation/TextData/CLEAN.php';
272
    }
273
274
    /**
275
     * @dataProvider providerDOLLAR
276
     *
277
     * @param mixed $expectedResult
278
     */
279
    public function testDOLLAR($expectedResult, ...$args)
280
    {
281
        $result = TextData::DOLLAR(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...tion\TextData::DOLLAR() 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

281
        $result = TextData::DOLLAR(/** @scrutinizer ignore-type */ ...$args);
Loading history...
282
        self::assertEquals($expectedResult, $result);
283
    }
284
285
    public function providerDOLLAR()
286
    {
287
        return require 'data/Calculation/TextData/DOLLAR.php';
288
    }
289
290
    /**
291
     * @dataProvider providerFIXED
292
     *
293
     * @param mixed $expectedResult
294
     */
295
    public function testFIXED($expectedResult, ...$args)
296
    {
297
        $result = TextData::FIXEDFORMAT(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...TextData::FIXEDFORMAT() 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

297
        $result = TextData::FIXEDFORMAT(/** @scrutinizer ignore-type */ ...$args);
Loading history...
298
        self::assertEquals($expectedResult, $result);
299
    }
300
301
    public function providerFIXED()
302
    {
303
        return require 'data/Calculation/TextData/FIXED.php';
304
    }
305
306
    /**
307
     * @dataProvider providerT
308
     *
309
     * @param mixed $expectedResult
310
     */
311
    public function testT($expectedResult, ...$args)
312
    {
313
        $result = TextData::RETURNSTRING(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $testValue of PhpOffice\PhpSpreadsheet...extData::RETURNSTRING() 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

313
        $result = TextData::RETURNSTRING(/** @scrutinizer ignore-type */ ...$args);
Loading history...
314
        self::assertEquals($expectedResult, $result);
315
    }
316
317
    public function providerT()
318
    {
319
        return require 'data/Calculation/TextData/T.php';
320
    }
321
322
    /**
323
     * @dataProvider providerTEXT
324
     *
325
     * @param mixed $expectedResult
326
     */
327
    public function testTEXT($expectedResult, ...$args)
328
    {
329
        //    Enforce decimal and thousands separator values to UK/US, and currency code to USD
330
        StringHelper::setDecimalSeparator('.');
331
        StringHelper::setThousandsSeparator(',');
332
        StringHelper::setCurrencyCode('$');
333
334
        $result = TextData::TEXTFORMAT(...$args);
335
        self::assertEquals($expectedResult, $result);
336
    }
337
338
    public function providerTEXT()
339
    {
340
        return require 'data/Calculation/TextData/TEXT.php';
341
    }
342
343
    /**
344
     * @dataProvider providerVALUE
345
     *
346
     * @param mixed $expectedResult
347
     */
348
    public function testVALUE($expectedResult, ...$args)
349
    {
350
        StringHelper::setDecimalSeparator('.');
351
        StringHelper::setThousandsSeparator(' ');
352
        StringHelper::setCurrencyCode('$');
353
354
        $result = TextData::VALUE(...$args);
1 ignored issue
show
Bug introduced by
$args is expanded, but the parameter $value of PhpOffice\PhpSpreadsheet...ation\TextData::VALUE() 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

354
        $result = TextData::VALUE(/** @scrutinizer ignore-type */ ...$args);
Loading history...
355
        self::assertEquals($expectedResult, $result, null, 1E-8);
356
    }
357
358
    public function providerVALUE()
359
    {
360
        return require 'data/Calculation/TextData/VALUE.php';
361
    }
362
363
    /**
364
     * @dataProvider providerEXACT
365
     *
366
     * @param mixed $expectedResult
367
     * @param array $args
368
     */
369
    public function testEXACT($expectedResult, ...$args)
370
    {
371
        StringHelper::setDecimalSeparator('.');
372
        StringHelper::setThousandsSeparator(' ');
373
        StringHelper::setCurrencyCode('$');
374
375
        $result = TextData::EXACT(...$args);
376
        self::assertSame($expectedResult, $result, null);
377
    }
378
379
    /**
380
     * @return array
381
     */
382
    public function providerEXACT()
383
    {
384
        return require 'data/Calculation/TextData/EXACT.php';
385
    }
386
}
387