premier commit
[bazdig.git] / test / PageCopyTest.php
blobc50a2789c46f773217b81793cc99af61d3cec6a8
1 <?php
2 /**
3 * PHPUnit test case for PageCopy
4 *
5 * The method skeletons below need to be filled in with
6 * real data so that the tests will run correctly. Replace
7 * all EXPECTED_VAL and PARAM strings with real data.
8 *
9 * Created with PHPUnit_Skeleton on 2007-04-09
11 require_once 'PHPUnit.php';
12 class PageCopyTest extends PHPUnit_TestCase {
14 var $PageCopy;
16 function PageCopyTest($name)
18 $this->PHPUnit_TestCase($name);
21 function setUp()
23 require_once '../lib/pagecopy.php';
24 $url = "http://localhost/slim/markkit/test";
25 $file = "/home/slim/markkit-glassjoe/markkit/test";
26 $copydir = new LocalResource($url, $file);
27 $test_url_wf = "$url/test_page_well_formed.html";
28 $test_url_ts = "$url/test_page_tag_soup.html";
29 $this->PageCopy =& new PageCopy("testcopy.html",$test_url_wf, $copydir);
30 $this->PageCopyTS =& new PageCopy("testcopy_ts.html",$test_url_ts, $copydir);
33 function tearDown()
35 unset($this->PageCopy);
36 unset($this->PageCopyTS);
37 unlink("testcopy.html");
38 @unlink("testcopy_ts.html");
41 function testupdate()
43 $this->PageCopy->update();
44 $this->assertTrue(is_file("testcopy.html"));
47 function testadd_to_html()
49 $this->PageCopy->add_to_html("<br id='testaddtohtml' />");
50 $this->PageCopy->update();
51 $c = file_get_contents("testcopy.html");
52 $this->assertTrue(ereg("id='testaddtohtml' />\s*</html>", $c));
53 $this->assertFalse(ereg("id='testaddtohtml'.*id='testaddtohtml'", $c));
54 $this->PageCopyTS->add_to_html("<br id='testaddtohtml' />");
55 $this->PageCopyTS->update();
56 $c = file_get_contents("testcopy_ts.html");
57 $this->assertTrue(ereg("id='testaddtohtml' />", $c));
60 function testadd_to_head()
62 $this->PageCopy->add_to_head("<br id='testaddtohtml' />");
63 $this->PageCopy->update();
64 $c = file_get_contents("testcopy.html");
65 $this->assertTrue(ereg("id='testaddtohtml' />\s*</head>", $c));
66 $this->assertFalse(ereg("id='testaddtohtml'.*id='testaddtohtml'", $c));
67 $this->PageCopyTS->add_to_head("<br id='testaddtohtml' />");
68 $this->PageCopyTS->update();
69 $c = file_get_contents("testcopy_ts.html");
70 $this->assertTrue(ereg("id='testaddtohtml' />", $c));
73 function testadd_to_head_start()
75 $this->PageCopy->add_to_head_start("<br id='testaddtohtml' />");
76 $this->PageCopy->update();
77 $c = file_get_contents("testcopy.html");
78 $this->assertTrue(ereg("<head>\s*<br id='testaddtohtml' />", $c));
79 $this->assertFalse(ereg("id='testaddtohtml'.*id='testaddtohtml'", $c));
80 $this->PageCopyTS->add_to_head_start("<br id='testaddtohtml' />");
81 $this->PageCopyTS->update();
82 $c = file_get_contents("testcopy_ts.html");
83 $this->assertTrue(ereg("<br id='testaddtohtml' />", $c));
86 // Running the test.
87 $suite = new PHPUnit_TestSuite('PageCopyTest');
88 $result = PHPUnit::run($suite);
89 echo $result->toString();