Laravel - Artisan Commands

Laravel 5.7 comes with a new way to process and test new commands. It includes a new artisan team testing feature and the demo is mentioned below −
class ArtisanCommandTest extends TestCase{ public function testBasicTest() { $this->artisan('nova:create', [ 'name' => 'My New Admin panel' ]) ->expectsQuestion('Please enter your API key', 'apiKeySecret') ->expectsOutput('Authenticating...') ->expectsQuestion('Please select a version', 'v1.0') ->expectsOutput('Installing...') ->expectsQuestion('Do you want to compile the assets?', 'yes') ->expectsOutput('Compiling assets...') ->assertExitCode(0); } }
Code Explanation
Here, a new class named "ArtisanCommandTest" is created in the test cases module. It includes the base function testBasicTest which includes various assertion functions.
The artisan team expects a question to include two attributes. One with a question and the other with apiKeySecret . Here the artisan checks apiKeySecret and validates the input sent by the user.
The same scenario applies to the "Please select a version" question, where the user is required to mention a specific version.