symfony icon indicating copy to clipboard operation
symfony copied to clipboard

[Console] Wrong response content question multiline

Open alamirault opened this issue 1 year ago • 2 comments

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 image

But currently is

image

Possible Solution

No response

Additional Context

No response

alamirault avatar Nov 18 '24 11:11 alamirault

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?

carsonbot avatar May 19 '25 13:05 carsonbot

Still relevant

alamirault avatar May 29 '25 11:05 alamirault

Indeed there seems to be two issues regarding multiline questions test:

  1. 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.

  1. 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.

MatTheCat avatar Aug 22 '25 09:08 MatTheCat

Thanks you @MatTheCat !

It's fix the bug

alamirault avatar Oct 03 '25 08:10 alamirault