1 |
jonen |
1.1 |
<?php |
2 |
|
|
/** |
3 |
|
|
* This is a Unit Test script for the |
4 |
|
|
* HTMLTagClass class. It is used to make sure |
5 |
|
|
* everything works from build to build. |
6 |
|
|
* |
7 |
|
|
* |
8 |
|
|
* $Id: unittest3.php,v 1.1 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 HTMLTagClassTest extends PHPUnit_TestCase { |
28 |
|
|
|
29 |
|
|
function HTMLTagClassTest($name) { |
30 |
|
|
$this->PHPUnit_TestCase($name); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
function test_Constructor() { |
34 |
|
|
$tag = new HTMLTagClass(array("src" => "http://www.slashdot.org")); |
35 |
|
|
$tag->set_tag_name("a"); |
36 |
|
|
$this->assertEquals("a", $tag->_tag, "Test tag name"); |
37 |
|
|
$this->assertEquals(0, $tag->count_content(), "Test content count"); |
38 |
|
|
$this->assertEquals("http://www.slashdot.org", |
39 |
|
|
$tag->_attributes["src"], "Test tag attribute"); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
function test_set_style() { |
43 |
|
|
$tag = new DIVtag(); |
44 |
|
|
$str = "color:blue;"; |
45 |
|
|
$tag->set_style($str); |
46 |
|
|
$this->assertEquals($str, $tag->_attributes["style"], "Test style attribute"); |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
function test_set_class() { |
50 |
|
|
$tag = new DIVtag(); |
51 |
|
|
$str = "foo"; |
52 |
|
|
$tag->set_class($str); |
53 |
|
|
$this->assertEquals($str, $tag->_attributes["class"], "Test class attribute"); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
function test_set_id() { |
57 |
|
|
$tag = new DIVtag(); |
58 |
|
|
$str = "foo"; |
59 |
|
|
$tag->set_id($str); |
60 |
|
|
$this->assertEquals($str, $tag->_attributes["id"], "Test id attribute"); |
61 |
|
|
} |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
$suite = new PHPUnit_TestSuite('HTMLTagClassTest'); |
65 |
|
|
$result = PHPUnit::run($suite); |
66 |
|
|
if (isset($_SERVER["PHP_SELF"]) && strlen($_SERVER["PHP_SELF"]) > 0) { |
67 |
|
|
echo $result->toHTML(); |
68 |
|
|
} else { |
69 |
|
|
echo $result->toString(); |
70 |
|
|
} |
71 |
|
|
?> |