Removing dead files that we no longer need
[isso.git] / UnitTest / XmlTest.php
1 <?php
2
3 require_once 'PHPUnit/Framework.php';
4
5 /**
6 * XML Test
7 *
8 * @author Blue Static
9 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
10 * @version $Revision$
11 * @package ISSO Tests
12 *
13 */
14 class XmlTest extends PHPUnit_Framework_TestCase
15 {
16 public function setUp()
17 {
18 require_once('ISSO/Xml.php');
19 }
20
21 public function testSimpleXmlFile()
22 {
23 $xml = '
24 <root>
25 <elm1>elm1 Value</elm1>
26 <elm1>elm1 Value 2</elm1>
27 <elm2>elm2 Value</elm2>
28 </root>';
29
30 $results = array('root' =>
31 array(
32 'elm1' =>
33 array(
34 0 => array('value' => 'elm1 Value'),
35 1 => array('value' => 'elm1 Value 2')
36 ),
37 'elm2' => array('value' => 'elm2 Value')
38 )
39 );
40 $this->assertEquals($results, BSXml::Parse($xml));
41 }
42
43 public function testInvalidXml()
44 {
45 $xml = '<root><nest1><nest2>soemValue</nest1></nest2></root>';
46
47 try
48 {
49 BSXml::Parse($xml);
50 $this->fail('exception expcted');
51 }
52 catch (Exception $e)
53 {}
54 }
55
56 public function testUnifyNode()
57 {
58 $xml = '
59 <root>
60 <elm1>elm1 Value</elm1>
61 <elm1>elm1 Value 2</elm1>
62 <elm2>elm2 Value</elm2>
63 </root>';
64
65 $array = BSXml::Parse($xml);
66 BSXml::UnifyNode($array['root']['elm2']);
67 $this->assertEquals($array['root']['elm2'][0]['value'], 'elm2 Value');
68 }
69
70 public function testUtf8Xml()
71 {
72 $xml = '<root><utf8>test: π</utf8></root>';
73 $array = BSXml::Parse($xml, true);
74 $this->assertEquals($array['root']['utf8']['value'], 'test: π');
75 }
76 }
77
78 ?>