create(); $this->assertTrue($deliveryLog->notificationAction()->exists()); $this->assertTrue($deliveryLog->notificationAction->is($deliveryLog->fresh()->notificationAction)); $this->assertSame(NotificationChannel::Webhook, $deliveryLog->fresh()->channel); $this->assertSame(NotificationDeliveryStatus::Pending, $deliveryLog->fresh()->delivery_status); } /** * Ensure delivery logs can represent every supported delivery state. */ public function test_delivery_logs_support_pending_succeeded_failed_and_retryable_statuses(): void { NotificationDeliveryLog::factory()->pending()->create(); NotificationDeliveryLog::factory()->succeeded()->create(); NotificationDeliveryLog::factory()->failed()->create(); NotificationDeliveryLog::factory()->retryable()->create(); $this->assertSame( [ NotificationDeliveryStatus::Pending, NotificationDeliveryStatus::Succeeded, NotificationDeliveryStatus::Failed, NotificationDeliveryStatus::Retryable, ], NotificationDeliveryLog::query()->orderBy('id')->get()->pluck('delivery_status')->all(), ); } /** * Ensure delivery logs cast metadata and attempt information for later delivery tracking. */ public function test_delivery_logs_cast_metadata_and_attempt_information(): void { $deliveryLog = NotificationDeliveryLog::factory()->succeeded()->create([ 'payload_metadata' => [ 'project_key' => 'CORE', 'ticket_key' => 'CORE-27', ], ])->fresh(); $this->assertSame('CORE-27', $deliveryLog->payload_metadata['ticket_key']); $this->assertSame(204, $deliveryLog->http_status); $this->assertNotNull($deliveryLog->last_attempted_at); $this->assertNotNull($deliveryLog->delivered_at); } }