Add guest policy settings
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\GuestNotification;
|
||||
use App\Models\GuestPolicySetting;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class GuestNotificationBroadcastTest extends TenantTestCase
|
||||
@@ -49,6 +51,38 @@ class GuestNotificationBroadcastTest extends TenantTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_guest_notification_default_ttl_applies(): void
|
||||
{
|
||||
$now = now();
|
||||
Carbon::setTestNow($now);
|
||||
|
||||
GuestPolicySetting::flushCache();
|
||||
GuestPolicySetting::query()->create([
|
||||
'id' => 1,
|
||||
'guest_notification_ttl_hours' => 6,
|
||||
]);
|
||||
|
||||
$event = Event::factory()->for($this->tenant)->create();
|
||||
|
||||
$payload = [
|
||||
'title' => 'Upload-Reminder',
|
||||
'message' => 'Bitte lade deine letzten Fotos hoch.',
|
||||
'type' => 'broadcast',
|
||||
];
|
||||
|
||||
$response = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/guest-notifications", $payload);
|
||||
|
||||
$response->assertCreated();
|
||||
|
||||
$notification = GuestNotification::query()->where('event_id', $event->id)->first();
|
||||
|
||||
$this->assertNotNull($notification);
|
||||
$this->assertNotNull($notification->expires_at);
|
||||
$this->assertEquals($now->copy()->addHours(6)->toDateTimeString(), $notification->expires_at?->toDateTimeString());
|
||||
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
|
||||
public function test_admin_cannot_access_foreign_event(): void
|
||||
{
|
||||
$otherTenantEvent = Event::factory()->create([
|
||||
|
||||
Reference in New Issue
Block a user