Skip to content

Commit 5130c11

Browse files
committed
Fix tests
1 parent 8eb6e8a commit 5130c11

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/Feature/Client/ScheduleAppointmentTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use App\Models\Client;
44
use App\TimeOfDay;
55
use Database\Factories\AnimalFactory;
6+
use Tests\TestCase;
67

78
$VALID_APPOINTMENT = [
89
'client' => [
@@ -22,6 +23,16 @@
2223
],
2324
];
2425

26+
function scheduleAppointment(TestCase $self, array $data): void
27+
{
28+
// Try to schedule an appointment
29+
$response = $self
30+
->post(route('public.schedule-appointment'), $data);
31+
32+
// Check for redirect. Since we're using Inertia, it redirects the user to the homepage on success
33+
$response->assertRedirect(route('public.home'));
34+
}
35+
2536
test('can not empty schedule appointment', function () {
2637
$response = $this
2738
->post(route('public.schedule-appointment'));
@@ -41,7 +52,7 @@
4152
->post(route('public.schedule-appointment'), $data);
4253

4354
// Check for redirect. Since we're using Inertia, it redirects the user to the homepage on success
44-
$response->assertRedirect(route('public.schedule-appointment'));
55+
$response->assertRedirect(route('public.home'));
4556

4657
// Check if data was saved
4758
$this->assertDatabaseHas('clients', $data['client']);
@@ -67,12 +78,7 @@
6778
// Ensure it exists
6879
$this->assertDatabaseHas('clients', $clientData);
6980

70-
// Try to schedule an appointment
71-
$response = $this
72-
->post(route('public.schedule-appointment'), $data);
73-
74-
// Check for redirect. Since we're using Inertia, it redirects the user to the homepage on success
75-
$response->assertRedirect(route('public.schedule-appointment'));
81+
scheduleAppointment($this, $data);
7682

7783
// Check if the client was updated
7884
$this->assertDatabaseHas('clients', $data['client']);
@@ -88,7 +94,7 @@
8894
->post(route('public.schedule-appointment'), $data);
8995

9096
// Check for redirect. Since we're using Inertia, it redirects the user to the homepage on success
91-
$response->assertRedirect(route('public.schedule-appointment'));
97+
$response->assertRedirect(route('public.home'));
9298
}
9399

94100
// Check if the client was updated

0 commit comments

Comments
 (0)