Removing all the package replacement tags and SVN keyword tags
[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 - 2007, Blue Static
10 * @package ISSO Tests
11 *
12 */
13 class XmlTest extends PHPUnit_Framework_TestCase
14 {
15 public function setUp()
16 {
17 require_once('ISSO/Xml.php');
18 }
19
20 public function testSimpleXmlFile()
21 {
22 $xml = '
23 <root>
24 <elm1>elm1 Value</elm1>
25 <elm1>elm1 Value 2</elm1>
26 <elm2>elm2 Value</elm2>
27 </root>';
28
29 $results = array('root' =>
30 array(
31 'elm1' =>
32 array(
33 0 => array('value' => 'elm1 Value'),
34 1 => array('value' => 'elm1 Value 2')
35 ),
36 'elm2' => array('value' => 'elm2 Value')
37 )
38 );
39 $this->assertEquals($results, BSXml::Parse($xml));
40 }
41
42 public function testInvalidXml()
43 {
44 $xml = '<root><nest1><nest2>soemValue</nest1></nest2></root>';
45
46 try
47 {
48 BSXml::Parse($xml);
49 $this->fail('exception expcted');
50 }
51 catch (Exception $e)
52 {}
53 }
54
55 public function testUnifyNode()
56 {
57 $xml = '
58 <root>
59 <elm1>elm1 Value</elm1>
60 <elm1>elm1 Value 2</elm1>
61 <elm2>elm2 Value</elm2>
62 </root>';
63
64 $array = BSXml::Parse($xml);
65 BSXml::UnifyNode($array['root']['elm2']);
66 $this->assertEquals($array['root']['elm2'][0]['value'], 'elm2 Value');
67 }
68
69 public function testUtf8Xml()
70 {
71 $xml = '<root><utf8>test: π</utf8></root>';
72 $array = BSXml::Parse($xml, true);
73 $this->assertEquals($array['root']['utf8']['value'], 'test: π');
74 }
75 }
76
77 ?>