Drupal investigation

multiline.phpt 1.6KB

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