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