[Console] Wrong response content question multiline
Symfony version(s) affected
6.4.* (same on 7.1.*)
Description
Hello,
When I test multiline question with phpunit and CommandTester. Multiline question and next questions have invalid content.
Is there a bug, or something to do ?
Probably same question https://github.com/symfony/symfony/discussions/58379
How to reproduce
https://github.com/alamirault/symfony-command-multiline
Run ./vendor/bin/phpunit tests/Integration/Command/BadCommandTest.php to see failed test.
Expected is
But currently is
Possible Solution
No response
Additional Context
No response
Hey, thanks for your report! There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?
Still relevant
Indeed there seems to be two issues regarding multiline questions test:
- Inputs are joined together with new lines, so you cannot tell where a multiline answer ends. That’s why the phone number appears as part of the address.
I thought suffixing the address by an End-of-Transmission character would fix that, but fgetc won’t give it any special meaning so a check could be added.
- Multiline answers are read on a clone of the original stream, but its pointer won’t be updated. That’s why the first address line appears as phone number.
This one should be easily fixed: just fseek the original stream to the position of the clone if it is seekable.
Thanks you @MatTheCat !
It's fix the bug