3 require_once 'PHPUnit/Framework.php';
9 * @copyright Copyright (c)2002 - 2007, Blue Static
13 class XmlTest
extends PHPUnit_Framework_TestCase
15 public function setUp()
17 require_once(ISSO
. '/Xml.php');
20 public function testSimpleXmlFile()
24 <elm1>elm1 Value</elm1>
25 <elm1>elm1 Value 2</elm1>
26 <elm2>elm2 Value</elm2>
29 $results = array('root' =>
33 0 => array('value' => 'elm1 Value'),
34 1 => array('value' => 'elm1 Value 2')
36 'elm2' => array('value' => 'elm2 Value')
39 $this->assertEquals($results, BSXml
::Parse($xml));
42 public function testInvalidXml()
44 $xml = '<root><nest1><nest2>soemValue</nest1></nest2></root>';
49 $this->fail('exception expcted');
55 public function testUnifyNode()
59 <elm1>elm1 Value</elm1>
60 <elm1>elm1 Value 2</elm1>
61 <elm2>elm2 Value</elm2>
64 $array = BSXml
::Parse($xml);
65 BSXml
::UnifyNode($array['root']['elm2']);
66 $this->assertEquals($array['root']['elm2'][0]['value'], 'elm2 Value');
69 public function testUtf8Xml()
71 $xml = '<root><utf8>test: π</utf8></root>';
72 $array = BSXml
::Parse($xml, true);
73 $this->assertEquals($array['root']['utf8']['value'], 'test: π');