Changeset 100

Show
Ignore:
Timestamp:
12/19/07 11:09:29 (13 months ago)
Author:
iteman
Message:

- Fixed the defect that an unexpected class to be marked as a target.
- Refactored.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Stagehand/TestRunner/Common.php

    r98 r100  
    231231 
    232232    // }}} 
    233     // {{{ _exclude() 
    234  
    235     /** 
    236      * Returns whether the class should be exclude or not. 
    237      * 
    238      * @param string $class 
    239      * @return boolean 
    240      */ 
    241     private function _exclude($class) 
    242     { 
    243         if (!is_null($this->_excludePattern) && preg_match($this->_excludePattern, $class)) { 
    244             return true; 
    245         } 
    246  
    247         return !is_subclass_of($class, $this->_baseClass); 
    248     } 
    249  
    250     // }}} 
    251233    // {{{ _collectTestCases() 
    252234 
     
    294276            $newClasses = array_values(array_diff(get_declared_classes(), $currentClasses)); 
    295277            for ($j = 0, $jCount = count($newClasses); $j < $jCount; ++$j) { 
    296                 if ($this->_exclude($newClasses[$j])) { 
     278                if (!is_subclass_of($newClasses[$j], $this->_baseClass)) { 
    297279                    continue; 
    298280                } 
    299281 
    300                 if (!$this->_include($newClasses[$j])) { 
     282                if (!is_null($this->_excludePattern) 
     283                    && preg_match($this->_excludePattern, $newClasses[$j]) 
     284                    ) { 
     285                    continue; 
     286                } 
     287 
     288                if (!is_null($this->_includePattern) 
     289                    && !preg_match($this->_includePattern, $newClasses[$j]) 
     290                    ) { 
    301291                    continue; 
    302292                } 
     
    344334 
    345335        return $directories; 
    346     } 
    347  
    348     // }}} 
    349     // {{{ _include() 
    350  
    351     /** 
    352      * Returns whether the class should be include or not. 
    353      * 
    354      * @param string $class 
    355      * @return boolean 
    356      */ 
    357     private function _include($class) 
    358     { 
    359         if (!is_null($this->_includePattern) && preg_match($this->_includePattern, $class)) { 
    360             return true; 
    361         } 
    362  
    363         return is_subclass_of($class, $this->_baseClass); 
    364336    } 
    365337