Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Console] Adapt doc for easier testing of commands needing user inputs#6623

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
xabbuh merged 1 commit intosymfony:masterfromchalasr:commandtester_userinputs
Jun 30, 2016

Conversation

@chalasr
Copy link
Member

@chalasrchalasr commentedMay 28, 2016
edited
Loading

Doc-PR forsymfony/symfony#18710.

This one eases testing of commands needing user interactions by simulating them from the CommandTester directly, by creating a input stream from the ones set by the developer.

ogizanagi and OskarStark reacted with thumbs up emojiwebnet-fr reacted with heart emoji
If you want to write a unit test for a command which expectssome kind of input
from the command line, you need to set thehelper input stream::
If you want to write a unit test for a command which expectsuser inputs
from the command line, you need to set theinputs like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You need to end the paragraph with two colons so that the following block will be properly treated as a PHP code block.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Fixed, Thank's@xabbuh

@OskarStark
Copy link
Contributor

LGTM 👍

@chalasr
Copy link
MemberAuthor

chalasr commentedJun 2, 2016
edited
Loading

Updated according tosymfony/symfony@19117ce
Tests pass

@chalasrchalasrforce-pushed thecommandtester_userinputs branch from8af5ff0 to0d03e8aCompareJune 4, 2016 10:43
@chalasrchalasrforce-pushed thecommandtester_userinputs branch from0d03e8a toa8e793aCompareJune 16, 2016 11:00
fabpot added a commit to symfony/symfony that referenced this pull requestJun 16, 2016
…dTester (chalasr)This PR was merged into the 3.2-dev branch.Discussion----------[Console] Simplify simulation of user inputs in CommandTester| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        |symfony/symfony-docs#6623After@javiereguiluz pointed it in#17470, I open this PR to simplify the simulation of user inputs for testing a Command.It would be done by calling `CommandTester::setUserInputs()` with an array of inputs as argument, and so make the CommandTester creating an input stream from the inputs set by the developer, then call `QuestionHelper::setInputStream` and assign it to the helperSet of the command, sort as all is done automatically in one call.Depends on#18999Commits-------c7ba38a [Console] Set user inputs from CommandTester
symfony-splitter pushed a commit to symfony/console that referenced this pull requestJun 16, 2016
…dTester (chalasr)This PR was merged into the 3.2-dev branch.Discussion----------[Console] Simplify simulation of user inputs in CommandTester| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        |symfony/symfony-docs#6623After@javiereguiluz pointed it in #17470, I open this PR to simplify the simulation of user inputs for testing a Command.It would be done by calling `CommandTester::setUserInputs()` with an array of inputs as argument, and so make the CommandTester creating an input stream from the inputs set by the developer, then call `QuestionHelper::setInputStream` and assign it to the helperSet of the command, sort as all is done automatically in one call.Depends on #18999Commits-------c7ba38a [Console] Set user inputs from CommandTester
@chalasr
Copy link
MemberAuthor

This is no more on hold, the PR has been merged.

@javiereguiluz
Copy link
Member

Status: needs review

@chalasr
Copy link
MemberAuthor

Thank you@javiereguiluz, can I do it myself for next?

@javiereguiluz
Copy link
Member

@chalasr yes, it's explained a bit here:http://symfony.com/doc/current/contributing/community/reviews.html#the-bug-report-review-process

Sadly our bot still has things to learn. I'd love to say:"hey Carson, remove the "On hold" label"

@chalasrchalasrforce-pushed thecommandtester_userinputs branch froma8e793a to096308fCompareJune 16, 2016 17:39
@xabbuhxabbuh removed the On hold labelJun 18, 2016
input stream.
By calling:method:`CommandTester::setInputs`, you imitate what the console would
do internally with all user input through the CLI. This way you can test any
user interaction (even complex ones) by passing the appropriate inputs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we should be more explicit what it means that the input is an array (IIUC one element is read once new input is requested by the command, right?).

