lundi 9 novembre 2015

Laravel 5.1 PhpUnit Delete method not working

I am writing a simple test to create an element, see if it is there and then delete it to verify the integrity of my web app every time I build it.

I have a test:

$this->visit('admin/menu/samples')
        ->seePageIs('admin/menu/samples')
        ->click('New Sample')
        ->seePageIs('admin/menu/samples/new/create')
        ->type('test1', 'name')
        ->type('test2','description')
        ->type('test2','introduction')
        ->select(1, 'scenario_id')
        ->type('test','slug')
        ->press('Add')
        ->seePageIs('admin/menu/samples')
        ->delete('admin/menu/samples/'. \App\Sample::whereSlug('test')->first()->id )
        ->visit('admin/menu/samples')
        ->dontSee('test1');

it creates the Sample element fine, but as I have several Delete buttons ( for every Sample element in index, as they are in a list) I can't use the method click/press('Delete'). So I thought I'd just use the delete method, which I have already set up. The problem is that it will not delete the element that I have created. The delete request will not work. I assure you that the route is there and the if I just press the Delete button my Sample element will be deleted.

Why can't I mimic this with PHPUnit, is there another way to delete?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire