Skip to content

Commit

Permalink
Adding parsing of Class::Constant for use by @expectedExceptionCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Petrus Rademeyer committed Dec 8, 2010
1 parent 06603fe commit 8a32ee9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions PHPUnit/Util/Test.php
Expand Up @@ -128,6 +128,21 @@ public static function getExpectedException($className, $methodName)

if (isset($matches[3])) {
$code = (int)$matches[3];
if( $code == 0 && strpos( $annotations['method']['expectedExceptionCode'][0], '::' ) !== false ) {
$arrTag = explode( '::', $annotations['method']['expectedExceptionCode'][0] );
$sPossibleClass = $arrTag[0];
$sPossibleConstant = $arrTag[1];

try {
$cls = new ReflectionClass( $sPossibleClass );
if ( $cls->hasConstant( $sPossibleConstant ) ) {
$code = (int) $cls->getConstant( $sPossibleConstant );
}
} catch ( Exception $e ) {
//The class could probably not be found but we'll just let the test cases continue for now.
}

}
}

else if (isset($annotations['method']['expectedExceptionCode'])) {
Expand Down

0 comments on commit 8a32ee9

Please sign in to comment.