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

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/test/unittest2.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide 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 jonen 1.1 <?php
2     /**
3     * This is a Unit Test script for the
4     * XmlTagClass class. It is used to make sure
5     * everything works from build to build.
6     *
7     *
8     * $Id: unittest2.php,v 1.3 2003/08/16 00:40:43 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 XMLTagClassTest extends PHPUnit_TestCase {
28    
29     function XMLTagClassTest($name) {
30     $this->PHPUnit_TestCase($name);
31     }
32    
33     function test_Constructor() {
34     $tag = new XMLTagClass("foo",array("bar" => 1, "blah" => ""));
35     $this->assertEquals("foo", $tag->_tag, "Test tag name");
36     $this->assertEquals(0, $tag->count_content(), "Test content count");
37     $this->assertEquals(1, $tag->_attributes["bar"], "Test tag attribute");
38     }
39    
40     function test_add() {
41     $tag = new XMLTagClass("foo");
42     $tag->add("foo","bar", "blah");
43     $this->assertEquals(3, $tag->count_content(), "Test content count");
44     $foo = $tag->get_element(2);
45     $this->assertEquals("blah", $foo, "Test content value");
46     }
47    
48     function test_set_cdata_flag() {
49     $tag = new XMLTagClass("foo");
50     $tag->add("foo","bar", "blah");
51     $tag->set_cdata_flag(TRUE);
52     $this->assertEquals(_CDATACONTENTWRAP, $tag->_flags & _CDATACONTENTWRAP,
53     "Test the flag bitfield");
54     $this->assertEquals("<foo><![CDATA[",
55     substr($tag->render(), 0, 14),
56     "Test CDATA tag");
57     }
58    
59     function test_render() {
60     $tag = new XMLTagClass("foo");
61     $tag->add("foo", "bar");
62     $this->assertEquals("<foo>\n"._INDENT_STR."foo\n"._INDENT_STR."bar\n</foo>\n",
63     $tag->render(0),
64     "Test render with indent level 0");
65     $this->assertEquals(_INDENT_STR."<foo>\n"._INDENT_STR._INDENT_STR."foo\n".
66     _INDENT_STR._INDENT_STR."bar\n".
67     _INDENT_STR."</foo>\n",
68     $tag->render(1),
69     "Test render with indent level 1");
70    
71     $tag->set_collapse(TRUE, FALSE);
72     $this->assertEquals("<foo>foobar</foo>",
73     $tag->render(1), "Test render with collapse");
74    
75     }
76     }
77    
78     $suite = new PHPUnit_TestSuite('XMLTagClassTest');
79     $result = PHPUnit::run($suite);
80     if (isset($_SERVER["PHP_SELF"]) && strlen($_SERVER["PHP_SELF"]) > 0) {
81     echo $result->toHTML();
82     } else {
83     echo $result->toString();
84     }
85     ?>

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