GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0dcb27...fb7903 )
by Mewes
11:26
created

BasicTwigTest::testDocumentTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Tests\Twig;
4
5
use PhpOffice\PhpSpreadsheet\Cell\DataType;
6
7
/**
8
 * Class BasicTwigTest.
9
 */
10
class BasicTwigTest extends BaseTwigTest
11
{
12
    protected static $TEMP_PATH = '/../../tmp/basic/';
13
14
    //
15
    // PhpUnit
16
    //
17
18
    /**
19
     * @return array
20
     */
21
    public function formatProvider()
22
    {
23
        return [['ods'], ['xls'], ['xlsx']];
24
    }
25
26
    //
27
    // Tests
28
    //
29
30
    /**
31
     * @param string $format
32
     *
33
     * @throws \Exception
34
     *
35
     * @dataProvider formatProvider
36
     */
37 View Code Duplication
    public function testBlock($format)
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...
38
    {
39
        $document = $this->getDocument('block', $format);
40
        static::assertNotNull($document, 'Document does not exist');
41
42
        $sheet = $document->getSheetByName('Test');
43
        static::assertNotNull($sheet, 'Sheet does not exist');
44
45
        static::assertEquals('Hello', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
46
        static::assertEquals('World', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
47
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
48
        static::assertEquals('Bar', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
49
    }
50
51
    /**
52
     * @param string $format
53
     *
54
     * @throws \Exception
55
     *
56
     * @dataProvider formatProvider
57
     */
58 View Code Duplication
    public function testBlockOverrideCell($format)
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...
59
    {
60
        $document = $this->getDocument('blockOverrideCell', $format);
61
        static::assertNotNull($document, 'Document does not exist');
62
63
        $sheet = $document->getSheetByName('Test');
64
        static::assertNotNull($sheet, 'Sheet does not exist');
65
66
        static::assertEquals('Hello', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
67
        static::assertEquals('World', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
68
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
69
        static::assertEquals('Bar2', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
70
    }
71
72
    /**
73
     * @param string $format
74
     *
75
     * @throws \Exception
76
     *
77
     * @dataProvider formatProvider
78
     */
79 View Code Duplication
    public function testBlockOverrideContent($format)
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...
80
    {
81
        $document = $this->getDocument('blockOverrideContent', $format);
82
        static::assertNotNull($document, 'Document does not exist');
83
84
        $sheet = $document->getSheetByName('Test');
85
        static::assertNotNull($sheet, 'Sheet does not exist');
86
87
        static::assertEquals('Hello', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
88
        static::assertEquals('World', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
89
        static::assertEquals('Foo2', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
90
        static::assertEquals('Bar', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
91
    }
92
93
    /**
94
     * @param string $format
95
     *
96
     * @throws \Exception
97
     *
98
     * @dataProvider formatProvider
99
     */
100 View Code Duplication
    public function testBlockOverrideRow($format)
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...
101
    {
102
        $document = $this->getDocument('blockOverrideRow', $format);
103
        static::assertNotNull($document, 'Document does not exist');
104
105
        $sheet = $document->getSheetByName('Test');
106
        static::assertNotNull($sheet, 'Sheet does not exist');
107
108
        static::assertEquals('Hello2', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
109
        static::assertEquals('World2', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
110
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
111
        static::assertEquals('Bar', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
112
    }
113
114
    /**
115
     * @param string $format
116
     *
117
     * @throws \Exception
118
     *
119
     * @dataProvider formatProvider
120
     */
121 View Code Duplication
    public function testBlockOverrideSheet($format)
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...
122
    {
123
        $document = $this->getDocument('blockOverrideSheet', $format);
124
        static::assertNotNull($document, 'Document does not exist');
125
126
        $sheet = $document->getSheetByName('Test2');
127
        static::assertNotNull($sheet, 'Sheet does not exist');
128
129
        static::assertEquals('Hello3', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
130
        static::assertEquals('World3', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
131
        static::assertNotEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
132
        static::assertNotEquals('Bar', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
133
    }
134
135
    /**
136
     * @param string $format
137
     *
138
     * @throws \Exception
139
     *
140
     * @dataProvider formatProvider
141
     */
142
    public function testCellFormula($format)
143
    {
144
        $document = $this->getDocument('cellFormula', $format);
145
        static::assertNotNull($document, 'Document does not exist');
146
147
        $sheet = $document->getSheetByName('Test');
148
        static::assertNotNull($sheet, 'Sheet does not exist');
149
150
        static::assertEquals('=A1*B1+2', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
151
        static::assertTrue($sheet->getCell('A2')->isFormula(), 'Unexpected value in isFormula');
152
        static::assertEquals(1337, $sheet->getCell('A2')->getCalculatedValue(), 'Unexpected calculated value in A2');
153
154
        static::assertEquals('=SUM(A1:B1)', $sheet->getCell('A3')->getValue(), 'Unexpected value in A3');
155
        static::assertTrue($sheet->getCell('A3')->isFormula(), 'Unexpected value in isFormula');
156
        static::assertEquals(669.5, $sheet->getCell('A3')->getCalculatedValue(), 'Unexpected calculated value in A3');
157
    }
158
159
    /**
160
     * @param string $format
161
     *
162
     * @throws \Exception
163
     *
164
     * @dataProvider formatProvider
165
     */
166
    public function testCellIndex($format)
167
    {
168
        $document = $this->getDocument('cellIndex', $format);
169
        static::assertNotNull($document, 'Document does not exist');
170
171
        $sheet = $document->getSheetByName('Test');
172
        static::assertNotNull($sheet, 'Sheet does not exist');
173
174
        static::assertEquals('Foo', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
175
        static::assertEquals('Hello', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
176
        static::assertNotEquals('Bar', $sheet->getCell('C1')->getValue(), 'Unexpected value in C1');
177
        static::assertEquals('Lorem', $sheet->getCell('C1')->getValue(), 'Unexpected value in C1');
178
        static::assertEquals('Ipsum', $sheet->getCell('D1')->getValue(), 'Unexpected value in D1');
179
        static::assertEquals('World', $sheet->getCell('E1')->getValue(), 'Unexpected value in E1');
180
181
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A1');
182
        static::assertEquals('Bar', $sheet->getCell('B2')->getValue(), 'Unexpected value in B1');
183
        static::assertEquals('Lorem', $sheet->getCell('C2')->getValue(), 'Unexpected value in C1');
184
        static::assertEquals('Ipsum', $sheet->getCell('D2')->getValue(), 'Unexpected value in D1');
185
        static::assertEquals('Hello', $sheet->getCell('E2')->getValue(), 'Unexpected value in E1');
186
        static::assertEquals('World', $sheet->getCell('F2')->getValue(), 'Unexpected value in F1');
187
    }
188
189
    /**
190
     * @param string $format
191
     *
192
     * @throws \Exception
193
     *
194
     * @dataProvider formatProvider
195
     */
196
    public function testCellProperties($format)
197
    {
198
        $document = $this->getDocument('cellProperties', $format);
199
        static::assertNotNull($document, 'Document does not exist');
200
201
        $sheet = $document->getSheetByName('Test');
202
        static::assertNotNull($sheet, 'Sheet does not exist');
203
204
        $cell = $sheet->getCell('A1');
205
        static::assertNotNull($cell, 'Cell does not exist');
206
207
        $dataValidation = $cell->getDataValidation();
208
        static::assertNotNull($dataValidation, 'DataValidation does not exist');
209
210
        $style = $cell->getStyle();
211
        static::assertNotNull($style, 'Style does not exist');
212
213
        static::assertEquals(42, $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
214
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('A2')->getDataType(), 'Unexpected value in dataType');
215
216
        static::assertEquals('42', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
217
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('B2')->getDataType(), 'Unexpected value in dataType');
218
219
        static::assertEquals(42, $sheet->getCell('C2')->getValue(), 'Unexpected value in C2');
220
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('C2')->getDataType(), 'Unexpected value in dataType');
221
222
        static::assertEquals('007', $sheet->getCell('A3')->getValue(), 'Unexpected value in A3');
223
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('A3')->getDataType(), 'Unexpected value in dataType');
224
225
        static::assertEquals('007', $sheet->getCell('B3')->getValue(), 'Unexpected value in B3');
226
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('B3')->getDataType(), 'Unexpected value in dataType');
227
228
        static::assertEquals(7, $sheet->getCell('C3')->getValue(), 'Unexpected value in C3');
229
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('C3')->getDataType(), 'Unexpected value in dataType');
230
231
        static::assertEquals(0.1337, $sheet->getCell('A4')->getValue(), 'Unexpected value in A4');
232
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('A4')->getDataType(), 'Unexpected value in dataType');
233
234
        static::assertEquals('0.13370', $sheet->getCell('B4')->getValue(), 'Unexpected value in B4');
235
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('B4')->getDataType(), 'Unexpected value in dataType');
236
237
        static::assertEquals(0.1337, $sheet->getCell('C4')->getValue(), 'Unexpected value in C4');
238
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('C4')->getDataType(), 'Unexpected value in dataType');
239
    }
240
241
    /**
242
     * @param string $format
243
     *
244
     * @throws \Exception
245
     *
246
     * @dataProvider formatProvider
247
     */
248
    public function testCellValue($format)
249
    {
250
        $document = $this->getDocument('cellValue', $format);
251
        static::assertNotNull($document, 'Document does not exist');
252
253
        $sheet = $document->getSheetByName('Test');
254
        static::assertNotNull($sheet, 'Sheet does not exist');
255
256
        static::assertEquals(667.5, $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
257
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('A1')->getDataType(), 'Unexpected value in dataType');
258
259
        static::assertEquals(2, $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
260
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('B1')->getDataType(), 'Unexpected value in dataType');
261
262
        static::assertEquals('007', $sheet->getCell('C1')->getValue(), 'Unexpected value in C1');
263
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('C1')->getDataType(), 'Unexpected value in dataType');
264
265
        static::assertEquals('foo', $sheet->getCell('D1')->getValue(), 'Unexpected value in D1');
266
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('D1')->getDataType(), 'Unexpected value in dataType');
267
268
        static::assertEquals(0.42, $sheet->getCell('E1')->getValue(), 'Unexpected value in E1');
269
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('E1')->getDataType(), 'Unexpected value in dataType');
270
271
        static::assertEquals(21, $sheet->getCell('F1')->getValue(), 'Unexpected value in F1');
272
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('F1')->getDataType(), 'Unexpected value in dataType');
273
274
        static::assertEquals(1.2, $sheet->getCell('G1')->getValue(), 'Unexpected value in G1');
275
        static::assertEquals(DataType::TYPE_NUMERIC, $sheet->getCell('G1')->getDataType(), 'Unexpected value in dataType');
276
277
        static::assertEquals('BAR', $sheet->getCell('H1')->getValue(), 'Unexpected value in H1');
278
        static::assertEquals(DataType::TYPE_STRING, $sheet->getCell('H1')->getDataType(), 'Unexpected value in dataType');
279
    }
280
281
    /**
282
     * The following attributes are not supported by the readers and therefore cannot be tested:
283
     * $security->getLockRevision() -> true
284
     * $security->getLockStructure() -> true
285
     * $security->getLockWindows() -> true
286
     * $security->getRevisionsPassword() -> 'test'
287
     * $security->getWorkbookPassword() -> 'test'.
288
     *
289
     * @param string $format
290
     *
291
     * @throws \Exception
292
     *
293
     * @dataProvider formatProvider
294
     */
295
    public function testDocumentProperties($format)
296
    {
297
        $document = $this->getDocument('documentProperties', $format);
298
        static::assertNotNull($document, 'Document does not exist');
299
300
        $properties = $document->getProperties();
301
        static::assertNotNull($properties, 'Properties do not exist');
302
303
        // +/- 24h range to allow possible timezone differences (946684800)
304
        static::assertGreaterThanOrEqual(946598400, $properties->getCreated(), 'Unexpected value in created');
305
        static::assertLessThanOrEqual(946771200, $properties->getCreated(), 'Unexpected value in created');
306
        static::assertEquals('Test creator', $properties->getCreator(), 'Unexpected value in creator');
307
308
        $defaultStyle = $document->getDefaultStyle();
309
        static::assertNotNull($defaultStyle, 'DefaultStyle does not exist');
310
311
        static::assertEquals('Test description', $properties->getDescription(), 'Unexpected value in description');
312
        // +/- 24h range to allow possible timezone differences (946684800)
313
        static::assertGreaterThanOrEqual(946598400, $properties->getModified(), 'Unexpected value in modified');
314
        static::assertLessThanOrEqual(946771200, $properties->getModified(), 'Unexpected value in modified');
315
316
        $security = $document->getSecurity();
317
        static::assertNotNull($security, 'Security does not exist');
318
319
        static::assertEquals('Test subject', $properties->getSubject(), 'Unexpected value in subject');
320
        static::assertEquals('Test title', $properties->getTitle(), 'Unexpected value in title');
321
    }
322
323
    /**
324
     * @param string $format
325
     *
326
     * @throws \Exception
327
     *
328
     * @dataProvider formatProvider
329
     */
330 View Code Duplication
    public function testDocumentSimple($format)
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...
331
    {
332
        $document = $this->getDocument('documentSimple', $format);
333
        static::assertNotNull($document, 'Document does not exist');
334
335
        $sheet = $document->getSheetByName('Test');
336
        static::assertNotNull($sheet, 'Sheet does not exist');
337
338
        static::assertEquals('Foo', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
339
        static::assertEquals('Bar', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
340
        static::assertEquals('Hello', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
341
        static::assertEquals('World', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
342
    }
343
344
    /**
345
     * @param string $format
346
     *
347
     * @throws \Exception
348
     *
349
     * @dataProvider formatProvider
350
     */
351 View Code Duplication
    public function testDocumentTemplate($format)
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...
352
    {
353
        $document = $this->getDocument('documentTemplate.'.$format, $format);
354
        static::assertNotNull($document, 'Document does not exist');
355
356
        $sheet = $document->getSheet(0);
357
        static::assertNotNull($sheet, 'Sheet does not exist');
358
359
        static::assertEquals('Hello2', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
360
        static::assertEquals('World', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
361
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
362
        static::assertEquals('Bar2', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
363
    }
364
365
    /**
366
     * @param string $format
367
     *
368
     * @throws \Exception
369
     *
370
     * @dataProvider formatProvider
371
     */
372 View Code Duplication
    public function testDocumentWhitespace($format)
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...
373
    {
374
        $document = $this->getDocument('documentWhitespace', $format);
375
        static::assertNotNull($document, 'Document does not exist');
376
377
        $sheet = $document->getSheetByName('Test');
378
        static::assertNotNull($sheet, 'Sheet does not exist');
379
380
        static::assertEquals('Foo', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
381
        static::assertEquals('Bar', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
382
        static::assertEquals('Hello', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
383
        static::assertEquals('World', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
384
    }
385
386
    /**
387
     * @param string $format
388
     *
389
     * @throws \Exception
390
     *
391
     * @dataProvider formatProvider
392
     */
393
    public function testInclude($format)
394
    {
395
        $document = $this->getDocument('include', $format);
396
        static::assertNotNull($document, 'Document does not exist');
397
398
        $sheet = $document->getSheetByName('Test');
399
        static::assertNotNull($sheet, 'Sheet does not exist');
400
401
        static::assertEquals('Hello1', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
402
        static::assertEquals('World1', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
403
        static::assertEquals('Hello2', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
404
        static::assertEquals('World2', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
405
406
        $sheet = $document->getSheetByName('Test2');
407
        static::assertNotNull($sheet, 'Sheet does not exist');
408
409
        static::assertEquals('Hello3', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
410
        static::assertEquals('World3', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
411
    }
412
413
    /**
414
     * @param string $format
415
     *
416
     * @throws \Exception
417
     *
418
     * @dataProvider formatProvider
419
     */
420
    public function testMacro($format)
421
    {
422
        $document = $this->getDocument('macro', $format);
423
        static::assertNotNull($document, 'Document does not exist');
424
425
        $sheet = $document->getSheetByName('Test');
426
        static::assertNotNull($sheet, 'Sheet does not exist');
427
428
        static::assertEquals('Hello1', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
429
        static::assertEquals('World1', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
430
        static::assertEquals('Hello2', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
431
        static::assertEquals('World2', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
432
433
        $sheet = $document->getSheetByName('Test2');
434
        static::assertNotNull($sheet, 'Sheet does not exist');
435
436
        static::assertEquals('Hello3', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
437
        static::assertEquals('World3', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
438
439
        $sheet = $document->getSheetByName('Test3');
440
        static::assertNotNull($sheet, 'Sheet does not exist');
441
442
        static::assertEquals('Hello4', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
443
        static::assertEquals('World4', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
444
    }
445
446
    /**
447
     * @param string $format
448
     *
449
     * @throws \Exception
450
     *
451
     * @dataProvider formatProvider
452
     */
453
    public function testRowIndex($format)
454
    {
455
        $document = $this->getDocument('rowIndex', $format);
456
        static::assertNotNull($document, 'Document does not exist');
457
458
        $sheet = $document->getSheetByName('Test');
459
        static::assertNotNull($sheet, 'Sheet does not exist');
460
461
        static::assertEquals('Foo', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
462
        static::assertNotEquals('Bar', $sheet->getCell('A3')->getValue(), 'Unexpected value in A3');
463
        static::assertEquals('Lorem', $sheet->getCell('A3')->getValue(), 'Unexpected value in A3');
464
        static::assertEquals('Ipsum', $sheet->getCell('A4')->getValue(), 'Unexpected value in A4');
465
        static::assertEquals('Hello', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
466
        static::assertEquals('World', $sheet->getCell('A5')->getValue(), 'Unexpected value in A5');
467
468
        static::assertEquals('Foo', $sheet->getCell('A6')->getValue(), 'Unexpected value in A6');
469
        static::assertEquals('Bar', $sheet->getCell('A7')->getValue(), 'Unexpected value in A7');
470
        static::assertEquals('Lorem', $sheet->getCell('A8')->getValue(), 'Unexpected value in A8');
471
        static::assertEquals('Ipsum', $sheet->getCell('A9')->getValue(), 'Unexpected value in A9');
472
        static::assertEquals('Hello', $sheet->getCell('A10')->getValue(), 'Unexpected value in A10');
473
    }
474
475
    /**
476
     * @param string $format
477
     *
478
     * @throws \Exception
479
     *
480
     * @dataProvider formatProvider
481
     */
482 View Code Duplication
    public function testSheetComplex($format)
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...
483
    {
484
        $document = $this->getDocument('sheetComplex', $format);
485
        static::assertNotNull($document, 'Document does not exist');
486
487
        $sheet = $document->getSheetByName('Test 1');
488
        static::assertNotNull($sheet, 'Sheet "Test 1" does not exist');
489
        static::assertEquals('Foo', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
490
        static::assertEquals('Bar', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
491
492
        $sheet = $document->getSheetByName('Test 2');
493
        static::assertNotNull($sheet, 'Sheet "Test 2" does not exist');
494
        static::assertEquals('Hello World', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
495
    }
496
497
    /**
498
     * The following attributes are not supported by the readers and therefore cannot be tested:
499
     * $columnDimension->getAutoSize() -> false
500
     * $columnDimension->getCollapsed() -> true
501
     * $columnDimension->getColumnIndex() -> 1
502
     * $columnDimension->getVisible() -> false
503
     * $defaultColumnDimension->getAutoSize() -> true
504
     * $defaultColumnDimension->getCollapsed() -> false
505
     * $defaultColumnDimension->getColumnIndex() -> 1
506
     * $defaultColumnDimension->getVisible() -> true
507
     * $defaultRowDimension->getCollapsed() -> false
508
     * $defaultRowDimension->getRowIndex() -> 1
509
     * $defaultRowDimension->getVisible() -> true
510
     * $defaultRowDimension->getzeroHeight() -> false
511
     * $rowDimension->getCollapsed() -> true
512
     * $rowDimension->getRowIndex() -> 1
513
     * $rowDimension->getVisible() -> false
514
     * $rowDimension->getzeroHeight() -> true
515
     * $sheet->getShowGridlines() -> false.
516
     *
517
     * @param string $format
518
     *
519
     * @throws \Exception
520
     *
521
     * @dataProvider formatProvider
522
     */
523
    public function testSheetProperties($format)
524
    {
525
        $document = $this->getDocument('sheetProperties', $format);
526
        static::assertNotNull($document, 'Document does not exist');
527
528
        $sheet = $document->getSheetByName('Test');
529
        static::assertNotNull($sheet, 'Sheet does not exist');
530
531
        $defaultColumnDimension = $sheet->getDefaultColumnDimension();
532
        static::assertNotNull($defaultColumnDimension, 'DefaultColumnDimension does not exist');
533
        static::assertEquals(0, $defaultColumnDimension->getOutlineLevel(), 'Unexpected value in outlineLevel');
534
        static::assertEquals(-1, $defaultColumnDimension->getWidth(), 'Unexpected value in width');
535
        static::assertEquals(0, $defaultColumnDimension->getXfIndex(), 'Unexpected value in xfIndex');
536
537
        $columnDimension = $sheet->getColumnDimension('D');
538
        static::assertNotNull($columnDimension, 'ColumnDimension does not exist');
539
        static::assertEquals(0, $columnDimension->getXfIndex(), 'Unexpected value in xfIndex');
540
541
        $pageSetup = $sheet->getPageSetup();
542
        static::assertNotNull($pageSetup, 'PageSetup does not exist');
543
        static::assertEquals(1, $pageSetup->getFitToHeight(), 'Unexpected value in fitToHeight');
544
        static::assertFalse($pageSetup->getFitToPage(), 'Unexpected value in fitToPage');
545
        static::assertEquals(1, $pageSetup->getFitToWidth(), 'Unexpected value in fitToWidth');
546
        static::assertFalse($pageSetup->getHorizontalCentered(), 'Unexpected value in horizontalCentered');
547
        static::assertEquals(100, $pageSetup->getScale(), 'Unexpected value in scale');
548
        static::assertFalse($pageSetup->getVerticalCentered(), 'Unexpected value in verticalCentered');
549
550
        $defaultRowDimension = $sheet->getDefaultRowDimension();
551
        static::assertNotNull($defaultRowDimension, 'DefaultRowDimension does not exist');
552
        static::assertEquals(0, $defaultRowDimension->getOutlineLevel(), 'Unexpected value in outlineLevel');
553
        static::assertEquals(-1, $defaultRowDimension->getRowHeight(), 'Unexpected value in rowHeight');
554
        static::assertEquals(0, $defaultRowDimension->getXfIndex(), 'Unexpected value in xfIndex');
555
    }
556
}
557