/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/test/unittest1.php
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/test/unittest1.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu May 6 16:57:30 2004 UTC (20 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This is a Unit Test script for the
4 * Container class. It is used to make sure
5 * everything works from build to build.
6 *
7 *
8 * $Id: unittest1.php,v 1.2 2003/08/16 00:31:04 hemna Exp $
9 *
10 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
11 * @package phpHtmlLib
12 */
13
14 $phphtmllib = "..";
15 require_once($phphtmllib."/includes.inc");
16 /**
17 * You have to have PEAR's PHPUnit installed
18 *
19 * pear install PHPUnit
20 */
21 require_once("PHPUnit.php");
22
23
24 /**
25 * Test the Container class
26 */
27 class ContainerTest extends PHPUnit_TestCase {
28
29 function ContainerTest($name) {
30 $this->PHPUnit_TestCase($name);
31 }
32
33 function test_Constructor() {
34 $container = new Container("foo", 1, new StdClass);
35 $this->assertEquals($container->count_content(),3, "Test content count");
36 $this->assertTrue(is_object($container->_content[2]) &&
37 strcasecmp(get_class($container->_content[2]),"stdClass") == 0,
38 "Test stdClass");
39 }
40
41 function test_add() {
42 $container = new Container();
43 $container->add("foo");
44 $this->assertEquals($container->count_content(),1, "Test content count");
45 $foo = $container->get_element(0);
46 $this->assertEquals($foo, "foo", "Test");
47 }
48
49 function test_get_element() {
50 $container = new Container();
51 $test = "foo";
52 $container->add($test);
53 $foo =& $container->get_element(0);
54 $this->assertEquals($foo,"foo", "Test adding 'foo'");
55 }
56
57
58 function test_reset_Content() {
59 $container = new Container();
60 $container->reset_content();
61 $this->assertEquals(0,$container->count_content(), "Test reset to empty");
62 $container->reset_content("foo");
63 $foo =& $container->get_element(0);
64 $this->assertEquals("foo",$foo, "Test adding 'foo'");
65 }
66
67 function test_set_collapse() {
68 $container = new Container();
69 $container->set_collapse(TRUE);
70 $this->assertEquals(_COLLAPSE, $container->_flags & _COLLAPSE,
71 "Test the collapse flag bitfield");
72 $this->assertEquals(_INDENT, $container->_flags & _INDENT,
73 "Test the indent flag bitfield");
74 $container->set_collapse(FALSE, FALSE);
75 $this->assertEquals(0, $container->_flags & _COLLAPSE,
76 "Test the collapse flag bitfield");
77 $this->assertEquals(0, $container->_flags & _INDENT,
78 "Test the indent flag bitfield");
79 }
80
81 function test_render() {
82 $container = new Container();
83 $container->add("foo", "bar");
84 $this->assertEquals("foo\nbar\n",
85 $container->render(0),
86 "Test render with indent level 0");
87 $this->assertEquals(_INDENT_STR."foo\n"._INDENT_STR."bar\n",
88 $container->render(1),
89 "Test render with indent level 1");
90
91 $container->set_collapse(TRUE, FALSE);
92 $this->assertEquals("foobar",
93 $container->render(1), "Test render with collapse");
94
95 }
96 }
97
98 $suite = new PHPUnit_TestSuite('ContainerTest');
99 $result = PHPUnit::run($suite);
100 if (isset($_SERVER["PHP_SELF"]) && strlen($_SERVER["PHP_SELF"]) > 0) {
101 echo $result->toHTML();
102 } else {
103 echo $result->toString();
104 }
105 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed