dimanche 5 juillet 2015

Is there any example on how to write test for CRUD based app in "Laravel 5.1"?

I am new to test driven development. I am somewhat experienced with the php's Laravel framework. In it's new version (5.1) they have massively improved their testing features. I want to know if there is any example of how to write tests for a basic CRUD app in laravel 5.1. I was able to test the creation of tasks. But still I am not sure if it is the best practice. Please help me.

<?php

use App\Task;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class TasksTest extends TestCase
{

    use DatabaseTransactions;

    public function testCreateTask()
    {
        $this->visit('/tasks/create')
             ->type('This is task title', 'title')
             ->type('This is task description', 'description')
             ->press('Create Task')
             ->seePageIs('/tasks')
             ->see('This is task title');
    }

}

Aucun commentaire:

Enregistrer un commentaire