{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/ideas/issues/1404","repository_url":"https://api.github.com/repos/laravel/ideas","labels_url":"https://api.github.com/repos/laravel/ideas/issues/1404/labels{/name}","comments_url":"https://api.github.com/repos/laravel/ideas/issues/1404/comments","events_url":"https://api.github.com/repos/laravel/ideas/issues/1404/events","html_url":"https://github.com/laravel/ideas/issues/1404","id":383945992,"node_id":"MDU6SXNzdWUzODM5NDU5OTI=","number":1404,"title":"[Proposal]Can't test choice in command which maybe with multiple answers","user":{"login":"kiyonlin","id":1214670,"node_id":"MDQ6VXNlcjEyMTQ2NzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1214670?v=4","gravatar_id":"","url":"https://api.github.com/users/kiyonlin","html_url":"https://github.com/kiyonlin","followers_url":"https://api.github.com/users/kiyonlin/followers","following_url":"https://api.github.com/users/kiyonlin/following{/other_user}","gists_url":"https://api.github.com/users/kiyonlin/gists{/gist_id}","starred_url":"https://api.github.com/users/kiyonlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiyonlin/subscriptions","organizations_url":"https://api.github.com/users/kiyonlin/orgs","repos_url":"https://api.github.com/users/kiyonlin/repos","events_url":"https://api.github.com/users/kiyonlin/events{/privacy}","received_events_url":"https://api.github.com/users/kiyonlin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-24T00:36:48Z","updated_at":"2018-11-24T01:17:23Z","closed_at":"2018-11-24T01:17:23Z","author_association":"NONE","body":"When I want to get multiple answers of a choice in a command like this:\r\n```php\r\npublic function handle()\r\n{\r\n      $choices = $this->choice('multi choice', ['one', 'two'], null, 1, true);\r\n      // the answers of the choice are [\"one\",\"two\"]\r\n      $this->line('Your choice was ' . json_encode($choices));\r\n}\r\n```\r\n\r\nBut I can't test it like this:\r\n```php\r\n    /**\r\n     * A basic test example.\r\n     *\r\n     * @return void\r\n     */\r\n    public function testExample()\r\n    {\r\n        $this->artisan('command:name')\r\n            ->expectsQuestion('multi choice', 'one,two')\r\n            ->expectsOutput('Your choice was [\"one\",\"two\"]')\r\n            //->expectsOutput('Your choice was \"one,two\"')\r\n            ->assertExitCode(0);\r\n    }\r\n```\r\nBecause the function `expectsQuestion` in [PendingCommand.php](https://github.com/laravel/framework/blob/5.7/src/Illuminate/Foundation/Testing/PendingCommand.php)  doesn't accept the answers of type array.\r\n\r\nSo this function maybe add an additional type for the answer param like this:\r\n```php\r\n    /**\r\n     * Specify a question that should be asked when the command runs.\r\n     *\r\n     * @param  string  $question\r\n     * @param  string|array  $answer\r\n     * @return $this\r\n     */\r\n    public function expectsQuestion($question, $answer)\r\n    {\r\n        $this->test->expectedQuestions[] = [$question, $answer];\r\n\r\n        return $this;\r\n    }\r\n```\r\n\r\nThanks to everyone."},"comment":{"url":"https://api.github.com/repos/laravel/ideas/issues/comments/441335249","html_url":"https://github.com/laravel/ideas/issues/1404#issuecomment-441335249","issue_url":"https://api.github.com/repos/laravel/ideas/issues/1404","id":441335249,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTMzNTI0OQ==","user":{"login":"kiyonlin","id":1214670,"node_id":"MDQ6VXNlcjEyMTQ2NzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1214670?v=4","gravatar_id":"","url":"https://api.github.com/users/kiyonlin","html_url":"https://github.com/kiyonlin","followers_url":"https://api.github.com/users/kiyonlin/followers","following_url":"https://api.github.com/users/kiyonlin/following{/other_user}","gists_url":"https://api.github.com/users/kiyonlin/gists{/gist_id}","starred_url":"https://api.github.com/users/kiyonlin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiyonlin/subscriptions","organizations_url":"https://api.github.com/users/kiyonlin/orgs","repos_url":"https://api.github.com/users/kiyonlin/repos","events_url":"https://api.github.com/users/kiyonlin/events{/privacy}","received_events_url":"https://api.github.com/users/kiyonlin/received_events","type":"User","site_admin":false},"created_at":"2018-11-24T01:17:23Z","updated_at":"2018-11-24T01:17:23Z","author_association":"NONE","body":"There is no problem. Sorry about that. It just gets some warning from idea."}}
{"actor":{"display_login":"kiyonlin"}}