From f7dab2fc99b5d195d3bdad724c84ac34e2e2ffa4 Mon Sep 17 00:00:00 2001 From: Roman Zipp Date: Fri, 12 May 2023 19:10:27 +0200 Subject: [PATCH] Fix tests --- src/Controllers/RetryMonitorController.php | 3 ++- tests/RoutesTest.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controllers/RetryMonitorController.php b/src/Controllers/RetryMonitorController.php index 778b221b..c5013979 100644 --- a/src/Controllers/RetryMonitorController.php +++ b/src/Controllers/RetryMonitorController.php @@ -2,6 +2,7 @@ namespace romanzipp\QueueMonitor\Controllers; +use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Artisan; @@ -17,7 +18,7 @@ public function __invoke(Request $request, int $monitorId): RedirectResponse ->where('status', MonitorStatus::FAILED) ->where('retried', false) ->whereNotNull('job_uuid') - ->findOrFail($monitorId); + ->find($monitorId) ?? throw new ModelNotFoundException(); if (is_a($monitor, Monitor::class)) { $monitor->retried = true; diff --git a/tests/RoutesTest.php b/tests/RoutesTest.php index 1981eebb..845ce063 100644 --- a/tests/RoutesTest.php +++ b/tests/RoutesTest.php @@ -148,6 +148,7 @@ public function testRetryDisabledUi() /** @var \romanzipp\QueueMonitor\Models\Monitor $monitor */ $monitor = Monitor::query()->create([ 'job_id' => mt_rand(), + 'job_uuid' => '048f02b7-0dc2-4f9c-9baa-7852273876cc', ]); $this @@ -165,6 +166,7 @@ public function testRetryDisabledRetrying() /** @var \romanzipp\QueueMonitor\Models\Monitor $monitor */ $monitor = Monitor::query()->create([ 'job_id' => mt_rand(), + 'job_uuid' => '048f02b7-0dc2-4f9c-9baa-7852273876cc', ]); $this @@ -182,6 +184,7 @@ public function testRetryEnabled() /** @var \romanzipp\QueueMonitor\Models\Monitor $monitor */ $monitor = Monitor::query()->create([ 'job_id' => mt_rand(), + 'job_uuid' => '048f02b7-0dc2-4f9c-9baa-7852273876cc', 'status' => MonitorStatus::FAILED, 'retried' => false, ]);