<?php require_once ('lib/simpletest/unit_tester.php'); require_once ('html/HtmlTable.inc') ;
class HtmlTableTests extends UnitTestCase {
public function testHtmlCell () {
$t = new HtmlCell () ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r)) ; echo "<hr>" ; $this->assertEqual ($r, "<td></td>") ;
$t->setData ("een test") ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r)) ; echo "<hr>" ; $this->assertEqual ($r, "<td>een test</td>") ;
$t->setHorizontalAlignment(HTML_LEFT) ; $t->setVerticalAlignment(HTML_TOP) ; $t->setWidth(123) ; $t->setRowSpan(2) ; $t->setColumnSpan(3) ;
$r =$t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r)) ; echo "<hr>" ; $this->assertEqual ($r, "<td align=\"left\" valign=\"top\" width=\"123\" colspan=\"3\" rowspan=\"2\" >een test</td>") ;
$t->setTopAlign () ; $t->setBottomAlign () ; $t->setCenterAlign () ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<td align=\"center\" valign=\"bottom\" width=\"123\" colspan=\"3\" rowspan=\"2\" >een test</td>") ; }
public function testHtmlRow () {
$t = new HtmlRow () ; $r = $t->build() ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<tr>\n</tr>\n") ;
$t->setData (2, "tweede rij") ; $t->setData (0, "nulde rij") ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<tr><td>nulde rij</td><td>tweede rij</td></tr>") ;
$t->setHorizontalAlignment(HTML_LEFT) ; $t->setVerticalAlignment(HTML_MIDDLE) ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<tr align=\"left\" valign=\"middle\" ><td>nulde rij</td><td>tweede rij</td></tr>") ; }
public function testHtmlTable () {
$t = new HtmlTable () ; $r = $t->build() ; $this->assertEqual ($t->getNumRows(), 0) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<table>\n</table>\n") ;
$t->setData (0,0,"cel 11") ; $t->setData (1,1,"cel 22") ; $t->setData (1,0,"cel 21") ; $t->setData (0,1,"cel 12") ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($t->getNumRows(), 2) ; $this->assertEqual ($r, "<table><tr><td>cel 11</td><td>cel 12</td></tr><tr><td>cel 21</td><td>cel 22</td></tr></table>") ; echo "<hr>$r<hr>";
$t->setBorder (1) ; $t->setCellSpacing (5) ; $t->setCellPadding (3) ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<table border=\"1\" cellspacing=\"5\" cellpadding=\"3\" ><tr><td>cel 11</td><td>cel 12</td></tr><tr><td>cel 21</td><td>cel 22</td></tr></table>") ; echo "<hr>$r<hr>";
$t = new HtmlTable () ; $t->setData (0,0, new HtmlImage ("junit/data/good_avatar.jpg")) ; $t->setData (0,1,new HtmlImage ("junit/data/good_avatar.GIF")) ; $this->assertEqual ($t->getNumRows(), 1) ; $r = $t->build() ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; echo "<hr>$r<hr>";
// test using headers $t = new HtmlTable () ;
$t->setHeaderCells(array ("head1", "head2")); $t->setData (1,0,"cel 11") ; $t->setData (2,1,"cel 22") ; $t->setData (2,0,"cel 21") ; $t->setData (1,1,"cel 12") ; $r = $t->build() ; $r = str_replace ("\n", "", $r) ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<table><tr><th>head1</th><th>head2</th></tr><tr><td>cel 11</td><td>cel 12</td></tr><tr><td>cel 21</td><td>cel 22</td></tr></table>") ; echo "<hr>$r<hr>" ; }
public function testHtmlTableWildcard () {
$t = new HtmlTable () ; $r = $t->build() ; //print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<table>\n</table>\n") ;
$t->setData (0,0,"cel 11") ; $t->setData (1,2,"cel 23") ; $t->setData (1,0,"cel 21") ; $t->setData (0,2,"cel 13") ; $t->setData (2,0,"cel 31") ; $t->setData (2,2,"cel 33") ; $t->setData ('*', 1, "wildcard") ;
$r = $t->build() ; $r = str_replace ("\n", "", $r) ; echo $r ; $this->assertEqual ($t->getNumRows(), 3) ; //echo "<hr>" ; print_r (htmlentities($r,ENT_QUOTES)) ; echo "<hr>" ; $this->assertEqual ($r, "<table><tr><td>cel 11</td><td>wildcard</td><td>cel 13</td></tr><tr><td>cel 21</td><td>wildcard</td><td>cel 23</td></tr><tr><td>cel 31</td><td>wildcard</td><td>cel 33</td></tr></table>") ; }
}
?>
|