Skip to content

Commit

Permalink
Fix Style
Browse files Browse the repository at this point in the history
  • Loading branch information
Riley Aven committed Aug 1, 2024
1 parent 8e120f9 commit bdf9332
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/Notifications/CheckFailedNotificationTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php

use Illuminate\Support\Facades\Notification;
use Spatie\Health\Checks\Check;
use Spatie\Health\Checks\Result;
use Spatie\Health\Commands\RunHealthChecksCommand;
use Spatie\Health\Enums\Status;
use Spatie\Health\Facades\Health;
use Spatie\Health\Notifications\CheckFailedNotification;
use Spatie\Health\Notifications\Notifiable;
Expand All @@ -13,27 +10,27 @@

use function Pest\Laravel\artisan;

beforeEach(function() {
beforeEach(function () {
Notification::fake();
});

it('will not send a notification when none of the checks have a message', function() {
it('will not send a notification when none of the checks have a message', function () {
registerPassingCheck();

artisan(RunHealthChecksCommand::class)->assertSuccessful();

Notification::assertNothingSent();
});

it('will send a notification when one of the checks has a message', function() {
it('will send a notification when one of the checks has a message', function () {
registerFailingCheck();

artisan(RunHealthChecksCommand::class)->assertSuccessful();

Notification::assertSentTimes(CheckFailedNotification::class, 1);
});

it('will not send any notifications if the config option is set to false', function() {
it('will not send any notifications if the config option is set to false', function () {
config()->set('health.notifications.enabled', false);

registerFailingCheck();
Expand All @@ -43,7 +40,7 @@
Notification::assertSentTimes(CheckFailedNotification::class, 0);
});

it('will only send one failed notification per hour', function() {
it('will only send one failed notification per hour', function () {
TestTime::freeze();
registerFailingCheck();

Expand All @@ -59,7 +56,7 @@
Notification::assertSentTimes(CheckFailedNotification::class, 2);
});

it('can configure the throttle notifications key', function() {
it('can configure the throttle notifications key', function () {
TestTime::freeze();
registerFailingCheck();

Expand All @@ -75,17 +72,17 @@
Notification::assertSentTimes(CheckFailedNotification::class, 2);
});

test('the notification can be rendered to mail', function() {
test('the notification can be rendered to mail', function () {
$notification = (new CheckFailedNotification([]));
$notification->shouldSend(new Notifiable(), 'mail');
$mailable = $notification->toMail();

$html = (string)$mailable->render();
$html = (string) $mailable->render();

expect($html)->toBeString();
});

it('can disable warning notifications', function() {
it('can disable warning notifications', function () {
TestTime::freeze();
Health::checks([
$check = FakeUsedDiskSpaceCheck::new()
Expand All @@ -104,7 +101,7 @@
Notification::assertSentTimes(CheckFailedNotification::class, 1);
});

it('can disable failure notifications', function() {
it('can disable failure notifications', function () {
TestTime::freeze();
Health::checks([
$check = FakeUsedDiskSpaceCheck::new()
Expand All @@ -123,7 +120,7 @@
Notification::assertSentTimes(CheckFailedNotification::class, 1);
});

it('can change warning throttle time', function() {
it('can change warning throttle time', function () {
TestTime::freeze();
Health::checks([
$check = FakeUsedDiskSpaceCheck::new()
Expand All @@ -150,7 +147,7 @@
Notification::assertSentTimes(CheckFailedNotification::class, 3);
});

it('can change failure throttle time', function() {
it('can change failure throttle time', function () {
TestTime::freeze();
Health::checks([
$check = FakeUsedDiskSpaceCheck::new()
Expand All @@ -177,13 +174,14 @@
Notification::assertSentTimes(CheckFailedNotification::class, 3);
});

it('can dispatch notifications for crashed check', function() {
it('can dispatch notifications for crashed check', function () {
TestTime::freeze();
Health::checks([
new class extends Check {
new class extends Check
{
public function run(): Result
{
return new Result(Status::crashed(),'Check Crashed', 'Check Crashed');
return new Result(Status::crashed(), 'Check Crashed', 'Check Crashed');
}
},
]);
Expand Down

0 comments on commit bdf9332

Please sign in to comment.