1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
namespace Tests\Unit;
use App\Models\Appointment;
use App\Models\Company;
use App\Models\Student;
use App\Services\AppointmentService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AppointmentServiceTest extends TestCase
{
use RefreshDatabase;
protected AppointmentService $service;
public function test_overlap_returns_true_when_overlap_exists()
{
Appointment::factory()->create([
'student_id' => $this->student->id,
'company_id' => $this->company->id,
'time_start' => '10:00',
'time_end' => '11:00',
]);
$data = [
'student_id' => $this->student->id,
'company_id' => $this->company->id,
'time_start' => '10:30',
'time_end' => '11:30',
];
$this->assertTrue($this->service->appointmentTimeOverlap($data));
}
public function test_overlap_returns_false_when_no_overlap()
{
Appointment::factory()->create([
'student_id' => $this->student->id,
'company_id' => $this->company->id,
'time_start' => '10:00',
'time_end' => '11:00',
]);
$data = [
'student_id' => $this->student->id,
'company_id' => $this->company->id,
'time_start' => '11:30',
'time_end' => '12:30',
];
$this->assertFalse($this->service->appointmentTimeOverlap($data));
}
protected function setUp(): void
{
parent::setUp();
$this->service = new AppointmentService();
$this->student = Student::factory()->create();
$this->company = Company::factory()->create();
}
}
|