Skip to content

Commit 2a4cd6c

Browse files
committed
Update test for duration info changes
1 parent d443270 commit 2a4cd6c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/Unit/NotificationTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace IvInteractive\Rotation\Tests\Unit;
44

5+
use Carbon\CarbonImmutable;
56
use Illuminate\Foundation\Testing\DatabaseMigrations;
67
use IvInteractive\Rotation\Notifications\ReencryptionFinishedNotification;
78
use IvInteractive\Rotation\Tests\Resources\User;
@@ -10,28 +11,39 @@ class NotificationTest extends \IvInteractive\Rotation\Tests\TestCase
1011
{
1112
use DatabaseMigrations;
1213

13-
public const CREATED_AT = '2020-01-01 00:00:00';
14-
public const FINISHED_AT = '2020-01-01 01:23:45';
14+
private CarbonImmutable $createdAt;
15+
private CarbonImmutable $finishedAt;
1516

1617
public function setUp(): void
1718
{
1819
parent::setUp();
1920
$this->user = User::factory()->create();
21+
22+
$this->createdAt = new CarbonImmutable('2020-01-01 00:00:00');
23+
$this->finishedAt = new CarbonImmutable('2020-01-01 01:23:45');
2024
}
2125

2226
public function testNotificationMailSubject()
2327
{
24-
$notification = new ReencryptionFinishedNotification(['createdAt'=>static::CREATED_AT, 'finishedAt'=>static::FINISHED_AT]);
28+
$notification = new ReencryptionFinishedNotification(['createdAt'=>$this->createdAt, 'finishedAt'=>$this->finishedAt]);
2529
$mail = $notification->toMail($this->user);
2630

2731
$this->assertSame(trans('rotation::notification.subject'), $mail->subject);
2832
}
2933

3034
public function testNotificationMailDuration()
3135
{
32-
$notification = new ReencryptionFinishedNotification(['createdAt'=>static::CREATED_AT, 'finishedAt'=>static::FINISHED_AT]);
36+
$notification = new ReencryptionFinishedNotification(['createdAt'=>$this->createdAt, 'finishedAt'=>$this->finishedAt]);
3337
$mail = $notification->toMail($this->user);
3438

3539
$this->assertStringContainsString('1 hour, 23 minutes and 45 seconds', $mail->introLines[0]);
3640
}
41+
42+
public function testNotificationMailNoDuration()
43+
{
44+
$notification = new ReencryptionFinishedNotification(['createdAt'=>$this->createdAt, 'finishedAt'=>null]);
45+
$mail = $notification->toMail($this->user);
46+
47+
$this->assertStringContainsString(trans('rotation::notification.body-no-duration'), $mail->introLines[0]);
48+
}
3749
}

0 commit comments

Comments
 (0)