| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
5.phpt: 3 row 3 column, setColAttributes / updateColAttributes
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
// $Id: 5.phpt 297540 2010-04-05 19:58:39Z wiesemann $
|
|
|
6 |
require_once 'HTML/Table.php';
|
|
|
7 |
$table = new HTML_Table('width="400"');
|
|
|
8 |
|
|
|
9 |
$data[0][] = 'Foo';
|
|
|
10 |
$data[0][] = 'Bar';
|
|
|
11 |
$data[0][] = 'Test';
|
|
|
12 |
$data[1][] = 'Foo';
|
|
|
13 |
$data[1][] = 'Bar';
|
|
|
14 |
$data[1][] = 'Test';
|
|
|
15 |
$data[2][] = 'Foo';
|
|
|
16 |
$data[2][] = 'Bar';
|
|
|
17 |
$data[2][] = 'Test';
|
|
|
18 |
|
|
|
19 |
foreach($data as $key => $value) {
|
|
|
20 |
$table->addRow($value, 'bgcolor = "yellow" align = "right"');
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
// This overwrites attrs thus removing align="right"
|
|
|
24 |
$table->setColAttributes(0, 'bgcolor = "purple"');
|
|
|
25 |
// This updates attrs thus keeping aligh="right" but change bgcolor
|
|
|
26 |
$table->updateColAttributes(2, 'bgcolor = "blue"');
|
|
|
27 |
|
|
|
28 |
// output
|
|
|
29 |
echo $table->toHTML();
|
|
|
30 |
?>
|
|
|
31 |
--EXPECT--
|
|
|
32 |
<table width="400">
|
|
|
33 |
<tr>
|
|
|
34 |
<td bgcolor="purple">Foo</td>
|
|
|
35 |
<td bgcolor="yellow" align="right">Bar</td>
|
|
|
36 |
<td bgcolor="blue" align="right">Test</td>
|
|
|
37 |
</tr>
|
|
|
38 |
<tr>
|
|
|
39 |
<td bgcolor="purple">Foo</td>
|
|
|
40 |
<td bgcolor="yellow" align="right">Bar</td>
|
|
|
41 |
<td bgcolor="blue" align="right">Test</td>
|
|
|
42 |
</tr>
|
|
|
43 |
<tr>
|
|
|
44 |
<td bgcolor="purple">Foo</td>
|
|
|
45 |
<td bgcolor="yellow" align="right">Bar</td>
|
|
|
46 |
<td bgcolor="blue" align="right">Test</td>
|
|
|
47 |
</tr>
|
|
|
48 |
</table>
|