Consolidate helpers into trait
This commit is contained in:
parent
d20844fefa
commit
8978dff054
3 changed files with 30 additions and 36 deletions
|
@ -8,19 +8,19 @@ use App\Models\Asset;
|
|||
use App\Models\Component;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckinAccessoryNotification;
|
||||
use App\Notifications\CheckinAssetNotification;
|
||||
use App\Notifications\CheckinLicenseSeatNotification;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\Support\AssertsAgainstSlackNotifications;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SlackNotificationsUponCheckinTest extends TestCase
|
||||
{
|
||||
use AssertsAgainstSlackNotifications;
|
||||
use InteractsWithSettings;
|
||||
|
||||
protected function setUp(): void
|
||||
|
@ -154,20 +154,4 @@ class SlackNotificationsUponCheckinTest extends TestCase
|
|||
''
|
||||
));
|
||||
}
|
||||
|
||||
private function assertSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertSentTo(
|
||||
new AnonymousNotifiable,
|
||||
$notificationClass,
|
||||
function ($notification, $channels, $notifiable) {
|
||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function assertNoSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,20 +9,20 @@ use App\Models\Component;
|
|||
use App\Models\Consumable;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CheckoutAccessoryNotification;
|
||||
use App\Notifications\CheckoutAssetNotification;
|
||||
use App\Notifications\CheckoutConsumableNotification;
|
||||
use App\Notifications\CheckoutLicenseSeatNotification;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\Support\AssertsAgainstSlackNotifications;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SlackNotificationsUponCheckoutTest extends TestCase
|
||||
{
|
||||
use AssertsAgainstSlackNotifications;
|
||||
use InteractsWithSettings;
|
||||
|
||||
protected function setUp(): void
|
||||
|
@ -170,20 +170,4 @@ class SlackNotificationsUponCheckoutTest extends TestCase
|
|||
'',
|
||||
));
|
||||
}
|
||||
|
||||
private function assertSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertSentTo(
|
||||
new AnonymousNotifiable,
|
||||
$notificationClass,
|
||||
function ($notification, $channels, $notifiable) {
|
||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function assertNoSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass);
|
||||
}
|
||||
}
|
||||
|
|
26
tests/Support/AssertsAgainstSlackNotifications.php
Normal file
26
tests/Support/AssertsAgainstSlackNotifications.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Notifications\AnonymousNotifiable;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
trait AssertsAgainstSlackNotifications
|
||||
{
|
||||
public function assertSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertSentTo(
|
||||
new AnonymousNotifiable,
|
||||
$notificationClass,
|
||||
function ($notification, $channels, $notifiable) {
|
||||
return $notifiable->routes['slack'] === Setting::getSettings()->webhook_endpoint;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function assertNoSlackNotificationSent(string $notificationClass)
|
||||
{
|
||||
Notification::assertNotSentTo(new AnonymousNotifiable, $notificationClass);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue