webCronToken(); $this->assertSame(40, strlen($token)); $this->get('/cron/falsch')->assertNotFound(); $this->get("/cron/{$token}")->assertNoContent(); $this->assertArrayHasKey('webcron', app(BackgroundTasks::class)->heartbeats()); } public function test_pseudo_cron_only_steps_in_without_external_cron(): void { $tasks = app(BackgroundTasks::class); $this->assertTrue($tasks->pseudoCronDue()); $tasks->heartbeat('cron'); $this->assertFalse($tasks->pseudoCronDue()); $this->travel(BackgroundTasks::PSEUDO_CRON_AFTER_SECONDS + 5)->seconds(); $this->assertTrue($tasks->pseudoCronDue()); $tasks->heartbeat('pseudo'); $this->assertFalse($tasks->pseudoCronDue(), 'Höchstens einmal pro Minute.'); } public function test_pseudo_cron_never_runs_during_saving_or_background_requests(): void { $this->assertTrue(RunPseudoCron::suitable(Request::create('/'))); $this->assertFalse(RunPseudoCron::suitable(Request::create('/livewire/update', 'POST'))); $this->assertFalse(RunPseudoCron::suitable(Request::create('/admin/menue', 'GET', server: ['HTTP_X_LIVEWIRE' => '1']))); $this->assertFalse(RunPseudoCron::suitable(Request::create('/neuigkeiten', 'GET', server: ['HTTP_X_INERTIA' => 'true']))); } public function test_queue_is_worked_in_process_not_via_an_external_php_binary(): void { $event = collect(app(Schedule::class)->events())->first(fn ($e) => $e->description === 'queue'); $this->assertInstanceOf(CallbackEvent::class, $event); } }