| [ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 //-------------------------------------------------------------------------------- 3 // Copyright 2004 Procata, Inc. 4 // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) 5 //-------------------------------------------------------------------------------- 6 /** 7 * @package WACT_TESTS 8 * @author Jason E. Sweat <jsweat_php AT yahoo DOT com> 9 * @version $Id: data_table_tag.test.php,v 1.19 2004/06/24 23:06:49 jeffmoore Exp $ 10 */ 11 require_once WACT_ROOT . 'template/template.inc.php'; 12 require_once WACT_ROOT . 'util/arraydataset.inc.php'; 13 14 require_once 'list/decorators.inc.php'; 15 16 class WarnTestCssClassRowFilter { 17 function doFilter(&$DataSpace, &$TblDataSpace, $RowNum) { 18 if ($DataSpace->get('check') == $TblDataSpace->get('field1')) { 19 return 'warn'; 20 } 21 } 22 } 23 class WarnTestCssClassColFilter { 24 var $col; 25 function WarnTestCssClassColFilter($col) { 26 $this->col = $col; 27 } 28 function doFilter(&$DataSpace, &$TblDataSpace, $RowNum) { 29 if ($DataSpace->get('check') == $TblDataSpace->get($this->col)) { 30 return 'warn'; 31 } 32 } 33 } 34 35 /** 36 * @package WACT_TESTS 37 */ 38 class TemplateDataTableTagTestCase extends UnitTestCase { 39 var $data; 40 41 function TemplateDataTableTagTestCase($name = 'TemplateDataTableTagTestCase') { 42 $this->UnitTestCase($name); 43 $this->data = array( 44 array('field1' => 'val1', 'field2' => 'val2') 45 ,array('field1' => 'val3', 'field2' => 'val4') 46 ,array('field1' => 'val5', 'field2' => 'val6') 47 ); 48 $this->FoundingFathers = 49 array( array('First' => 'George', 'Last' => 'Washington'), 50 array('First' => 'Alexander', 'Last' => 'Hamilton'), 51 array('First' => 'Benjamin', 'Last' => 'Franklin')); 52 $this->Numbers = 53 array( array('BaseNumber' => 2), 54 array('BaseNumber' => 4), 55 array('BaseNumber' => 6)); 56 } 57 58 function setUp() { 59 } 60 61 function tearDown() { 62 } 63 64 function testEmptyTable() { 65 $Template = '<data:table id="tab"></data:table>'; 66 67 RegisterTestingTemplate('/template/tags/dt_empty.html', $Template); 68 $Page =& new Template('/template/tags/dt_empty.html'); 69 70 $output = $Page->capture(); 71 $this->assertWantedPattern('/^<table\s+id="tab"\s*>/i', $output); 72 $this->assertWantedPattern('~<table[^>]+>[\n\t ]*</table>~ims', $output); 73 } 74 75 function testCommentsInTable() { 76 $Template = '<data:table id="tab">This is a comment</data:table>'; 77 78 RegisterTestingTemplate('/template/tags/dt_rem.html', $Template); 79 $Page =& new Template('/template/tags/dt_rem.html'); 80 81 $output = $Page->capture(); 82 $this->assertWantedPattern('/^<table\s+id="tab"\s*>/i', $output); 83 $this->assertWantedPattern('~<table[^>]+>[\n\t ]*</table>~ims', $output); 84 $this->assertNoUnwantedPattern('/This is a comment/i', $output); 85 } 86 87 function testAttribsOnTable() { 88 $Template = '<data:table id="tab" cellpadding="6" cellspacing="4" tableclass="data" foo="bogus"></data:table>'; 89 90 RegisterTestingTemplate('/template/tags/dt_attrib.html', $Template); 91 $Page =& new Template('/template/tags/dt_attrib.html'); 92 93 $output = $Page->capture(); 94 $this->assertWantedPattern('/^<table\s+id="tab"\s*/i', $output); 95 $this->assertWantedPattern('~<table[^>]+>[\n\t ]*</table>~ims', $output); 96 $this->assertWantedPattern('/<table(?U)[^>]*\scellpadding="6"[^>]*>/i', $output); 97 $this->assertWantedPattern('/<table(?U)[^>]*\scellspacing="4"[^>]*>/i', $output); 98 $this->assertWantedPattern('/<table(?U)[^>]*\sclass="data"[^>]*>/i', $output); 99 $this->assertNoUnwantedPattern('/<table(?U)[^>]*\sfoo="bogus"[^>]*>/i', $output); 100 } 101 102 function testDefaultBadNesting() { 103 $Template = '<data:default>There is no data to show.</data:default>'; 104 105 RegisterTestingTemplate('/template/tags/dt_defbadnest.html', $Template); 106 $Page =& new Template('/template/tags/dt_defbadnest.html'); 107 108 $output = $Page->capture(); 109 $this->assertErrorPattern('/MISSINGENCLOSURE(?U).*data:default/i'); 110 } 111 112 function testDefaultNoDataTable() { 113 $Template = '<data:table id="tab"><data:default>There is no data to show.</data:default></data:table>'; 114 115 RegisterTestingTemplate('/template/tags/dt_defnodata.html', $Template); 116 $Page =& new Template('/template/tags/dt_defnodata.html'); 117 118 $output = $Page->capture(); 119 $this->assertWantedPattern('/^<table\s+id="tab"\s*>/i', $output); 120 $this->assertWantedPattern('~<table[^>]+>(?U).*There is no data to show(?U).*</table>~ims', $output); 121 } 122 123 function testBasicTable() { 124 $Template = '<data:table id="tab"></data:table>'; 125 126 RegisterTestingTemplate('/template/tags/dt_basic.html', $Template); 127 $Page =& new Template('/template/tags/dt_basic.html'); 128 $Table =& $Page->GetChild('tab'); 129 $Table->registerDataSet(new ArrayDataSet($this->data)); 130 131 $output = $Page->capture(); 132 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 133 $this->assertWantedPattern('~<th[^>]*>field1</th>(?U).*<th[^>]*>field2</th>~ims', $output); 134 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val1</td>\s*<td[^>]*>val2</td>~ims', $output); 135 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val3</td>\s*<td[^>]*>val4</td>~ims', $output); 136 } 137 138 function testBasicFromTable() { 139 $Template = '<data:table id="tab" from="data"></data:table>'; 140 141 RegisterTestingTemplate('/template/tags/dt_basicfrom.html', $Template); 142 $Page =& new Template('/template/tags/dt_basicfrom.html'); 143 $Page->Set('data', new ArrayDataSet($this->data)); 144 145 $output = $Page->capture(); 146 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 147 $this->assertWantedPattern('~<th[^>]*>field1</th>(?U).*<th[^>]*>field2</th>~ims', $output); 148 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val1</td>\s*<td[^>]*>val2</td>~ims', $output); 149 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val3</td>\s*<td[^>]*>val4</td>~ims', $output); 150 } 151 152 function testColumnBadNesting() { 153 $Template = '<data:column name="foo">There is no data to show.</data:column>'; 154 155 RegisterTestingTemplate('/template/tags/dt_colbadnest.html', $Template); 156 $Page =& new Template('/template/tags/dt_colbadnest.html'); 157 158 $output = $Page->capture(); 159 160 $this->assertErrorPattern('/MISSINGENCLOSURE(?U).*data:column/i'); 161 $Template = '<data:table><data:default><data:column name="foo">There is no data to show.</data:column></data:default></data:table>'; 162 163 RegisterTestingTemplate('/template/tags/dt_col2badnest.html', $Template); 164 $Page =& new Template('/template/tags/dt_col2badnest.html'); 165 166 $output = $Page->capture(); 167 $this->assertErrorPattern('/MISSINGENCLOSURE(?U).*data:column/i'); 168 } 169 170 function testColumnControlsOrder() { 171 $Template = '<data:table id="tab"><data:column name="field2" foo="bogus" /></data:table>'; 172 173 RegisterTestingTemplate('/template/tags/dt_colord.html', $Template); 174 $Page =& new Template('/template/tags/dt_colord.html'); 175 $Table =& $Page->GetChild('tab'); 176 $Table->registerDataSet(new ArrayDataSet($this->data)); 177 178 $output = $Page->capture(); 179 $this->assertWantedPattern('~<th[^>]*>field2</th>(?U).*<th[^>]*>field1</th>~ims', $output); 180 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val2</td>\s*<td[^>]*>val1</td>~ims', $output); 181 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val4</td>\s*<td[^>]*>val3</td>~ims', $output); 182 } 183 184 function testColumnCellTemplateOrder() { 185 $Template = '<data:table id="tab"><data:column name="field2"><data:cell>{$field2|uppercase}</data:cell></data:column></data:table>'; 186 187 RegisterTestingTemplate('/template/tags/dt_coltpl.html', $Template); 188 $Page =& new Template('/template/tags/dt_coltpl.html'); 189 $Table =& $Page->GetChild('tab'); 190 $Table->registerDataSet(new ArrayDataSet($this->data)); 191 192 $output = $Page->capture(); 193 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>VAL2</td>\s*<td[^>]*>val1</td>~ms', $output); 194 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>VAL4</td>\s*<td[^>]*>val3</td>~ms', $output); 195 } 196 197 function testHeaderBadNesting() { 198 $Template = '<data:header />'; 199 200 RegisterTestingTemplate('/template/tags/dt_headbadnest.html', $Template); 201 $Page =& new Template('/template/tags/dt_headbadnest.html'); 202 203 $output = $Page->capture(); 204 205 $this->assertErrorPattern('/MISSINGENCLOSURE(?U).*data:header/i'); 206 } 207 208 function testFooterBadNesting() { 209 $Template = '<data:footer />'; 210 211 RegisterTestingTemplate('/template/tags/dt_footbadnest.html', $Template); 212 $Page =& new Template('/template/tags/dt_footbadnest.html'); 213 214 $output = $Page->capture(); 215 216 $this->assertErrorPattern('/MISSINGENCLOSURE(?U).*data:footer/i'); 217 } 218 219 function testColumnHeaderTemplate() { 220 $Template = '<data:table id="tab" from="data">' 221 .'<data:column name="field1"><data:header>{$#field1_desc|uppercase}</data:header></data:column>' 222 .'<data:column name="field2"><data:header>{$#field2_desc|uppercase} ({$field2})</data:header></data:column>' 223 .'</data:table>'; 224 225 RegisterTestingTemplate('/template/tags/dt_headtpl.html', $Template); 226 $Page =& new Template('/template/tags/dt_headtpl.html'); 227 $Page->set('field1_desc', 'field1'); 228 $Page->set('field2_desc', 'f2'); 229 $Page->set('data', new ArrayDataSet($this->data)); 230 231 $output = $Page->capture(); 232 $this->assertWantedPattern('~<th[^>]*>FIELD1</th>(?U).*<th[^>]*>F2\s\(val2\)</th>~ims', $output); 233 } 234 235 function testColumnAttribHeader() { 236 $Template = '<data:table id="tab" from="data">' 237 .'<data:column name="field1" label="FIELD1" />' 238 .'<data:column name="field2"><data:header>{$#field2_desc|uppercase} ({$field2})</data:header></data:column>' 239 .'</data:table>'; 240 241 RegisterTestingTemplate('/template/tags/dt_headatttpl.html', $Template); 242 $Page =& new Template('/template/tags/dt_headatttpl.html'); 243 $Page->set('field1_desc', 'field1'); 244 $Page->set('field2_desc', 'f2'); 245 $Page->set('data', new ArrayDataSet($this->data)); 246 247 $output = $Page->capture(); 248 $this->assertWantedPattern('~<th[^>]*>FIELD1</th>(?U).*<th[^>]*>F2\s\(val2\)</th>~ims', $output); 249 } 250 251 /* I can't seem to get this test to run, I always get an 252 UNRESOLVED_BINDING error 253 254 function testColumnAttribHeaderProperty() { 255 $Template = '<data:table id="tab" from="data">' 256 .'<data:column name="field1" label="{$#field1_desc}" />' 257 .'</data:table>'; 258 259 RegisterTestingTemplate('/template/tags/dt_headattproptpl.html', $Template); 260 $Page =& new Template('/template/tags/dt_headattproptpl.html'); 261 $Page->set('field1_desc', 'Field1'); 262 $Page->set('data', new ArrayDataSet($this->data)); 263 264 $output = $Page->capture(); 265 $this->assertWantedPattern('~<th[^>]*>Field1</th>~ms', $output); 266 } 267 */ 268 269 function testColumnHide() { 270 $Template = '<data:table id="tab" from="data">' 271 .'<data:column name="field1" hide />' 272 .'</data:table>'; 273 274 RegisterTestingTemplate('/template/tags/dt_colhide.html', $Template); 275 $Page =& new Template('/template/tags/dt_colhide.html'); 276 $Page->set('data', new ArrayDataSet($this->data)); 277 278 $output = $Page->capture(); 279 $this->assertNoUnwantedPattern('~<th[^>]*>field1</th>~ims', $output); 280 $this->assertNoUnwantedPattern('~<td[^>]*>val1</td>~ims', $output); 281 } 282 283 function testColumnAsThTable() { 284 $Template = '<data:table id="tab" from="data"><data:column name="field1" heading /></data:table>'; 285 286 RegisterTestingTemplate('/template/tags/dt_colashead.html', $Template); 287 $Page =& new Template('/template/tags/dt_colashead.html'); 288 $Page->Set('data', new ArrayDataSet($this->data)); 289 290 $output = $Page->capture(); 291 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 292 $this->assertWantedPattern('~<th[^>]*>field1</th>(?U).*<th[^>]*>field2</th>~ims', $output); 293 $this->assertWantedPattern('~<tr[^>]*>\s*<tH[^>]*>val1</tH>\s*<td[^>]*>val2</td>~ims', $output); 294 $this->assertWantedPattern('~<tr[^>]*>\s*<tH[^>]*>val3</tH>\s*<td[^>]*>val4</td>~ims', $output); 295 } 296 297 function testAutoGenAttrib() { 298 $Template = '<data:table id="tab" from="data" autogen=FALSE ><data:column name="field2" /></data:table>'; 299 300 RegisterTestingTemplate('/template/tags/dt_autogenoff.html', $Template); 301 $Page =& new Template('/template/tags/dt_autogenoff.html'); 302 $Page->set('data', new ArrayDataSet($this->data)); 303 304 $output = $Page->capture(); 305 $this->assertWantedPattern('~<th[^>]*>field2</th>~ims', $output); 306 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val2</td>~ims', $output); 307 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*>val4</td>~ims', $output); 308 $this->assertNoUnwantedPattern('~<th[^>]*>field1</th>~ims', $output); 309 $this->assertNoUnwantedPattern('~<td[^>]*>val1</td>~ims', $output); 310 $this->assertNoUnwantedPattern('~<td[^>]*>val3</td>~ims', $output); 311 } 312 313 function testTableWideHeader() { 314 $Template = '<data:table id="tab" from="data"><data:header>{$#t} {$field1} wide heading</data:header></data:table>'; 315 316 RegisterTestingTemplate('/template/tags/dt_tabhead.html', $Template); 317 $Page =& new Template('/template/tags/dt_tabhead.html'); 318 $data = $this->data; 319 foreach ($data as $key => $row) { 320 $data[$key] = array_merge($row, array('another'=>'', 'column'=>'', 'and'=>'', 'one'=>'', 'more' => '')); 321 } 322 $Page->Set('data', new ArrayDataSet($data)); 323 $Page->Set('t', 'Table'); 324 325 $output = $Page->capture(); 326 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 327 $this->assertWantedPattern('~<tr[^>]*>\s*<tH\s+colspan="7"[^>]*>Table val1 wide heading</th></tr>~ims', $output); 328 } 329 330 function testTableWideFooter() { 331 $Template = '<data:table id="tab" from="data"><data:footer>Copyleft 2004 Procata, Inc.</data:footer></data:table>'; 332 333 RegisterTestingTemplate('/template/tags/dt_tabfoot.html', $Template); 334 $Page =& new Template('/template/tags/dt_tabfoot.html'); 335 $data = $this->data; 336 foreach ($data as $key => $row) { 337 $data[$key] = array_merge($row, array('another'=>'', 'column'=>'', 'and'=>'', 'one'=>'', 'more' => '')); 338 } 339 $Page->Set('data', new ArrayDataSet($data)); 340 341 $output = $Page->capture(); 342 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 343 $this->assertWantedPattern('~<tr[^>]*>\s*<td\s+colspan="7"[^>]*>Copyleft 2004[^<]*</td>\s*</tr>\s*</table>~ims', $output); 344 } 345 346 function testTableWideFooterTh() { 347 $Template = '<data:table id="tab" from="data"><data:footer heading>Copyleft 2004 Procata, Inc.</data:footer></data:table>'; 348 349 RegisterTestingTemplate('/template/tags/dt_tabfooth.html', $Template); 350 $Page =& new Template('/template/tags/dt_tabfooth.html'); 351 $data = $this->data; 352 foreach ($data as $key => $row) { 353 $data[$key] = array_merge($row, array('another'=>'', 'column'=>'', 'and'=>'', 'one'=>'', 'more' => '')); 354 } 355 $Page->Set('data', new ArrayDataSet($data)); 356 357 $output = $Page->capture(); 358 $this->assertWantedPattern('~^<table[^>]+>(?U).*</table>$~ims', $output); 359 $this->assertWantedPattern('~<tr[^>]*>\s*<th\s+colspan="7"[^>]*>Copyleft 2004[^<]*</th>\s*</tr>\s*</table>~ims', $output); 360 } 361 362 function testColFooters() { 363 $Template = '<data:table id="tab" from="data">' 364 .'<data:column name="field1"><data:footer>f1</data:footer></data:column>' 365 .'<data:column name="field2"><data:footer>{$#foot}</data:footer><data:footer heading>f3</data:footer></data:column>' 366 .'</data:table>'; 367 368 RegisterTestingTemplate('/template/tags/dt_tabcfoot.html', $Template); 369 $Page =& new Template('/template/tags/dt_tabcfoot.html'); 370 $Page->Set('data', new ArrayDataSet($this->data)); 371 $Page->Set('foot', 'f2'); 372 373 $output = $Page->capture(); 374 $this->assertWantedPattern('~<tr[^>]*><td>f1</td><td>f2</td></tr>~ims', $output); 375 $this->assertWantedPattern('~<tr[^>]*><td> </td><th>f3</th></tr>~ims', $output); 376 } 377 378 function testColFootersBold() { 379 $Template = '<data:table id="tab" from="data">' 380 .'<data:column name="field1"><data:footer b>f1</data:footer></data:column>' 381 .'<data:column name="field2"><data:footer bold>{$#foot}</data:footer><data:footer heading>f3</data:footer></data:column>' 382 .'</data:table>'; 383 384 RegisterTestingTemplate('/template/tags/dt_tabcfootb.html', $Template); 385 $Page =& new Template('/template/tags/dt_tabcfootb.html'); 386 $Page->Set('data', new ArrayDataSet($this->data)); 387 $Page->Set('foot', 'f2'); 388 389 $output = $Page->capture(); 390 $this->assertWantedPattern('~<tr[^>]*><td><b>f1</b></td><td><b>f2</b></td></tr>~ims', $output); 391 $this->assertWantedPattern('~<tr[^>]*><td> </td><th>f3</th></tr>~ims', $output); 392 } 393 394 function testColGroup() { 395 $Template = '<data:table id="tab" from="data">' 396 .'<data:column id="f2" name="field2" />' 397 .'<data:group id="grp"><data:header> :: {$#grp} :: </data:header>' 398 .'<data:column id="f1" name="field1" /><data:column id="a" name="another" />' 399 .'</data:group>' 400 .'</data:table>'; 401 402 RegisterTestingTemplate('/template/tags/dt_tabgrp.html', $Template); 403 $Page =& new Template('/template/tags/dt_tabgrp.html'); 404 $data = $this->data; 405 foreach ($data as $key => $row) { 406 $data[$key] = array_merge($row, array('another'=>'', 'column'=>'')); 407 } 408 $Page->Set('data', new ArrayDataSet($data)); 409 $Page->Set('grp', 'Group Title'); 410 411 $output = $Page->capture(); 412 $this->assertWantedPattern('~<tr[^>]*>(?U).*<th\s+rowspan="2"[^>]*>field2</th><th\s+colspan="2"[^>]*> :: Group Title :: </th>(?U).*<th\s+rowspan="2"[^>]*>column</th>(?U).*</tr>~ims', $output); 413 $this->assertWantedPattern('~<tr[^>]*>(?U).*<th>field1</th>(?U).*<th>another</th></tr>~ims', $output); 414 } 415 416 function testRowCssClassFilter() { 417 $Template = '<data:table id="tab" from="data">' 418 .'</data:table>'; 419 420 RegisterTestingTemplate('/template/tags/dt_tabrowfil.html', $Template); 421 $Page =& new Template('/template/tags/dt_tabrowfil.html'); 422 $Page->Set('data', new ArrayDataSet($this->data)); 423 $Page->Set('check', 'val3'); 424 425 $Filter =& new WarnTestCssClassRowFilter; 426 $Table =& $Page->GetChild('tab'); 427 $Table->registerRowCssClassFilter($Filter); 428 429 $output = $Page->capture(); 430 $this->assertWantedPattern('~<tr[^>]*class="warn"[^>]*>\s*<td>val3</td>~ims', $output); 431 } 432 433 function testColumnCssClassFilter() { 434 $Template = '<data:table id="tab" from="data">' 435 .'<data:column id="f2" name="field2" />' 436 .'</data:table>'; 437 438 RegisterTestingTemplate('/template/tags/dt_tabcolfil.html', $Template); 439 $Page =& new Template('/template/tags/dt_tabcolfil.html'); 440 $Page->Set('data', new ArrayDataSet($this->data)); 441 $Page->Set('check', 'val4'); 442 443 $Filter =& new WarnTestCssClassColFilter('field2'); 444 $Column =& $Page->GetChild('f2'); 445 $Column->registerCssClassFilter($Filter); 446 447 $output = $Page->capture(); 448 $this->assertWantedPattern('~<tr[^>]*>\s*<td[^>]*class="warn">val4</td>~ims', $output); 449 } 450 451 function testTableRowAttributes() { 452 $Template = '<data:table id="tab" from="data" style="ts" rowstyle="rs" align="left" valign="top" foo="bar"></data:table>'; 453 454 RegisterTestingTemplate('/template/tags/dt_tabrowatt.html', $Template); 455 $Page =& new Template('/template/tags/dt_tabrowatt.html'); 456 $Page->Set('data', new ArrayDataSet($this->data)); 457 458 $output = $Page->capture(); 459 $attrib_pattern='<tr(?U)[^>]*(\sstyle="rs"|\salign="left"|\svalign="top"){3}[^>]*>'; 460 $this->assertWantedPattern('~<table[^>]*style="ts"[^>]*>(?U).*<tr[^>]*>((?U).*'.$attrib_pattern.'){3}~ims', $output); 461 $this->assertNoUnwantedPattern('~foo="bar"~ims', $output); 462 } 463 464 function testColumnAttributes() { 465 $Template = '<data:table id="tab" from="data" style="ts">' 466 .'<data:column name="field1" style="f1s" align="right" foo="bar" />' 467 .'<data:column name="field2" style="f2s" align="center" foo="baz" />' 468 .'</data:table>'; 469 470 RegisterTestingTemplate('/template/tags/dt_tabcolatt.html', $Template); 471 $Page =& new Template('/template/tags/dt_tabcolatt.html'); 472 $Page->Set('data', new ArrayDataSet($this->data)); 473 474 $output = $Page->capture(); 475 $attrib_pattern='<td(?U)[^>]*(\sstyle="f1s"|\salign="right"){2}[^>]*>(?U).*</td>(?U).*<td(?U)[^>]*(\sstyle="f2s"|\salign="center"){2}[^>]*>(?U).*</td>'; 476 $this->assertWantedPattern('~<table[^>]*style="ts"[^>]*>((?U).*<tr[^>]*>(?U).*'.$attrib_pattern.'){3}~ims', $output); 477 } 478 479 function testHeaderAttributes() { 480 $Template = '<data:table id="tab" from="data" style="ts">' 481 .'<data:column name="field1" style="text-align: center">' 482 .'<data:header style="width: 250px">f1</data:header>' 483 .'</data:column>' 484 .'</data:table>'; 485 486 RegisterTestingTemplate('/template/tags/dt_tabheadatt.html', $Template); 487 $Page =& new Template('/template/tags/dt_tabheadatt.html'); 488 $Page->Set('data', new ArrayDataSet($this->data)); 489 490 $output = $Page->capture(); 491 $this->assertWantedPattern('~<table[^>]*style="ts"[^>]*>(?U).*<tr[^>]*>(?U).*<th[^>]*style="width: 250px"[^>]*>((?U).*<tr[^>]*>(?U).*<td[^>]*style="text-align: center"[^>]*>){3}~ims', $output); 492 } 493 494 495 function testSuppressOpen() {} // no <table.*> 496 497 function testSuppressClose() {} // no </table> 498 499 function testAutoRowClass() {} //feature to add wact_header, wact_detail and wact_footer classes to all <tr> 500 501 function testSupressHeadings() {} //no headings show up 502 503 function testRepeatHeadings() {} //headings show up ever n rows 504 505 function testNestedListOuterIdInnerFrom() { 506 $Template = '<list:LIST id="test"><list:ITEM>'; 507 $Template .= '{$First}:'; 508 $Template .= '<data:table from="sub" />'; 509 $Template .= '</list:ITEM></list:LIST>'; 510 RegisterTestingTemplate('/tags/data/nested-id-from.html', $Template); 511 512 $Page =& new Template('/tags/data/nested-id-from.html'); 513 $list =& $Page->getChild('test'); 514 $list->registerDataSet(new NestedDataSetDecorator(new ArrayDataSet($this->FoundingFathers))); 515 $output = $Page->capture(); 516 $this->assertWantedPattern('/^George:.*value1.*value3.*value5.*Alexander:.*value1.*value3.*value5.*Benjamin:.*value1.*value3.*value5.*$/s', $output); 517 } 518 519 function testNestedListOuterFromInnerFrom() { 520 $Template = '<list:LIST from="test"><list:ITEM>'; 521 $Template .= '{$First}:'; 522 $Template .= '<data:table from="sub" />'; 523 $Template .= '</list:ITEM></list:LIST>'; 524 RegisterTestingTemplate('/tags/data/nested-from-from.html', $Template); 525 526 $Page =& new Template('/tags/data/nested-from-from.html'); 527 $Page->set('test',new NestedDataSetDecorator(new ArrayDataSet($this->FoundingFathers))); 528 $output = $Page->capture(); 529 $this->assertWantedPattern('/^George:.*value1.*value3.*value5.*Alexander:.*value1.*value3.*value5.*Benjamin:.*value1.*value3.*value5.*$/s', $output); 530 } 531 532 function testNestedListOuterIdInnerId() { 533 $Template = '<list:LIST id="test"><list:ITEM>'; 534 $Template .= '{$BaseNumber}:'; 535 $Template .= '<data:table id="sub" />'; 536 $Template .= '</list:ITEM></list:LIST>'; 537 RegisterTestingTemplate('/tags/data/nested-id-id.html', $Template); 538 539 $Page =& new Template('/tags/data/nested-id-id.html'); 540 $NumberList =& new ArrayDataSet($this->Numbers); 541 $Page->setChildDataSource('test', $NumberList); 542 $Page->setChildDataSource('sub', new InnerDataSource($NumberList)); 543 $output = $Page->capture(); 544 $this->assertWantedPattern('/^2:.*2.*4.*8.*4:.*4.*16.*64.*6:.*6.*36.*216.*$/s', $output); 545 } 546 547 /* 548 Does not work under PHP 4 because a copy is made during the set('test'). 549 This test should pass under PHP 5. 550 function testNestedListOuterFromInnerId() { 551 $Template = '<list:LIST from="test"><list:ITEM>'; 552 $Template .= '{$BaseNumber}:'; 553 $Template .= '<data:table id="sub" />'; 554 $Template .= '</list:ITEM></list:LIST>'; 555 RegisterTestingTemplate('/tags/data/nested-from-id.html', $Template); 556 557 $Page =& new Template('/tags/data/nested-from-id.html'); 558 559 $NumberList =& new ArrayDataSet($this->Numbers); 560 $Page->set('test', $NumberList); 561 $Page->setChildDataSource('sub', new InnerDataSource($NumberList)); 562 563 $output = $Page->capture(); 564 $this->assertWantedPattern('/^2:.*2.*4.*8.*4:.*4.*16.*64.*6:.*6.*36.*216.*$/s', $output); 565 } 566 */ 567 568 } 569 570 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |