-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add expectErrorLog()
for expecting error_log()
output
#6118
base: main
Are you sure you want to change the base?
Conversation
I tried debugging it a bit more to find out how phpunit knows what the unit-under-test passed to
I can see the string also be mentioned in the event log stream of |
ohh I think I understand the problem now. |
1507fae
to
fa8961d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6118 +/- ##
=========================================
Coverage 95.09% 95.09%
- Complexity 6739 6742 +3
=========================================
Files 724 724
Lines 21267 21278 +11
=========================================
+ Hits 20223 20234 +11
Misses 1044 1044 ☔ View full report in Codecov by Sentry. |
a078ae1
to
5b5c7ee
Compare
I think we are in better shape now (put a new summary into the PR description) |
src/Framework/TestCase.php
Outdated
@@ -1007,6 +1014,11 @@ final protected function expectOutputString(string $expectedString): void | |||
$this->outputExpectedString = $expectedString; | |||
} | |||
|
|||
final protected function expectsErrorLog(): void |
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.
This should be expectErrorLog()
to be consistent with expectOutputString
, for example.
expectErrorLog()
for expecting error_log()
output
@@ -0,0 +1,31 @@ | |||
--TEST-- |
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.
expectErrorLog()
is a new feature. Therefore, we should not put its end-to-end tests into the regression
directory. The generic
would be acceptable for now.
great catch, fixed it. thank you! |
summary:
error_log()
without a call toexpectsErrorLog()
, the output is directly rendered in-between the summary (as tested in Regression test for error_log() #6127)error_log()
with a call toexpectsErrorLog()
, no more output is rendered in-between the test summary printing. when noerror_log()
is invoked the test is considered failed.backstory:
while looking into #2155 (comment) I realized PHPunit is already somehow capturing the
error_log()
output.I think this means we don't need a workaround like #2155 (comment) in phpunit itself, but just a API which allows us to make assertions on the already captured output.
DX wise I think there is also some room for improvement since the
error_log
'ged string just shows up in the test-debug output without any indication where this string is coming from (the test-author needs to look into the code beeing tested to realize that this string originates from aerror_log
) or how to make assertions on it.With this PR I am just sending a test so we can see the status quo and discuss where to move from here
closes #2155