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

TextDataTest::testSUBSTITUTE()   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\Functions;
6
use PhpSpreadsheet\Calculation\TextData;
7
use PhpSpreadsheet\Shared\StringHelper;
8
9
class TextDataTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function setUp()
12
    {
13
        Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
14
    }
15
16
    /**
17
     * @dataProvider providerCHAR
18
     */
19
    public function testCHAR()
20
    {
21
        $args = func_get_args();
22
        $expectedResult = array_pop($args);
23
        $result = call_user_func_array([TextData::class, 'CHARACTER'], $args);
24
        $this->assertEquals($expectedResult, $result);
25
    }
26
27
    public function providerCHAR()
28
    {
29
        return require 'data/Calculation/TextData/CHAR.php';
30
    }
31
32
    /**
33
     * @dataProvider providerCODE
34
     */
35
    public function testCODE()
36
    {
37
        $args = func_get_args();
38
        $expectedResult = array_pop($args);
39
        $result = call_user_func_array([TextData::class, 'ASCIICODE'], $args);
40
        $this->assertEquals($expectedResult, $result);
41
    }
42
43
    public function providerCODE()
44
    {
45
        return require 'data/Calculation/TextData/CODE.php';
46
    }
47
48
    /**
49
     * @dataProvider providerCONCATENATE
50
     */
51
    public function testCONCATENATE()
52
    {
53
        $args = func_get_args();
54
        $expectedResult = array_pop($args);
55
        $result = call_user_func_array([TextData::class, 'CONCATENATE'], $args);
56
        $this->assertEquals($expectedResult, $result);
57
    }
58
59
    public function providerCONCATENATE()
60
    {
61
        return require 'data/Calculation/TextData/CONCATENATE.php';
62
    }
63
64
    /**
65
     * @dataProvider providerLEFT
66
     */
67
    public function testLEFT()
68
    {
69
        $args = func_get_args();
70
        $expectedResult = array_pop($args);
71
        $result = call_user_func_array([TextData::class, 'LEFT'], $args);
72
        $this->assertEquals($expectedResult, $result);
73
    }
74
75
    public function providerLEFT()
76
    {
77
        return require 'data/Calculation/TextData/LEFT.php';
78
    }
79
80
    /**
81
     * @dataProvider providerMID
82
     */
83
    public function testMID()
84
    {
85
        $args = func_get_args();
86
        $expectedResult = array_pop($args);
87
        $result = call_user_func_array([TextData::class, 'MID'], $args);
88
        $this->assertEquals($expectedResult, $result);
89
    }
90
91
    public function providerMID()
92
    {
93
        return require 'data/Calculation/TextData/MID.php';
94
    }
95
96
    /**
97
     * @dataProvider providerRIGHT
98
     */
99
    public function testRIGHT()
100
    {
101
        $args = func_get_args();
102
        $expectedResult = array_pop($args);
103
        $result = call_user_func_array([TextData::class, 'RIGHT'], $args);
104
        $this->assertEquals($expectedResult, $result);
105
    }
106
107
    public function providerRIGHT()
108
    {
109
        return require 'data/Calculation/TextData/RIGHT.php';
110
    }
111
112
    /**
113
     * @dataProvider providerLOWER
114
     */
115
    public function testLOWER()
116
    {
117
        $args = func_get_args();
118
        $expectedResult = array_pop($args);
119
        $result = call_user_func_array([TextData::class, 'LOWERCASE'], $args);
120
        $this->assertEquals($expectedResult, $result);
121
    }
122
123
    public function providerLOWER()
124
    {
125
        return require 'data/Calculation/TextData/LOWER.php';
126
    }
127
128
    /**
129
     * @dataProvider providerUPPER
130
     */
131
    public function testUPPER()
132
    {
133
        $args = func_get_args();
134
        $expectedResult = array_pop($args);
135
        $result = call_user_func_array([TextData::class, 'UPPERCASE'], $args);
136
        $this->assertEquals($expectedResult, $result);
137
    }
138
139
    public function providerUPPER()
140
    {
141
        return require 'data/Calculation/TextData/UPPER.php';
142
    }
143
144
    /**
145
     * @dataProvider providerPROPER
146
     */
147
    public function testPROPER()
148
    {
149
        $args = func_get_args();
150
        $expectedResult = array_pop($args);
151
        $result = call_user_func_array([TextData::class, 'PROPERCASE'], $args);
152
        $this->assertEquals($expectedResult, $result);
153
    }
154
155
    public function providerPROPER()
156
    {
157
        return require 'data/Calculation/TextData/PROPER.php';
158
    }
159
160
    /**
161
     * @dataProvider providerLEN
162
     */
163
    public function testLEN()
164
    {
165
        $args = func_get_args();
166
        $expectedResult = array_pop($args);
167
        $result = call_user_func_array([TextData::class, 'STRINGLENGTH'], $args);
168
        $this->assertEquals($expectedResult, $result);
169
    }
170
171
    public function providerLEN()
172
    {
173
        return require 'data/Calculation/TextData/LEN.php';
174
    }
175
176
    /**
177
     * @dataProvider providerSEARCH
178
     */
179
    public function testSEARCH()
180
    {
181
        $args = func_get_args();
182
        $expectedResult = array_pop($args);
183
        $result = call_user_func_array([TextData::class, 'SEARCHINSENSITIVE'], $args);
184
        $this->assertEquals($expectedResult, $result);
185
    }
186
187
    public function providerSEARCH()
188
    {
189
        return require 'data/Calculation/TextData/SEARCH.php';
190
    }
