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_Option_Encodings_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_Option_Encodings_TestCase extends PHPUnit_Framework_TestCase {
34
 
35
    public static function main() {
36
        $suite  = new PHPUnit_Framework_TestSuite('XML_Unserializer_Option_Encodings_TestCase');
37
        $result = PHPUnit_TextUI_TestRunner::run($suite);
38
    }
39
 
40
    protected function setUp() {}
41
 
42
    protected function tearDown() {}
43
 
44
   /**
45
    * Test unserializing from UTF-8 to ISO-8859-1
46
    */
47
    public function testUtf8ToIso()
48
    {
49
        $u = new XML_Unserializer();
50
        $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_SOURCE, 'UTF-8');
51
        $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_TARGET, 'ISO-8859-1');
52
        $xml = '<xml>'.utf8_encode('A string containing ü ä Ãê').'</xml>';
53
        $u->unserialize($xml);
54
        $this->assertEquals('A string containing ü ä Ãê', $u->getUnserializedData());
55
    }
56
 
57
}
58
 
59
/**
60
 * PHPUnit main() hack
61
 * "Call class::main() if this source file is executed directly."
62
 */
63
if (PHPUnit_MAIN_METHOD == 'XML_Unserializer_Option_Encodings_TestCase::main') {
64
    XML_Unserializer_Option_Encodings_TestCase::main();
65
}
66
?>