mercredi 28 octobre 2015

Howto Test delete method in Laravel 5.1

I have a method in controller that I would like to test

public function destroy(Instrument $instrument)
{
    $instrument->delete();

    flash()->success('Instrument Deleted Successfully!');

    return Redirect::route('instrument.index');
}

If I am to test controller manually method works fine.

However, I have been trying to test this without much luck... btw, this method is accessed via DELETE method.

Below are some example of calls that I have tried:

$this->action('DELETE', 'InstrumentController@destroy', ['id' => 19]);

And this..

$this->delete('/instrument/destroy/19');

I was trying to test using $this->visit() but when you click on delete button a bootstrap toolkit appears, because its not preloaded in the dom i am unable to test using $this->visit()...

If some one could help out, would be great



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire