create([]); $this->assertDatabaseHas('tasks', [ 'id' => $task->id, ]); $request = [ 'account_id' => $task->account->id, 'task_id' => $task->id, ]; app(DestroyTask::class)->execute($request); $this->assertDatabaseMissing('tasks', [ 'id' => $task->id, ]); } public function test_it_fails_if_wrong_parameters_are_given() { $request = [ 'task_id' => 2, ]; $this->expectException(ValidationException::class); app(DestroyTask::class)->execute($request); } public function test_it_throws_a_task_doesnt_exist() { $task = factory(Task::class)->create([]); $account = factory(Account::class)->create([]); $request = [ 'account_id' => $account->id, 'task_id' => $task->id, ]; $this->expectException(ModelNotFoundException::class); app(DestroyTask::class)->execute($request); } }