File: rules.phpt

package info (click to toggle)
php-console-table 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 212 kB
  • sloc: php: 498; xml: 414; sh: 5; makefile: 4
file content (74 lines) | stat: -rw-r--r-- 1,526 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--TEST--
Horizontal rules
--FILE--
<?php

if (file_exists(dirname(__FILE__) . '/../Table.php')) {
    require_once dirname(__FILE__) . '/../Table.php';
} else {
    require_once 'Console/Table.php';
}

$data = array(
    array('one', 'two'),
    CONSOLE_TABLE_HORIZONTAL_RULE,
    array('three', 'four'),
    CONSOLE_TABLE_HORIZONTAL_RULE,
    CONSOLE_TABLE_HORIZONTAL_RULE,
    array('five', 'six'),
    array('seven', 'eight'),
);

$table = new Console_Table();
$table->setHeaders(array('foo', 'bar'));
$table->addData($data);
$table->addSeparator();
echo $table->getTable();
echo "=========================\n";

$table = new Console_Table(CONSOLE_TABLE_ALIGN_LEFT, '');
$table->setHeaders(array('foo', 'bar'));
$table->addData($data);
$table->addSeparator();
echo $table->getTable();
echo "=========================\n";

$table = new Console_Table(CONSOLE_TABLE_ALIGN_LEFT, '#', 0);
$table->setHeaders(array('foo', 'bar'));
$table->addData($data);
$table->addSeparator();
echo $table->getTable();

?>
--EXPECT--
+-------+-------+
| foo   | bar   |
+-------+-------+
| one   | two   |
+-------+-------+
| three | four  |
+-------+-------+
+-------+-------+
| five  | six   |
| seven | eight |
+-------+-------+
+-------+-------+
=========================
 foo    bar   
 one    two   
 three  four  
 five   six   
 seven  eight 
=========================
#############
#foo  #bar  #
#############
#one  #two  #
#############
#three#four #
#############
#############
#five #six  #
#seven#eight#
#############
#############