Bad unit test... need to actually set the UTF-8 flag in BSXml::Parse()
[isso.git] / docs / UnitTest / XmlTest.php
1 <?php
2
3 /**
4 * XML Test
5 *
6 * @author Blue Static
7 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
8 * @version $Revision$
9 * @package ISSO Tests
10 *
11 */
12 class XmlTest extends UnitTestCase
13 {
14 public function setUp()
15 {
16 require_once('ISSO/Xml.php');
17 }
18
19 public function testSimpleXmlFile()
20 {
21 $xml = '
22 <root>
23 <elm1>elm1 Value</elm1>
24 <elm1>elm1 Value 2</elm1>
25 <elm2>elm2 Value</elm2>
26 </root>';
27
28 $results = array('root' =>
29 array(
30 'elm1' =>
31 array(
32 0 => array('value' => 'elm1 Value'),
33 1 => array('value' => 'elm1 Value 2')
34 ),
35 'elm2' => array('value' => 'elm2 Value')
36 )
37 );
38 $this->assertEqual($results, BSXml::Parse($xml));
39 }
40
41 public function testInvalidXml()
42 {
43 $xml = '<root><nest1><nest2>soemValue</nest1></nest2></root>';
44
45 BSXml::Parse($xml);
46
47 $this->assertError();
48 }
49
50 public function testUnifyNode()
51 {
52 $xml = '
53 <root>
54 <elm1>elm1 Value</elm1>
55 <elm1>elm1 Value 2</elm1>
56 <elm2>elm2 Value</elm2>
57 </root>';
58
59 $array = BSXml::Parse($xml);
60 BSXml::UnifyNode($array['root']['elm2']);
61 $this->assertEqual($array['root']['elm2'][0]['value'], 'elm2 Value');
62 }
63
64 public function testUtf8Xml()
65 {
66 $xml = '<root><utf8>test: π</utf8></root>';
67 $array = BSXml::Parse($xml, true);
68 $this->assertEqual($array['root']['utf8']['value'], 'test: π');
69 }
70 }
71
72 ?>