-
Notifications
You must be signed in to change notification settings - Fork 7.9k
test to function ErrorException::getSeverity(); #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
was add a test to method uncovered from class ErrorException,and i test too anothers inheritance methods.
This test is not clear enough, don't use magic numbers. |
Hello @krakjoe how are you? please, give me some example and ill fix this code! |
"This test is not clear enough, don't use magic numbers." @krakjoe Thanks! |
/* Trigger exception */ | ||
preg_match(); | ||
?> | ||
--EXPECTF-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these values here should be predictable, such as message, severity, code, previous, file & line.
} | ||
throw new ErrorException($message, $code, $severity); | ||
} catch(ErrorException $err) { | ||
var_dump( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this long var_dump(), you can also test for \Exception's magic __toString() method by calling:
echo $err;
|
||
$message = "error exception, severity =>"; | ||
$code = 500; | ||
$severity = 75; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like @krakjoe mentioned, please do not use magic numbers, severity here should mimic the E_* constants, so you could for example assign $severity to E_WARNING and just give the $code a value of 0 since you are testing for getSeverity here anyway
Thanks, also remember you can define error_reporting in an --INI-- section, so that you can reliably determine that whatever value you set $severity to will not fail the: if(!(error_reporting() & $severity)) check, thanks for your work :) |
okey @KalleZ Thank you for your explanation !!! 👍 |
@marcosptf bump ... you forgot about this one :) |
im fixing it... |
Merged 3efef6d Thanks. |
was add a test to method uncovered from class ErrorException,and i test too anothers inheritance methods.