From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- tests/UnitTests/framework/Data/utXmlDocument.php | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/UnitTests/framework/Data/utXmlDocument.php (limited to 'tests/UnitTests/framework/Data/utXmlDocument.php') diff --git a/tests/UnitTests/framework/Data/utXmlDocument.php b/tests/UnitTests/framework/Data/utXmlDocument.php new file mode 100644 index 00000000..f66a4f2d --- /dev/null +++ b/tests/UnitTests/framework/Data/utXmlDocument.php @@ -0,0 +1,68 @@ +loadFromFile($dir.'/data1.xml'); + $doc->saveToFile($dir.'/data1.xml.tmp'); + $this->assertTrue($this->compareFiles($dir.'/data1.xml.tmp',$dir.'/data1.xml.out')); + @unlink($dir.'/data1.xml.tmp'); + + // an XML file with Chinese characters + $doc->loadFromFile($dir.'/data2.xml'); + $doc->saveToFile($dir.'/data2.xml.tmp'); + $this->assertTrue($this->compareFiles($dir.'/data2.xml.tmp',$dir.'/data2.xml.out')); + @unlink($dir.'/data2.xml.tmp'); + + // a typical Prado Application configuration file + $doc=new TXmlDocument; + $doc->loadFromFile($dir.'/data3.xml'); + $doc->saveToFile($dir.'/data3.xml.tmp'); + $this->assertTrue($this->compareFiles($dir.'/data3.xml.tmp',$dir.'/data3.xml.out')); + @unlink($dir.'/data3.xml.tmp'); + } + + protected function compareFiles($file1,$file2) + { + return file_get_contents($file1)===file_get_contents($file2); + } + + public function testAccessDomTree() + { + $dir=dirname(__FILE__).'/xml'; + $doc=new TXmlDocument; + $doc->loadFromFile($dir.'/data1.xml'); + $this->assertTrue($doc->getVersion()==='1.0'); + $this->assertTrue($doc->getEncoding()==='utf-8'); + $this->assertTrue($doc->getElements()->getCount()===2); + $this->assertTrue($doc->getElements()->itemAt(0)->getTagName()==='title'); + $this->assertTrue($doc->getElements()->itemAt(0)->getValue()==='My lists'); + $this->assertTrue($doc->getElements()->itemAt(1)->getTagName()==='chapter'); + $this->assertTrue($doc->getElements()->itemAt(1)->getAttribute('id')==='books'); + } + + public function testUpdateDomTree() + { + } + + public function testComposeDomTree() + { + } +} + +?> \ No newline at end of file -- cgit v1.2.3