annotate vendor/pear/console_table/tests/multiline.phpt @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 --TEST--
Chris@0 2 Multiline table cells
Chris@0 3 --FILE--
Chris@0 4 <?php
Chris@0 5
Chris@0 6 if (file_exists(dirname(__FILE__) . '/../Table.php')) {
Chris@0 7 require_once dirname(__FILE__) . '/../Table.php';
Chris@0 8 } else {
Chris@0 9 require_once 'Console/Table.php';
Chris@0 10 }
Chris@0 11
Chris@0 12 $data = array(
Chris@0 13 array('col1', '0', "col3\nmultiline", 'col4'),
Chris@0 14 array('r2col1', 'r2col2', "r2col3\nmultiline", 'r2col4'),
Chris@0 15 array('r3col1', 'r3col2', "r3col3\nmultiline\r\nverymuch", 'r3col4'),
Chris@0 16 array('r4col1', 'r4col2', "r4col3", 'r4col4'),
Chris@0 17 array('r5col1', 'r5col2', "r5col3", 'r5col4'),
Chris@0 18 );
Chris@0 19
Chris@0 20 $table = new Console_Table();
Chris@0 21 $table->setHeaders(array("h1\nmultiline", 'h2', "h3", 'h4'));
Chris@0 22 $table->addData($data);
Chris@0 23 echo $table->getTable();
Chris@0 24
Chris@0 25 echo Console_Table::fromArray(array('one line header'),
Chris@0 26 array(array("multiple\nlines"),
Chris@0 27 array('one line')));
Chris@0 28
Chris@0 29 ?>
Chris@0 30 --EXPECT--
Chris@0 31 +-----------+--------+-----------+--------+
Chris@0 32 | h1 | h2 | h3 | h4 |
Chris@0 33 | multiline | | | |
Chris@0 34 +-----------+--------+-----------+--------+
Chris@0 35 | col1 | 0 | col3 | col4 |
Chris@0 36 | | | multiline | |
Chris@0 37 | r2col1 | r2col2 | r2col3 | r2col4 |
Chris@0 38 | | | multiline | |
Chris@0 39 | r3col1 | r3col2 | r3col3 | r3col4 |
Chris@0 40 | | | multiline | |
Chris@0 41 | | | verymuch | |
Chris@0 42 | r4col1 | r4col2 | r4col3 | r4col4 |
Chris@0 43 | r5col1 | r5col2 | r5col3 | r5col4 |
Chris@0 44 +-----------+--------+-----------+--------+
Chris@0 45 +-----------------+
Chris@0 46 | one line header |
Chris@0 47 +-----------------+
Chris@0 48 | multiple |
Chris@0 49 | lines |
Chris@0 50 | one line |
Chris@0 51 +-----------------+