Our test suite is now done with PHPUnit, although it's rather broken
[isso.git] / docs / 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 BSXml::Parse($xml);
48
49 // TODO - use exceptions
50 // $this->assertError();
51 }
52
53 public function testUnifyNode()
54 {
55 $xml = '
56 <root>
57 <elm1>elm1 Value</elm1>
58 <elm1>elm1 Value 2</elm1>
59 <elm2>elm2 Value</elm2>
60 </root>';
61
62 $array = BSXml::Parse($xml);
63 BSXml::UnifyNode($array['root']['elm2']);
64 $this->assertEquals($array['root']['elm2'][0]['value'], 'elm2 Value');
65 }
66
67 public function testUtf8Xml()
68 {
69 $xml = '<root><utf8>test: π</utf8></root>';
70 $array = BSXml::Parse($xml, true);
71 $this->assertEquals($array['root']['utf8']['value'], 'test: π');
72 }
73 }
74
75 ?>