12 namespace Symfony\Component\Console\Tests\Helper;
26 $this->stream = fopen(
'php://memory',
'r+');
31 fclose($this->stream);
38 public function testRender($headers, $rows, $style, $expected)
42 ->setHeaders($headers)
58 ->setHeaders($headers)
74 ->setHeaders($headers)
77 foreach ($rows as $row) {
88 array(
'99921-58-10-7',
'Divine Comedy',
'Dante Alighieri'),
89 array(
'9971-5-0210-0',
'A Tale of Two Cities',
'Charles Dickens'),
90 array(
'960-425-059-0',
'The Lord of the Rings',
'J. R. R. Tolkien'),
91 array(
'80-902734-1-6',
'And Then There Were None',
'Agatha Christie'),
96 array(
'ISBN',
'Title',
'Author'),
100 +---------------+--------------------------+------------------+
101 | ISBN | Title | Author |
102 +---------------+--------------------------+------------------+
103 | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
104 | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
105 | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
106 | 80-902734-1-6 | And Then There Were None | Agatha Christie |
107 +---------------+--------------------------+------------------+
112 array(
'ISBN',
'Title',
'Author'),
117 99921-58-10-7 Divine Comedy Dante Alighieri
118 9971-5-0210-0 A Tale of Two Cities Charles Dickens
119 960-425-059-0 The Lord of the Rings J. R. R. Tolkien
120 80-902734-1-6 And Then There Were None Agatha Christie
125 array(
'ISBN',
'Title',
'Author'),
129 =============== ========================== ==================
131 =============== ========================== ==================
132 99921-58-10-7 Divine Comedy Dante Alighieri
133 9971-5-0210-0 A Tale of Two Cities Charles Dickens
134 960-425-059-0 The Lord of the Rings J. R. R. Tolkien
135 80-902734-1-6 And Then There Were None Agatha Christie
136 =============== ========================== ==================
141 array(
'ISBN',
'Title'),
143 array(
'99921-58-10-7',
'Divine Comedy',
'Dante Alighieri'),
144 array(
'9971-5-0210-0'),
145 array(
'960-425-059-0',
'The Lord of the Rings',
'J. R. R. Tolkien'),
146 array(
'80-902734-1-6',
'And Then There Were None',
'Agatha Christie'),
150 +---------------+--------------------------+------------------+
152 +---------------+--------------------------+------------------+
153 | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
154 | 9971-5-0210-0 | | |
155 | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
156 | 80-902734-1-6 | And Then There Were None | Agatha Christie |
157 +---------------+--------------------------+------------------+
164 array(
'99921-58-10-7',
'Divine Comedy',
'Dante Alighieri'),
165 array(
'9971-5-0210-0'),
166 array(
'960-425-059-0',
'The Lord of the Rings',
'J. R. R. Tolkien'),
167 array(
'80-902734-1-6',
'And Then There Were None',
'Agatha Christie'),
171 +---------------+--------------------------+------------------+
172 | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
173 | 9971-5-0210-0 | | |
174 | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
175 | 80-902734-1-6 | And Then There Were None | Agatha Christie |
176 +---------------+--------------------------+------------------+
181 array(
'ISBN',
'Title',
'Author'),
183 array(
'99921-58-10-7',
"Divine\nComedy",
'Dante Alighieri'),
184 array(
'9971-5-0210-2',
"Harry Potter\nand the Chamber of Secrets",
"Rowling\nJoanne K."),
185 array(
'9971-5-0210-2',
"Harry Potter\nand the Chamber of Secrets",
"Rowling\nJoanne K."),
186 array(
'960-425-059-0',
'The Lord of the Rings',
"J. R. R.\nTolkien"),
190 +---------------+----------------------------+-----------------+
191 | ISBN | Title | Author |
192 +---------------+----------------------------+-----------------+
193 | 99921-58-10-7 | Divine | Dante Alighieri |
195 | 9971-5-0210-2 | Harry Potter | Rowling |
196 | | and the Chamber of Secrets | Joanne K. |
197 | 9971-5-0210-2 | Harry Potter | Rowling |
198 | | and the Chamber of Secrets | Joanne K. |
199 | 960-425-059-0 | The Lord of the Rings | J. R. R. |
201 +---------------+----------------------------+-----------------+
206 array(
'ISBN',
'Title'),
222 'Cell text with tags used for Output styling' => array(
223 array(
'ISBN',
'Title',
'Author'),
225 array(
'<info>99921-58-10-7</info>',
'<error>Divine Comedy</error>',
'<fg=blue;bg=white>Dante Alighieri</fg=blue;bg=white>'),
226 array(
'9971-5-0210-0',
'A Tale of Two Cities',
'<info>Charles Dickens</>'),
230 +---------------+----------------------+-----------------+
231 | ISBN | Title | Author |
232 +---------------+----------------------+-----------------+
233 | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
234 | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
235 +---------------+----------------------+-----------------+
239 'Cell text with tags not used for Output styling' => array(
240 array(
'ISBN',
'Title',
'Author'),
242 array(
'<strong>99921-58-10-700</strong>',
'<f>Divine Com</f>',
'Dante Alighieri'),
243 array(
'9971-5-0210-0',
'A Tale of Two Cities',
'Charles Dickens'),
247 +----------------------------------+----------------------+-----------------+
248 | ISBN | Title | Author |
249 +----------------------------------+----------------------+-----------------+
250 | <strong>99921-58-10-700</strong> | <f>Divine Com</f> | Dante Alighieri |
251 | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
252 +----------------------------------+----------------------+-----------------+
256 'Cell with colspan' => array(
257 array(
'ISBN',
'Title',
'Author'),
259 array(
'99921-58-10-7',
'Divine Comedy',
'Dante Alighieri'),
261 array(
new TableCell(
'Divine Comedy(Dante Alighieri)', array(
'colspan' => 3))),
264 new TableCell(
'Arduino: A Quick-Start Guide', array(
'colspan' => 2)),
270 new TableCell(
"A Tale of \nTwo Cities", array(
'colspan' => 2)),
275 +----------------+---------------+-----------------+
276 | ISBN | Title | Author |
277 +----------------+---------------+-----------------+
278 | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
279 +----------------+---------------+-----------------+
280 | Divine Comedy(Dante Alighieri) |
281 +----------------+---------------+-----------------+
282 | Arduino: A Quick-Start Guide | Mark Schmidt |
283 +----------------+---------------+-----------------+
284 | 9971-5-0210-0 | A Tale of |
286 +----------------+---------------+-----------------+
290 'Cell with rowspan' => array(
291 array(
'ISBN',
'Title',
'Author'),
294 new TableCell(
'9971-5-0210-0', array(
'rowspan' => 3)),
298 array(
'A Tale of Two Cities',
'Charles Dickens'),
299 array(
"The Lord of \nthe Rings",
"J. R. \nR. Tolkien"),
301 array(
'80-902734-1-6',
new TableCell(
"And Then \nThere \nWere None", array(
'rowspan' => 3)),
'Agatha Christie'),
302 array(
'80-902734-1-7',
'Test'),
306 +---------------+----------------------+-----------------+
307 | ISBN | Title | Author |
308 +---------------+----------------------+-----------------+
309 | 9971-5-0210-0 | Divine Comedy | Dante Alighieri |
310 | | A Tale of Two Cities | Charles Dickens |
311 | | The Lord of | J. R. |
312 | | the Rings | R. Tolkien |
313 +---------------+----------------------+-----------------+
314 | 80-902734-1-6 | And Then | Agatha Christie |
315 | 80-902734-1-7 | There | Test |
317 +---------------+----------------------+-----------------+
321 'Cell with rowspan and colspan' => array(
322 array(
'ISBN',
'Title',
'Author'),
325 new TableCell(
'9971-5-0210-0', array(
'rowspan' => 2,
'colspan' => 2)),
328 array(
'Charles Dickens'),
332 new TableCell(
'9971-5-0210-0', array(
'rowspan' => 3,
'colspan' => 2)),
334 array(
'J. R. R. Tolkien'),
339 +------------------+--------+-----------------+
340 | ISBN | Title | Author |
341 +------------------+--------+-----------------+
342 | 9971-5-0210-0 | Dante Alighieri |
343 | | Charles Dickens |
344 +------------------+--------+-----------------+
345 | Dante Alighieri | 9971-5-0210-0 |
346 | J. R. R. Tolkien | |
348 +------------------+--------+-----------------+
352 'Cell with rowspan and colspan contains new line break' => array(
353 array(
'ISBN',
'Title',
'Author'),
356 new TableCell(
"9971\n-5-\n021\n0-0", array(
'rowspan' => 2,
'colspan' => 2)),
359 array(
'Charles Dickens'),
363 new TableCell(
"9971\n-5-\n021\n0-0", array(
'rowspan' => 2,
'colspan' => 2)),
365 array(
'Charles Dickens'),
368 new TableCell(
"9971\n-5-\n021\n0-0", array(
'rowspan' => 2,
'colspan' => 2)),
369 new TableCell(
"Dante \nAlighieri", array(
'rowspan' => 2,
'colspan' => 1)),
374 +-----------------+-------+-----------------+
375 | ISBN | Title | Author |
376 +-----------------+-------+-----------------+
377 | 9971 | Dante Alighieri |
378 | -5- | Charles Dickens |
381 +-----------------+-------+-----------------+
382 | Dante Alighieri | 9971 |
383 | Charles Dickens | -5- |
386 +-----------------+-------+-----------------+
391 +-----------------+-------+-----------------+
395 'Cell with rowspan and colspan without using TableSeparator' => array(
396 array(
'ISBN',
'Title',
'Author'),
399 new TableCell(
"9971\n-5-\n021\n0-0", array(
'rowspan' => 2,
'colspan' => 2)),
402 array(
'Charles Dickens'),
405 new TableCell(
"9971\n-5-\n021\n0-0", array(
'rowspan' => 2,
'colspan' => 2)),
407 array(
'Charles Dickens'),
411 +-----------------+-------+-----------------+
412 | ISBN | Title | Author |
413 +-----------------+-------+-----------------+
414 | 9971 | Dante Alighieri |
415 | -5- | Charles Dickens |
418 | Dante Alighieri | 9971 |
419 | Charles Dickens | -5- |
422 +-----------------+-------+-----------------+
426 'Cell with rowspan and colspan with separator inside a rowspan' => array(
427 array(
'ISBN',
'Author'),
430 new TableCell(
'9971-5-0210-0', array(
'rowspan' => 3,
'colspan' => 1)),
434 array(
'Charles Dickens'),
438 +---------------+-----------------+
440 +---------------+-----------------+
441 | 9971-5-0210-0 | Dante Alighieri |
442 | |-----------------|
443 | | Charles Dickens |
444 +---------------+-----------------+
448 'Multiple header lines' => array(
450 array(
new TableCell(
'Main title', array(
'colspan' => 3))),
451 array(
'ISBN',
'Title',
'Author'),
456 +------+-------+--------+
458 +------+-------+--------+
459 | ISBN | Title | Author |
460 +------+-------+--------+
469 if (!function_exists(
'mb_strlen')) {
470 $this->markTestSkipped(
'The "mbstring" extension is not available');
475 ->setHeaders(array(
'■■'))
476 ->setRows(array(array(1234)))
477 ->setStyle(
'default')
498 ->setHorizontalBorderChar(
'.')
499 ->setVerticalBorderChar(
'.')
500 ->setCrossingChar(
'.')
506 ->setHeaders(array(
'Foo'))
507 ->setRows(array(array(
'Bar')))
508 ->setStyle(
'dotfull');
528 ->setHeaders(array(
'Foo'))
554 $this->assertEquals($table, $table->addRow(
new TableSeparator()),
'fluent interface on addRow() with a single TableSeparator() works');
566 return str_replace(PHP_EOL,
"\n", stream_get_contents($output->
getStream()));