命令列測試
#簡介期望輸入/ 輸出簡介除了簡化HTTP 測試之外, Laravel 為測試需要使用者輸入的控制台應用提供了簡單的API 。
expectsOutput### ,和 ###assertExitCode### 方法: ###Laravel 使用
expectsQuestion 方法為控制台指令「模擬”用戶輸入。此外,還可以使用
assertExitCode 和
expectsOutput
/** * 测试控制台命令。 * * @return void */ public function test_console_command(){ $this->artisan('question') ->expectsQuestion('What is your name?', 'Taylor Otwell') ->expectsQuestion('Which language do you program in?', 'PHP') ->expectsOutput('Your name is Taylor Otwell and you program in PHP.') ->assertExitCode(0); }###本篇首發在###LearnKu.com### 網站上。 ######