From 093e13c1ffa9ce7b7b51092a2d32302c24d3afe6 Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Sat, 11 Jan 2025 22:59:51 +0100 Subject: [PATCH 1/3] Fix tests --- tests/TaskHandlerTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/TaskHandlerTest.php b/tests/TaskHandlerTest.php index 988c498..f90c6ef 100644 --- a/tests/TaskHandlerTest.php +++ b/tests/TaskHandlerTest.php @@ -3,6 +3,7 @@ namespace Tests; use Illuminate\Console\Application as ConsoleApplication; +use Illuminate\Console\Scheduling\Event as SchedulingEvent; use Illuminate\Support\Facades\Event; use PHPUnit\Framework\Attributes\Test; use Stackkit\LaravelGoogleCloudScheduler\OpenIdVerificator; @@ -64,7 +65,7 @@ public function it_prevents_overlapping_if_the_command_is_scheduled_without_over $expression = '* * * * *'; $command = ConsoleApplication::formatCommandString('test:command'); - $mutex = 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($expression.$command); + $mutex = 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($expression. SchedulingEvent::normalizeCommand($command)); cache()->add($mutex, true, 60); From bbb293492a2f9e3a783005229d5e2343488ee092 Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Sat, 11 Jan 2025 23:12:59 +0100 Subject: [PATCH 2/3] Use mutexName method --- tests/TaskHandlerTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/TaskHandlerTest.php b/tests/TaskHandlerTest.php index f90c6ef..2607d82 100644 --- a/tests/TaskHandlerTest.php +++ b/tests/TaskHandlerTest.php @@ -5,6 +5,7 @@ use Illuminate\Console\Application as ConsoleApplication; use Illuminate\Console\Scheduling\Event as SchedulingEvent; use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Schedule; use PHPUnit\Framework\Attributes\Test; use Stackkit\LaravelGoogleCloudScheduler\OpenIdVerificator; @@ -63,9 +64,7 @@ public function it_prevents_overlapping_if_the_command_is_scheduled_without_over $this->assertLoggedLines(1); $this->assertLogged('TestCommand'); - $expression = '* * * * *'; - $command = ConsoleApplication::formatCommandString('test:command'); - $mutex = 'framework'.DIRECTORY_SEPARATOR.'schedule-'.sha1($expression. SchedulingEvent::normalizeCommand($command)); + $mutex = head(Schedule::events())->mutexName(); cache()->add($mutex, true, 60); From e0b4305f099d7cf16976a3d22541d7765d3fdce2 Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Sat, 11 Jan 2025 23:18:21 +0100 Subject: [PATCH 3/3] Laravel 10 fallback --- tests/TaskHandlerTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/TaskHandlerTest.php b/tests/TaskHandlerTest.php index 2607d82..cb058fa 100644 --- a/tests/TaskHandlerTest.php +++ b/tests/TaskHandlerTest.php @@ -2,10 +2,8 @@ namespace Tests; -use Illuminate\Console\Application as ConsoleApplication; -use Illuminate\Console\Scheduling\Event as SchedulingEvent; +use Illuminate\Console\Scheduling\Schedule; use Illuminate\Support\Facades\Event; -use Illuminate\Support\Facades\Schedule; use PHPUnit\Framework\Attributes\Test; use Stackkit\LaravelGoogleCloudScheduler\OpenIdVerificator; @@ -64,7 +62,7 @@ public function it_prevents_overlapping_if_the_command_is_scheduled_without_over $this->assertLoggedLines(1); $this->assertLogged('TestCommand'); - $mutex = head(Schedule::events())->mutexName(); + $mutex = head(app(Schedule::class)->events())->mutexName(); cache()->add($mutex, true, 60);