I would like to Unit test one of my controller and I'm wondering how to do that without impacting the database. Here are my files :
Route:
Route::resource('tasks', 'TasksListController');
In my TasksListController:
public function store()
{
if (empty(Input::get('name')) || !isset(Input::get('name'))) {
return false;
}
if (Task::create(Input::all())) {
return true;
}
return false;
}
My form:
<form action="/tasks" name="task" method="post">
<input type="text" name="name" />
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
</form>
My Unit Test:
class TasksTest extends TestCase {
public function testAddTask()
{
// How can I test the task creation ?
}
}