-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathHomeControllerTest.php
More file actions
55 lines (45 loc) · 1.45 KB
/
HomeControllerTest.php
File metadata and controls
55 lines (45 loc) · 1.45 KB
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
<?php
namespace Tests\Feature\Http\Controllers;
use App\Models\Event;
use Carbon\Carbon;
use Tests\DatabaseTestCase;
class HomeControllerTest extends DatabaseTestCase
{
public function setUp(): void
{
parent::setUp();
Carbon::setTestNow('2020-01-01');
}
public function test_upcoming_events_sorts_unordered_events()
{
Event::factory()->create([
'event_name' => 'Event 2',
'active_at' => '2020-01-01 19:00:00',
'expire_at' => '2020-01-02 21:00:00',
]);
Event::factory()->create([
'event_name' => 'Event 1',
'active_at' => '2020-01-01 18:00:00',
'expire_at' => '2020-01-02 20:00:00',
]);
Event::factory()->create([
'event_name' => 'Event 3',
'active_at' => '2020-01-02 12:00:00',
'expire_at' => '2020-01-02 14:00:00',
]);
$response = $this->get(route('home'));
$response->assertStatus(200);
$response->assertSeeInOrder(['Event 1', 'Event 2', 'Event 3']);
}
public function test_upcoming_events_does_not_show_old_events()
{
Event::factory()->create([
'event_name' => 'Event 1',
'active_at' => '2019-12-31 22:00:00',
'expire_at' => '2019-12-31 23:00:00',
]);
$response = $this->get(route('home'));
$response->assertStatus(200);
$response->assertDontSee('Event 1');
}
}