HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/tests/Feature/AdLeadFormFeatureTest.php
<?php

use App\Model\AdLead;
use App\Model\AdLeadFormConfig;

test('ad lead form status constants are valid', function () {
    expect(AdLeadFormConfig::STATUS_ACTIVE)->toBe('active');
    expect(AdLeadFormConfig::STATUS_PAUSED)->toBe('paused');
    expect(AdLeadFormConfig::STATUS_ERROR)->toBe('error');
});

test('ad lead form fillable fields are correct', function () {
    $config = new AdLeadFormConfig();
    expect($config->getFillable())->toContain('platform', 'form_id', 'mail_list_id', 'customer_id', 'field_mapping', 'status', 'leads_count');
});

test('ad lead form casts are correct', function () {
    $config = new AdLeadFormConfig();
    $casts = $config->getCasts();
    expect($casts['field_mapping'])->toBe('json');
    expect($casts)->toHaveKey('last_synced_at');
});

test('ad lead form status badge accessor works', function () {
    $config = new AdLeadFormConfig();
    $config->status = 'active';
    expect($config->status_badge)->toBe('green');
    $config->status = 'paused';
    expect($config->status_badge)->toBe('orange');
    $config->status = 'error';
    expect($config->status_badge)->toBe('red');
});

test('ad lead form platform label accessor works', function () {
    $config = new AdLeadFormConfig();
    $config->platform = 'meta';
    expect($config->platform_label)->toBe('Meta (Facebook/Instagram)');
});

test('ad lead form can be created via factory', function () {
    $config = AdLeadFormConfig::factory()->make(['customer_id' => 1]);
    expect($config->form_id)->not->toBeEmpty();
    expect($config->status)->toBe('active');
});

test('ad lead fillable fields are correct', function () {
    $lead = new AdLead();
    expect($lead->getFillable())->toContain('ad_lead_form_config_id', 'platform_lead_id', 'data', 'subscriber_id');
});

test('ad lead casts are correct', function () {
    $lead = new AdLead();
    $casts = $lead->getCasts();
    expect($casts['data'])->toBe('json');
    expect($casts)->toHaveKey('synced_at');
});