Changeset 2289

Show
Ignore:
Timestamp:
03/12/08 10:32:25 (6 months ago)
Author:
Geert
Message:

Extending Exception the way it should be done. Calling parent's constructor now and got rid of magic get. http://php.net/exceptions

Location:
trunk/modules/unit_test
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/unit_test/libraries/Unit_Test.php

    r2288 r2289  
    390390class Kohana_Unit_Test_Exception extends Exception { 
    391391 
    392     protected $message = ''; 
    393392    protected $debug = NULL; 
    394     protected $file = ''; 
    395     protected $line = ''; 
    396  
    397     /** 
    398      * Set exception message and debug 
     393 
     394    /** 
     395     * Sets exception message and debug info. 
    399396     * 
    400397     * @param   string  message 
     
    405402    { 
    406403        // Failure message 
    407         $this->message = (string) $message; 
     404        parent::__construct($message); 
    408405 
    409406        // Extra user-defined debug info 
    410407        $this->debug = $debug; 
    411408 
    412         // Retrieve failure location 
     409        // Overwrite failure location 
    413410        $trace = $this->getTrace(); 
    414411        $this->file = $trace[0]['file']; 
     
    417414 
    418415    /** 
    419      * Magically gets an object property. 
    420      * 
    421      * @param   string  property key 
    422      * @return  mixed   variable value if the key is found 
    423      * @return  void    if the key is not found 
    424      */ 
    425     public function __get($key) 
    426     { 
    427         if (isset($this->$key)) 
    428             return $this->$key; 
     416     * Returns the user-defined debug info 
     417     * 
     418     * @return  mixed  debug property 
     419     */ 
     420    public function getDebug() 
     421    { 
     422        return $this->debug; 
    429423    } 
    430424 
  • trunk/modules/unit_test/views/kohana_unit_test.php

    r2288 r2289  
    136136                        <td class="k-failed"> 
    137137                            <strong><?php echo Kohana::lang('unit_test.failed') ?></strong> 
    138                             <pre><?php echo html::specialchars($result->message) ?></pre> 
    139                             <?php echo html::specialchars($result->file) ?> (<?php echo Kohana::lang('unit_test.line') ?>&nbsp;<?php echo $result->line ?>) 
     138                            <pre><?php echo html::specialchars($result->getMessage()) ?></pre> 
     139                            <?php echo html::specialchars($result->getFile()) ?> (<?php echo Kohana::lang('unit_test.line') ?>&nbsp;<?php echo $result->getLine() ?>) 
    140140 
    141                             <?php if ($result->debug !== NULL): ?> 
    142                                 <pre class="k-debug" title="Debug info"><?php echo '(', gettype($result->debug), ') ', html::specialchars(var_export($result->debug, TRUE)) ?></pre> 
     141                            <?php if ($result->getDebug() !== NULL): ?> 
     142                                <pre class="k-debug" title="Debug info"><?php echo '(', gettype($result->getDebug()), ') ', html::specialchars(var_export($result->getDebug(), TRUE)) ?></pre> 
    143143                            <?php endif ?> 
    144144