8000 [Console] How provide input stream for ApplicationTester? · Issue #24784 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] How provide input stream for ApplicationTester? #24784

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

Closed
Chi-teck opened this issue Nov 1, 2017 · 6 comments
Closed

[Console] How provide input stream for ApplicationTester? #24784

Chi-teck opened this issue Nov 1, 2017 · 6 comments

Comments

@Chi-teck
Copy link
Contributor
Chi-teck commented Nov 1, 2017
Q A
Bug report? no
Feature request? yes
Symfony version 3.3.7

I am using the following code to test interactive console application.

$input_stream = $this->getInputStream("Some user input\n");
$question_helper = new QuestionHelper();
$question_helper->setInputStream($input_stream);

$helper_set = $application->getHelperSet();
$helper_set->set($question_helper);

$tester = new ApplicationTester($application);
$tester->run($arguments);

It works well but it is not compatible with Symfony 4 because setInputStream() method has been removed.

The documentation suggests using StreamableInputInterface::setStream() but I could not find any way to set Input for ApplicationTester.

Any suggestions?

@dmaicher
Copy link
Contributor
dmaicher commented Nov 1, 2017

@Chi-teck
Copy link
Contributor Author
Chi-teck commented Nov 1, 2017

@dmaicher, Yes, I did. It works fine with command tester. I need the same for application tester.

8000

@chalasr
Copy link
Member
chalasr commented Nov 2, 2017

There's no reason to not be able to do the same using the application tester.
👍 for ApplicationTester::setInputs().
Might need an internal trait to reuse logic between CommandTester and ApplicationTester, PR welcomed

@Simperfit
Copy link
Contributor

@Chi-teck Do you want to provide the PR ?

@Chi-teck
Copy link
Contributor Author
Chi-teck commented Nov 3, 2017

@Simperfit, I can't work on this at the moment. Feel free to submit the PR if you want.

@Simperfit
Copy link
Contributor

I'm gonna do it.

chalasr pushed a commit that referenced this issue Nov 26, 2017
… some code (Simperfit)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Console] add setInputs to ApplicationTester and share some code

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24784
| License       | MIT
| Doc PR        | todo

I didn't implemented the tests because I don't know how to write them on ApplicationTester.

Commits
-------

ea86ed8 [Console] add setInputs to ApplicationTest and share some code
@chalasr chalasr closed this as completed Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0