From b10264d6ef847dfad3734219ef44e23c92eb02f3 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 4 Feb 2024 00:12:18 +0100 Subject: [PATCH] Fix random shifts test --- src/Controllers/ShiftsController.php | 3 ++- tests/Unit/Controllers/ShiftsControllerTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controllers/ShiftsController.php b/src/Controllers/ShiftsController.php index 240c039a..8a2f01eb 100644 --- a/src/Controllers/ShiftsController.php +++ b/src/Controllers/ShiftsController.php @@ -50,8 +50,9 @@ class ShiftsController extends BaseController ->collect() // Prefer soon starting shifts ->groupBy('start') + // Get first starting shifts ->first() - // Select one at random + // Select one of them at random ->random(); return $this->redirect->to($this->url->to('/shifts', ['action' => 'view', 'shift_id' => $randomShift->id])); diff --git a/tests/Unit/Controllers/ShiftsControllerTest.php b/tests/Unit/Controllers/ShiftsControllerTest.php index 336f9888..c0dcf9e4 100644 --- a/tests/Unit/Controllers/ShiftsControllerTest.php +++ b/tests/Unit/Controllers/ShiftsControllerTest.php @@ -57,7 +57,7 @@ class ShiftsControllerTest extends ControllerTest $otherUser = User::factory()->create(); [$userAngelType, $otherAngelType] = AngelType::factory(2)->create(); [$possibleShift1, $possibleShift2, $otherAngelTypeShift, $alreadySubscribedShift] = Shift::factory(4) - ->create(['start' => $start]); + ->create(['start' => $start, 'end' => $start->addHours(2)]); $this->user->userAngelTypes()->attach($userAngelType, ['confirm_user_id' => $this->user->id]); NeededAngelType::factory()->create([ 'shift_id' => $possibleShift1->id,