From e4249e9ce1d05e98d00c3b87dd868e141fdd032c Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Feb 2007 06:19:34 +0000 Subject: [PATCH] - Fixing the unit tests to actually work and the same with code coverage - Added an XmlTest --- docs/UnitTest/AllTests.php | 3 +- docs/UnitTest/Coverage.php | 6 +-- docs/UnitTest/FunctionsTest.php | 2 +- docs/UnitTest/RegisterTest.php | 2 +- docs/UnitTest/XmlTest.php | 72 +++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 docs/UnitTest/XmlTest.php diff --git a/docs/UnitTest/AllTests.php b/docs/UnitTest/AllTests.php index bda69d5..6e86447 100644 --- a/docs/UnitTest/AllTests.php +++ b/docs/UnitTest/AllTests.php @@ -12,8 +12,9 @@ $test->addTestFile('RegisterTest.php'); $test->addTestFile('FunctionsTest.php'); $test->addTestFile('DateTest.php'); $test->addTestFile('InputTest.php'); +$test->addTestFile('XmlTest.php'); // run -$test->run(new CustomHtmlReporter); +$test->run(new CustomHtmlReporter()); ?> \ No newline at end of file diff --git a/docs/UnitTest/Coverage.php b/docs/UnitTest/Coverage.php index 873173a..625c793 100644 --- a/docs/UnitTest/Coverage.php +++ b/docs/UnitTest/Coverage.php @@ -22,10 +22,10 @@ require_once('/Server/lib/php/Spike/src/CoverageRecorder.php'); require_once('/Server/lib/php/Spike/src/reporter/HtmlCoverageReporter.php'); -$reporter = new HtmlCoverageReporter('Code Coverage Report', null, 'coverage'); +$reporter = new HtmlCoverageReporter('Code Coverage Report', null, '/Server/htdocs/ISSO/docs/UnitTest/coverage/'); -$include = array('..'); -$exclude = array('../docs/', '../UnitTest/', '../images/'); +$include = array('/Server/htdocs/ISSO/'); +$exclude = array('/Server/htdocs/ISSO/docs/'); $coverage = new CoverageRecorder($include, $exclude, $reporter); diff --git a/docs/UnitTest/FunctionsTest.php b/docs/UnitTest/FunctionsTest.php index ef67bdc..9d29d9d 100644 --- a/docs/UnitTest/FunctionsTest.php +++ b/docs/UnitTest/FunctionsTest.php @@ -1,7 +1,7 @@ + elm1 Value + elm1 Value 2 + elm2 Value + '; + + $results = array('root' => + array( + 'elm1' => + array( + 0 => array('value' => 'elm1 Value'), + 1 => array('value' => 'elm1 Value 2') + ), + 'elm2' => array('value' => 'elm2 Value') + ) + ); + $this->assertEqual($results, BSXml::Parse($xml)); + } + + public function testInvalidXml() + { + $xml = 'soemValue'; + + BSXml::Parse($xml); + + $this->assertError(); + } + + public function testUnifyNode() + { + $xml = ' + + elm1 Value + elm1 Value 2 + elm2 Value + '; + + $array = BSXml::Parse($xml); + BSXml::UnifyNode($array['root']['elm2']); + $this->assertEqual($array['root']['elm2'][0]['value'], 'elm2 Value'); + } + + public function testUtf8Xml() + { + $xml = 'test: π'; + $array = BSXml::Parse($xml); + $this->assertEqual($array['root']['utf8']['value'], 'test: π'); + } +} + +?> \ No newline at end of file -- 2.22.5