Changeset 106

Show
Ignore:
Timestamp:
01/09/08 00:08:16 (12 months ago)
Author:
iteman
Message:

- Refactored.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Stagehand/TestRunner/PHPSpec/Reporter.php

    r105 r106  
    107107            switch ($symbol) { 
    108108            case '.': 
    109                 $symbol = Console_Color::convert("%g$symbol%n"); 
     109                $symbol = $this->_green($symbol); 
    110110                break; 
    111111            case 'F': 
    112                 $symbol = Console_Color::convert("%r$symbol%n"); 
     112                $symbol = $this->_red($symbol); 
    113113                break; 
    114114            case 'E': 
    115                 $symbol = Console_Color::convert("%p$symbol%n"); 
     115                $symbol = $this->_magenta($symbol); 
    116116                break; 
    117117            case 'P': 
    118                 $symbol = Console_Color::convert("%y$symbol%n"); 
     118                $symbol = $this->_yellow($symbol); 
    119119                break; 
    120120            } 
     
    145145 
    146146            if ($failuresCount + $deliberateFailuresCount + $errorsCount + $exceptionsCount + $pendingsCount == 0) { 
    147                 $colorCode = '%g'; 
     147                $colorCode = 'green'; 
    148148            } elseif ($pendingsCount && $failuresCount + $deliberateFailuresCount + $errorsCount + $exceptionsCount == 0) { 
    149                 $colorCode = '%y'; 
     149                $colorCode = 'yellow'; 
    150150            } else { 
    151                 $colorCode = '%r'; 
     151                $colorCode = 'red'; 
    152152            } 
    153153 
     
    165165                                                                '/^(Pending:)/m' 
    166166                                                                ), 
    167                                                           array("$colorCode\$1%n", 
    168                                                                 '%p$1$2$3%n', 
    169                                                                 '%r$1$2$3%n', 
    170                                                                 '%r$1$2$3%n', 
    171                                                                 '%y$1$2$3%n', 
    172                                                                 '%g$1$2$3%n', 
    173                                                                 '$1%p$2%n', 
    174                                                                 '$1%r$2%n', 
    175                                                                 '$1%y$2%n', 
    176                                                                 '%p$1%n', 
    177                                                                 '%r$1%n', 
    178                                                                 '%y$1%n' 
     167                                                          array($this->{"_$colorCode"}('$1'), 
     168                                                                $this->_magenta('$1$2$3'), 
     169                                                                $this->_red('$1$2$3'), 
     170                                                                $this->_red('$1$2$3'), 
     171                                                                $this->_yellow('$1$2$3'), 
     172                                                                $this->_green('$1$2$3'), 
     173                                                                '$1' . $this->_magenta('$2'), 
     174                                                                '$1' . $this->_red('$2'), 
     175                                                                '$1' . $this->_yellow('$2'), 
     176                                                                $this->_magenta('$1'), 
     177                                                                $this->_red('$1'), 
     178                                                                $this->_yellow('$1') 
    179179                                                                ), 
    180180                                                          Console_Color::escape($output)) 
     
    196196     * @access private 
    197197     */ 
     198 
     199    // }}} 
     200    // {{{ _green() 
     201 
     202    /** 
     203     * @param string $text 
     204     * @return text 
     205     */ 
     206    private function _green($text) 
     207    { 
     208        return Console_Color::convert("%g$text%n"); 
     209    } 
     210 
     211    // }}} 
     212    // {{{ _red() 
     213 
     214    /** 
     215     * @param string $text 
     216     * @return text 
     217     */ 
     218    private function _red($text) 
     219    { 
     220        return Console_Color::convert("%r$text%n"); 
     221    } 
     222 
     223    // }}} 
     224    // {{{ _magenta() 
     225 
     226    /** 
     227     * @param string $text 
     228     * @return text 
     229     */ 
     230    private function _magenta($text) 
     231    { 
     232        return Console_Color::convert("%m$text%n"); 
     233    } 
     234 
     235    // }}} 
     236    // {{{ _yellow() 
     237 
     238    /** 
     239     * @param string $text 
     240     * @return text 
     241     */ 
     242    private function _yellow($text) 
     243    { 
     244        return Console_Color::convert("%y$text%n"); 
     245    } 
    198246 
    199247    /**#@-*/