Changeset 1750

Show
Ignore:
Timestamp:
07/30/08 00:56:06 (4 months ago)
Author:
mikey
Message:

fix imports
throw exception in net::stubbles::xml::unserializer::stubXMLUnserializer::unserializeFile() if file can not be found

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework/trunk/src/main/php/net/stubbles/xml/unserializer/stubXMLUnserializer.php

    • Property svn:keywords set to Id
    r1311 r1750  
    66 * @package     stubbles 
    77 * @subpackage  xml_unserializer 
     8 * @version     $Id$ 
    89 */ 
    9 stubClassLoader::load('net::stubbles::xml::unserializer::stubXMLUnserializerOption'); 
     10stubClassLoader::load('net::stubbles::lang::exceptions::stubFileNotFoundException', 
     11                      'net::stubbles::xml::stubXMLException', 
     12                      'net::stubbles::xml::unserializer::stubXMLUnserializerOption' 
     13); 
    1014/** 
    1115 * Class to read XML files and turn them into simple PHP types. 
     
    6064     * @param   string  $fileName 
    6165     * @return  mixed 
     66     * @throws  stubFileNotFoundException 
    6267     * @throws  stubXMLException 
    6368     */ 
    6469    public function unserializeFile($fileName) 
    6570    { 
     71        if (file_exists($fileName) === false) { 
     72            throw new stubFileNotFoundException($fileName); 
     73        } 
     74         
    6675        $reader = $this->initParser(); 
    6776        if ($reader->open($fileName, $this->options[stubXMLUnserializerOption::ENCODING_SOURCE]) === false) { 
  • framework/trunk/src/test/php/net/stubbles/xml/unserializer/stubXMLUnserializerTestCase.php

    • Property svn:keywords set to Id
    r1703 r1750  
    66 * @package     stubbles 
    77 * @subpackage  xml_unserializer_test 
     8 * @version     $Id$ 
    89 */ 
    910stubClassLoader::load('net::stubbles::xml::unserializer::stubXMLUnserializer'); 
     
    287288        $this->assertEquals(array('string' => utf8_encode('A string containing german umlauts: &ᅵᅵᅵ')), $unserializer->unserialize($xml)); 
    288289    } 
     290 
     291    /** 
     292     * test unserializing a non-existing file 
     293     * 
     294     * @test 
     295     * @expectedException  stubFileNotFoundException 
     296     */ 
     297    public function unserializeNonExistingFile() 
     298    { 
     299        $unserializer = new stubXMLUnserializer(); 
     300        $unserializer->unserializeFile(TEST_SRC_PATH . '/resources/doesNotExist.xml'); 
     301    } 
    289302} 
    290303?>