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/be.naniguide.com/tests/Feature/AdCreativeFeatureTest.php
<?php

use App\Model\AdCreative;

test('ad creative types are valid', function () {
    expect(AdCreative::TYPES)->toBe(['image', 'video', 'carousel', 'html']);
});

test('ad creative type labels exist for all types', function () {
    foreach (AdCreative::TYPES as $type) {
        expect(AdCreative::TYPE_LABELS)->toHaveKey($type);
    }
});

test('ad creative CTA options cover all platforms', function () {
    // These keys must match the dictionary used by all platform exporters
    $expected = ['learn_more', 'shop_now', 'sign_up', 'contact_us', 'download', 'get_quote', 'book_now', 'apply_now'];
    foreach ($expected as $key) {
        expect(AdCreative::CTA_OPTIONS)->toHaveKey($key);
    }
});

test('ad creative fillable includes builder_content', function () {
    $creative = new AdCreative();
    expect($creative->getFillable())->toContain(
        'uid',
        'customer_id',
        'ad_campaign_id',
        'name',
        'type',
        'headline',
        'primary_text',
        'description',
        'call_to_action',
        'destination_url',
        'image_url',
        'builder_content',
    );
});

test('ad creative casts builder_content to array', function () {
    $creative = new AdCreative();
    $casts = $creative->getCasts();
    expect($casts['builder_content'])->toBe('json');
    expect($casts['carousel_cards'])->toBe('json');
    expect($casts['metadata'])->toBe('json');
});

test('ad creative type label accessor works', function () {
    $creative = new AdCreative();
    $creative->type = 'image';
    expect($creative->type_label)->toBe('Image');
    $creative->type = 'carousel';
    expect($creative->type_label)->toBe('Carousel');
});

test('ad creative factory has withBuilderContent state helper', function () {
    // Verify the factory class exposes the helper method — actual behavior
    // is covered by exporter tests that feed realistic JSON directly.
    expect(method_exists(\Database\Factories\AdCreativeFactory::class, 'withBuilderContent'))->toBeTrue();
});