-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console][2.3] ApplicationTester - test stdout and stderr #17255
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
[Console][2.3] ApplicationTester - test stdout and stderr #17255
Conversation
Not sure how or if BC should be handled here, any opinions? |
} | ||
|
||
/** | ||
* @return resource | ||
*/ | ||
private function openOutputStream() | ||
protected function openErrorStream() |
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.
In my opinion you shouldn't modify code just for tests. If this is something you'd like to mock or control in tests, you should inject an object that has the open methods.
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.
As a general rule, I agree. However ApplicationTester
is not part of PHPUnit making mocking hard.
I don't see an option that will have less impact on the current code that will still allow for checking what is written to stdout
and what to stderr
.
For example the whole ConsoleOutput
class could be mimic'ed and injected (some thing like https://github.com/symfony/symfony/pull/17255/files?diff=split#diff-3bb511669d5c28238608aa75cf865163L67), but would replace a part of the logic that should tested itself.
007be88
to
bbde83b
Compare
* * verbosity: Sets the output verbosity flag | ||
* * interactive: Sets the input interactive flag | ||
* * decorated: Sets the output decorated flag | ||
* * verbosity: Sets the output verbosity flag |
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.
should be reverted
I'll rework this and create a new proposal :) |
1b66968
to
f3fbc7a
Compare
@iltar please have a look at it again. |
Ping @nicolas-grekas, sorry for pinging you from a PR you are not involved in so far, hope it is OK. |
ping @stof (sorry, but please have look) |
Any news on that? |
@@ -108,7 +163,7 @@ public function getInput() | |||
/** | |||
* Gets the output instance used by the last execution of the application. | |||
* | |||
* @return OutputInterface The current output instance | |||
* @return OutputInterface|ConsoleOutputInterface The current output instance |
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 reverted as ConsoleOutputInterface
extends OutputInterface
4e1c9c3
to
3b75524
Compare
5af06ad
to
a5d522a
Compare
Reworked, happy to take notes/comments |
*/ | ||
private $output; | ||
private $captureOutputStreamsIndependent = false; |
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.
$captureStreamsIndependently
?
Thank you @SpacePossum. |
Thank you all for reviewing! :) |
This PR was merged into the 1.12 branch. Discussion ---------- Split output to stderr and stdout For more correct testing I need symfony/symfony#17255 to be resolved. issue: #1579 (and others) Commits ------- 880f58d Split output to stderr and stdout.
Currently it is not possible to test application output of both
stdout
andstderr
using theApplicationTester
. This makes it hard to check if an application writes to the correct output.