I still have a lot of doubt about doing unit tests to the drivers that I believe in laravel, for example: employeeController, where this has methods like index, store, edit, Does anyone know how to perform these tests on the controller's methods?
I still have a lot of doubt about doing unit tests to the drivers that I believe in laravel, for example: employeeController, where this has methods like index, store, edit, Does anyone know how to perform these tests on the controller's methods?
To see these functions provided by Laravel, use the command when creating your controller:
php artisan make:controller EmpleadoController --resource
and your route file
route::resource("EmpleadoController");
Responding to your comment
In your composer.json
you must include:
// ...
"require-dev": {
"phpunit/phpunit": "3.7.*" // <--------
},
// ...
then you run from the terminal standing on your project
Composer update
from console you see that everything is fine
vendor/bin/phpunit
Then you create a file for tests in App/prueba.php
we create a function
public function miapp()
{
$response = $this->call('GET', 'miapp');
$this->assertResponseOk();
$this->assertEquals('App de prueba', $response->getContent());
}
You rerun the command:
vendor/bin/phpunit
and in your routes file:
Route::get('miapp', function(){
return 'Esta es una prueba';
});
and again:
vendor/bin/phpunit
We have the official documentation from Laravel.