create(['name' => 'Testing name', 'description' => 'Testing 123']); $singleMstr2 = factory(Master::class)->create(['name' => 'Testing name', 'description' => 'Testing 456']); $this->loginAsUser(); $this->visit(route('masters.index')); $this->see($singleMstr1->name); $this->see($singleMstr2->name); } /** @test */ public function user_can_create_a_master() { $this->loginAsUser(); $this->visit(route('masters.index')); $this->click(trans('master.create')); $this->seePageIs(route('masters.index', ['action' => 'create'])); $this->submitForm(trans('master.create'), [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); $this->seePageIs(route('masters.index')); $this->seeInDatabase('masters', [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); } /** @test */ public function user_can_edit_a_master_within_search_query() { $this->loginAsUser(); $singleMstr = factory(Master::class)->create(['name' => 'Testing 123']); $this->visit(route('masters.index', ['q' => '123'])); $this->click('edit-master-'.$singleMstr->id); $this->seePageIs(route('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123'])); $this->submitForm(trans('master.update'), [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); $this->seePageIs(route('masters.index', ['q' => '123'])); $this->seeInDatabase('masters', [ 'name' => 'Master 1 name', 'description' => 'Master 1 description', ]); } /** @test */ public function user_can_delete_a_master() { $this->loginAsUser(); $singleMstr = factory(Master::class)->create(); $this->visit(route('masters.index', [$singleMstr->id])); $this->click('del-master-'.$singleMstr->id); $this->seePageIs(route('masters.index', ['action' => 'delete', 'id' => $singleMstr->id])); $this->seeInDatabase('masters', [ 'id' => $singleMstr->id, ]); $this->press(trans('app.delete_confirm_button')); $this->dontSeeInDatabase('masters', [ 'id' => $singleMstr->id, ]); } }