[Console][2.3] ApplicationTester - test stdout and stderr#17255
[Console][2.3] ApplicationTester - test stdout and stderr#17255SpacePossum wants to merge 2 commits into
Conversation
|
Not sure how or if BC should be handled here, any opinions? |
There was a problem hiding this comment.
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.
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
|
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? |
| * 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.
This should be reverted as ConsoleOutputInterface extends OutputInterface
4e1c9c3 to
3b75524
Compare
5af06ad to
a5d522a
Compare
|
Reworked, happy to take notes/comments |
| * @var OutputInterface | ||
| */ | ||
| private $output; | ||
| private $captureOutputStreamsIndependent = false; |
|
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
stdoutandstderrusing theApplicationTester. This makes it hard to check if an application writes to the correct output.