-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventDateTest.php
46 lines (35 loc) · 1.19 KB
/
EventDateTest.php
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
<?php
namespace Tests\Feature;
use App\Jobs\NotifyRegistrants;
use App\Models\Event;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class EventDateTest extends TestCase
{
use RefreshDatabase;
public function test_it_notifies_users_when_date_changes()
{
/** @var Event $event */
$event = Event::factory()->create([
'date' => now()->subDay(),
]);
Queue::fake();
$event->date = now();
$event->save();
Queue::assertPushed(NotifyRegistrants::class);
}
public function test_it_doesnt_notify_users_if_date_doesnt_change()
{
/** @var Event $event */
$event = Event::factory()->create([
'date' => now()->subDay(),
]);
Queue::fake();
$event->date = new Carbon($event->date); // Fails because $event->date is a now different Carbon instance from the original and HasAttributes currently checks strict equality between new and old custom date attributes.
$event->save();
Queue::assertNotPushed(NotifyRegistrants::class);
}
}