verbesserung von benachrichtungen und warnungen an nutzer abgeschlossen. layout editor nun auf gutem stand.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Packages;
|
||||
|
||||
use App\Jobs\Packages\SendTenantCreditsLowNotification;
|
||||
use App\Models\Tenant;
|
||||
use App\Notifications\Packages\TenantCreditsLowNotification;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SendTenantCreditsLowNotificationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_logs_successful_notification(): void
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create([
|
||||
'contact_email' => 'admin@example.com',
|
||||
]);
|
||||
|
||||
$job = new SendTenantCreditsLowNotification($tenant->id, balance: 5, threshold: 10);
|
||||
$job->handle();
|
||||
|
||||
Notification::assertSentOnDemand(TenantCreditsLowNotification::class, function ($notification, $channels, $notifiable) {
|
||||
return in_array('mail', $channels, true) && ($notifiable->routes['mail'] ?? null) === 'admin@example.com';
|
||||
});
|
||||
|
||||
$tenant->refresh();
|
||||
|
||||
$this->assertCount(1, $tenant->notificationLogs);
|
||||
$log = $tenant->notificationLogs()->first();
|
||||
$this->assertSame('credits_low', $log->type);
|
||||
$this->assertSame('sent', $log->status);
|
||||
$this->assertSame('admin@example.com', $log->recipient);
|
||||
$this->assertNotNull($log->sent_at);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user