dimanche 19 juin 2016

Unit Testing (Laravel 5) - Identifying test senarios

I'm new to unity testing and having a hard time identifying the correct scenarios to test.

Mainly I have following functions in my website:

View Pages

  1. Retrieve values from the DB using a model

  2. Pass that data into the HTML template via the controller

  3. Print data in HTML template to display

//view

public function getStudents(){

$students = Student::all(); // model: get all the students from Database
$data['students'] = $students;   
return view('views/students', $data);// Pass data into the view   

}

Edit/Create Pages

  1. Retrieve input data from the view file

  2. Validate

  3. Save/Update DB and print success message.

    public function editStudent($id){

    //grab input data
    
    //validate
    
    //save in DB
    
    

    }

Above scenario looks pretty straight forward. As long as I get database entries I get the output. Do we need to write unit tests for this? What are the test scenarios?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire