Changeset 1164

Show
Ignore:
Timestamp:
12/19/07 17:50:28 (10 months ago)
Author:
mikey
Message:

added correct xml headers and test for ensuring that returned unserialized data is always UTF-8

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/test/php/net/stubbles/xml/unserializer/stubXMLUnserializerTestCase.php

    r1163 r1164  
    2222    public function testUnserializeAnyXML() 
    2323    { 
    24         $xml = '<users>' . 
     24        $xml = '<?xml version="1.0" encoding="iso-8859-1"?>' .  
     25               '<users>' . 
    2526               '  <user handle="schst">Stephan Schmidt</user>' . 
    2627               '  <user handle="mikey">Frank Kleine</user>' . 
     
    4950    public function testUnserializeList() 
    5051    { 
    51         $xml1 = '<root> 
     52        $xml1 = '<?xml version="1.0" encoding="iso-8859-1"?> 
     53                <root> 
    5254                   <item> 
    5355                     <name>schst</name> 
     
    5860                 </root>'; 
    5961                     
    60         $xml2 = '<root> 
     62        $xml2 = '<?xml version="1.0" encoding="iso-8859-1"?> 
     63                <root> 
    6164                   <item> 
    6265                     <name>schst</name> 
     
    7881    public function testWhiteSpaceTrim() 
    7982    { 
    80         $xml = '<xml> 
     83        $xml = '<?xml version="1.0" encoding="iso-8859-1"?> 
     84                <xml> 
    8185                  <string> 
    8286                    
     
    102106    public function testWhiteSpaceNormalize() 
    103107    { 
    104         $xml = '<xml> 
     108        $xml = '<?xml version="1.0" encoding="iso-8859-1"?> 
     109                <xml> 
    105110                  <string> 
    106111                    
     
    122127    public function testWhiteSpaceKeep() 
    123128    { 
    124         $xml = '<xml> 
     129        $xml = '<?xml version="1.0" encoding="iso-8859-1"?> 
     130                <xml> 
    125131                  <string> 
    126132                    
     
    167173    public function testUnserializeWithTagMap() 
    168174    { 
    169         $xml1         = '<root>' . 
     175        $xml1         = '<?xml version="1.0" encoding="iso-8859-1"?>' . 
     176                        '<root>' . 
    170177                        '  <foo>FOO</foo>' . 
    171178                        '  <bar>BAR</bar>' . 
    172179                        '</root>'; 
    173         $xml2         = '<root>' . 
     180        $xml2         = '<?xml version="1.0" encoding="iso-8859-1"?>' . 
     181                        '<root>' . 
    174182                        '  <foo>'. 
    175183                        '    <tomato>45</tomato>'. 
     
    199207    public function testUnserializeWithTypeGuessing() 
    200208    { 
    201         $xml          = '<root>' . 
     209        $xml          = '<?xml version="1.0" encoding="iso-8859-1"?>' . 
     210                        '<root>' . 
    202211                        '  <string>Just a string...</string>' . 
    203212                        '  <booleanValue>true</booleanValue>' . 
     
    228237        $this->assertTrue($result['array']['_content']); 
    229238    } 
     239 
     240    /** 
     241     * assert that output encoding is UTF-8 
     242     */ 
     243    public function testReturnEncoding() 
     244    { 
     245        $xml          = '<?xml version="1.0" encoding="iso-8859-1"?><root><string>A string containing german umlauts: äöü</string></root>'; 
     246        $unserializer = new stubXMLUnserializer(); 
     247        $this->assertEqual($unserializer->unserialize($xml), array('string' => utf8_encode('A string containing german umlauts: äöü'))); 
     248    } 
    230249} 
    231250?>