Laravel 5.7 improves artisan command testing / console testing that helps the developer to test their functions in console.
Laravel 5.7 updates console commands for testing console applications that ask for user input.
Below steps will helps us to perform console testing :-
1) Run below command :-
php artisan make:command ConsoleTest
Above command will create ConsoleTest.php file at path \app\Console\Commands
2) Update ConsoleTest.php file :-
Update value for $signature and handle function in ConsoleTest.php file.
3) Run below command :-
php artisan ConsoleTest
Above command will directly output the below line :-
This command is working fine.
4) Update handle function :-
Open [ Ссылка ] and copy code from there.
We will update handle function again with the code that will ask the user for input.
5) Run below command :-
php artisan ConsoleTest
Above command will ask the user the questions and display the answer.
6) Update ExampleTest.php file :-
Now update ExampleTest.php file located at path \tests\Feature
Copy from [ Ссылка ] and update testBasicTest function as shown in video.
7) Run below command :-
./vendor/bin/phpunit
The above command will give output as OK in green if test is successful otherwise will print "Failure" in Red if test fail.
And we have seen both cases in video.
So that's all for now. Hope you understand console testing by Laravel 5.7
Thanks for watching :)
Ещё видео!