Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Unit Tests for serializing arrays
4
 *
5
 * @package    XML_Serializer
6
 * @subpackage tests
7
 * @author     Stephan Schmidt <schst@php-tools.net>
8
 * @author     Chuck Burgess <ashnazg@php.net>
9
 */
10
 
11
/**
12
 * PHPUnit main() hack
13
 *
14
 * "Call class::main() if this source file is executed directly."
15
 */
16
if (!defined('PHPUnit_MAIN_METHOD')) {
17
    define('PHPUnit_MAIN_METHOD', 'XML_Unserializer_Arrays_TestCase::main');
18
}
19
require_once 'PHPUnit/Framework/TestCase.php';
20
require_once 'PHPUnit/Framework/TestSuite.php';
21
require_once 'PHPUnit/TextUI/TestRunner.php';
22
 
23
require_once 'XML/Unserializer.php';
24
 
25
/**
26
 * Unit Tests for serializing arrays
27
 *
28
 * @package    XML_Serializer
29
 * @subpackage tests
30
 * @author     Stephan Schmidt <schst@php-tools.net>
31
 * @author     Chuck Burgess <ashnazg@php.net>
32
 */
33
class XML_Unserializer_Arrays_TestCase extends PHPUnit_Framework_TestCase {
34
 
35
    public static function main() {
36
        $suite  = new PHPUnit_Framework_TestSuite('XML_Unserializer_Arrays_TestCase');
37
        $result = PHPUnit_TextUI_TestRunner::run($suite);
38
    }
39
 
40
    protected function setUp() {}
41
 
42
    protected function tearDown() {}
43
 
44
   /**
45
    * Test unserializing a simple array
46
    */
47
    public function testAssoc()
48
    {
49
        $u = new XML_Unserializer();
50
        $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'array');
51
        $xml = '<xml><foo>bar</foo></xml>';
52
        $u->unserialize($xml);
53
        $this->assertEquals(array('foo' => 'bar'), $u->getUnserializedData());
54
    }
55
 
56
   /**
57
    * Test unserializing an indexed array
58
    */
59
    public function testIndexed()
60
    {
61
        $u = new XML_Unserializer();
62
        $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'array');
63
        $xml = '<xml><foo>bar</foo><foo>tomato</foo></xml>';
64
        $u->unserialize($xml);
65
        $this->assertEquals(array('foo' => array('bar', 'tomato')), $u->getUnserializedData());
66
    }
67
 
68
}
69
 
70
/**
71
 * PHPUnit main() hack
72
 * "Call class::main() if this source file is executed directly."
73
 */
74
if (PHPUnit_MAIN_METHOD == 'XML_Unserializer_Arrays_TestCase::main') {
75
    XML_Unserializer_Arrays_TestCase::main();
76
}
77
?>