191
192
    /**
193
     * @dataProvider providerFIND
194
     */
195
    public function testFIND()
196
    {
197
        $args = func_get_args();
198
        $expectedResult = array_pop($args);
199
        $result = call_user_func_array([TextData::class, 'SEARCHSENSITIVE'], $args);
200
        $this->assertEquals($expectedResult, $result);
201
    }
202
203
    public function providerFIND()
204
    {
205
        return require 'data/Calculation/TextData/FIND.php';
206
    }
207
208
    /**
209
     * @dataProvider providerREPLACE
210
     */
211
    public function testREPLACE()
212
    {
213
        $args = func_get_args();
214
        $expectedResult = array_pop($args);
215
        $result = call_user_func_array([TextData::class, 'REPLACE'], $args);
216
        $this->assertEquals($expectedResult, $result);
217
    }
218
219
    public function providerREPLACE()
220
    {
221
        return require 'data/Calculation/TextData/REPLACE.php';
222
    }
223
224
    /**
225
     * @dataProvider providerSUBSTITUTE
226
     */
227
    public function testSUBSTITUTE()
228
    {
229
        $args = func_get_args();
230
        $expectedResult = array_pop($args);
231
        $result = call_user_func_array([TextData::class, 'SUBSTITUTE'], $args);
232
        $this->assertEquals($expectedResult, $result);
233
    }
234
235
    public function providerSUBSTITUTE()
236
    {
237
        return require 'data/Calculation/TextData/SUBSTITUTE.php';
238
    }
239
240
    /**
241
     * @dataProvider providerTRIM
242
     */
243
    public function testTRIM()
244
    {
245
        $args = func_get_args();
246
        $expectedResult = array_pop($args);
247
        $result = call_user_func_array([TextData::class, 'TRIMSPACES'], $args);
248
        $this->assertEquals($expectedResult, $result);
249
    }
250
251
    public function providerTRIM()
252
    {
253
        return require 'data/Calculation/TextData/TRIM.php';
254
    }
255
256
    /**
257
     * @dataProvider providerCLEAN
258
     */
259
    public function testCLEAN()
260
    {
261
        $args = func_get_args();
262
        $expectedResult = array_pop($args);
263
        $result = call_user_func_array([TextData::class, 'TRIMNONPRINTABLE'], $args);
264
        $this->assertEquals($expectedResult, $result);
265
    }
266
267
    public function providerCLEAN()
268
    {
269
        return require 'data/Calculation/TextData/CLEAN.php';
270
    }
271
272
    /**
273
     * @dataProvider providerDOLLAR
274
     */
275
    public function testDOLLAR()
276
    {
277
        $args = func_get_args();
278
        $expectedResult = array_pop($args);
279
        $result = call_user_func_array([TextData::class, 'DOLLAR'], $args);
280
        $this->assertEquals($expectedResult, $result);
281
    }
282
283
    public function providerDOLLAR()
284
    {
285
        return require 'data/Calculation/TextData/DOLLAR.php';
286
    }
287
288
    /**
289
     * @dataProvider providerFIXED
290
     */
291
    public function testFIXED()
292
    {
293
        $args = func_get_args();
294
        $expectedResult = array_pop($args);
295
        $result = call_user_func_array([TextData::class, 'FIXEDFORMAT'], $args);
296
        $this->assertEquals($expectedResult, $result);
297
    }
298
299
    public function providerFIXED()
300
    {
301
        return require 'data/Calculation/TextData/FIXED.php';
302
    }
303
304
    /**
305
     * @dataProvider providerT
306
     */
307
    public function testT()
308
    {
309
        $args = func_get_args();
310
        $expectedResult = array_pop($args);
311
        $result = call_user_func_array([TextData::class, 'RETURNSTRING'], $args);
312
        $this->assertEquals($expectedResult, $result);
313
    }
314
315
    public function providerT()
316
    {
317
        return require 'data/Calculation/TextData/T.php';
318
    }
319
320
    /**
321
     * @dataProvider providerTEXT
322
     */
323 View Code Duplication
    public function testTEXT()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
324
    {
325
        //    Enforce decimal and thousands separator values to UK/US, and currency code to USD
326
        call_user_func([StringHelper::class, 'setDecimalSeparator'], '.');
327
        call_user_func([StringHelper::class, 'setThousandsSeparator'], ',');
328
        call_user_func([StringHelper::class, 'setCurrencyCode'], '$');
329
330
        $args = func_get_args();
331
        $expectedResult = array_pop($args);
332
        $result = call_user_func_array([TextData::class, 'TEXTFORMAT'], $args);
333
        $this->assertEquals($expectedResult, $result);
334
    }
335
336
    public function providerTEXT()
337
    {
338
        return require 'data/Calculation/TextData/TEXT.php';
339
    }
340
341
    /**
342
     * @dataProvider providerVALUE
343
     */
344 View Code Duplication
    public function testVALUE()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
345
    {
346
        call_user_func([StringHelper::class, 'setDecimalSeparator'], '.');
347
        call_user_func([StringHelper::class, 'setThousandsSeparator'], ' ');
348
        call_user_func([StringHelper::class, 'setCurrencyCode'], '$');
349
350
        $args = func_get_args();
351
        $expectedResult = array_pop($args);
352
        $result = call_user_func_array([TextData::class, 'VALUE'], $args);
353
        $this->assertEquals($expectedResult, $result, null, 1E-8);
354
    }
355
356
    public function providerVALUE()
357
    {
358
        return require 'data/Calculation/TextData/VALUE.php';
359
    }
360
}
361