Copy link
MemberAuthor

@chalasrchalasrJun 18, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@xabbuh right, the behavior stays the same, we create a string from the given array of inputs, (each input is separated via a"\n"), then theQuestionHelper reads the stream whenask() is called (viafgets).
I addeda short explanation, I hope it is clear enough.

@chalasrchalasrforce-pushed thecommandtester_userinputs branch from51eb9d0 tob50ab55CompareJune 18, 2016 10:34
console would do internally with all user input through the CLI. This way
you can test any user interaction (even complex ones) by passing an appropriate
input stream.
By calling:method:`CommandTester::setInputs`, you imitate what the console would
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this needs to be the FQCN

@wouterj
Copy link
Member

Thanks for the contribution@chalasr! I've added 2 not so big comments.

Status: needs work

@chalasrchalasrforce-pushed thecommandtester_userinputs branch 5 times, most recently frombc90258 tob56ad94CompareJune 19, 2016 10:52
@chalasr
Copy link
MemberAuthor

@wouterj I made the changes.

Status: needs review

@chalasrchalasrforce-pushed thecommandtester_userinputs branch 4 times, most recently fromf2bcdfc toe9218b3CompareJune 20, 2016 19:14
@chalasr
Copy link
MemberAuthor

I made some changes.
Do not hesitate to give me your suggestions, writing documentation is almost harder than adding the feature itself!

Status: needs review

// Equals to a user inputting "Test" and hitting ENTER
// If you need to enter a confirmation, "yes\n" will work

$commandTester->setInputs('This', 'That');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should bearray('This', 'That') (same on line 299).

Also, I think we should add the descriptive comment before the line of code.

@chalasr
Copy link
MemberAuthor

@wouterj Changes made, thanks for the review.

@wouterj
Copy link
Member

Status: reviewed

👍 thanks for the contribution!

@chalasrchalasrforce-pushed thecommandtester_userinputs branch 3 times, most recently fromfa056e2 toeaa3294CompareJune 23, 2016 18:28
@chalasr
Copy link
MemberAuthor

@javiereguiluz Please let me know if it is complete enough for you.

@chalasrchalasrforce-pushed thecommandtester_userinputs branch fromeaa3294 to0694d58CompareJune 23, 2016 18:34
Fix missing colonChange userInputs to inputsTry to fix platformsh buildRe-add useful use statementsFixed typo, use FQCN::methodRollback not useful diffFormattingAdd more examples, precise documentationtypo 'would have type' => 'would have typed'removing an ending dot in comment for consistency
@chalasrchalasrforce-pushed thecommandtester_userinputs branch from0694d58 to26fdbe0CompareJune 23, 2016 18:46
@javiereguiluz
Copy link
Member

👍

@chalasr thanks for providing these docs and for your patience during the review process.

@xabbuh
Copy link
Member

Thank you@chalasr.

@xabbuhxabbuh merged commit26fdbe0 intosymfony:masterJun 30, 2016
xabbuh added a commit that referenced this pull requestJun 30, 2016
…ing user inputs (chalasr)This PR was merged into the master branch.Discussion----------[Console] Adapt doc for easier testing of commands needing user inputsDoc-PR forsymfony/symfony#18710.This one eases testing of commands needing user interactions by simulating them from the CommandTester directly, by creating a input stream from the ones set by the developer.Commits-------26fdbe0 [Console] Adapt doc for easier testing of commands needing user inputs
xabbuh added a commit that referenced this pull requestJun 30, 2016
@chalasrchalasr deleted the commandtester_userinputs branchJune 30, 2016 17:02
@chalasrchalasr restored the commandtester_userinputs branchAugust 16, 2016 12:02
@chalasrchalasr deleted the commandtester_userinputs branchOctober 25, 2016 19:48
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@chalasr@OskarStark@javiereguiluz@wouterj@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp