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/AdProductCatalogFeatureTest.php
<?php

use App\Model\AdProductCatalog;
use App\Model\AdProduct;

test('ad product catalog sources are valid', function () {
    expect(AdProductCatalog::SOURCES)->toBe(['manual', 'feed_url', 'shopify', 'woocommerce', 'csv']);
});

test('ad product catalog sync constants are valid', function () {
    expect(AdProductCatalog::SYNC_PENDING)->toBe('pending');
    expect(AdProductCatalog::SYNC_IN_PROGRESS)->toBe('in_progress');
    expect(AdProductCatalog::SYNC_COMPLETED)->toBe('completed');
    expect(AdProductCatalog::SYNC_FAILED)->toBe('failed');
});

test('ad product catalog fillable fields are correct', function () {
    $catalog = new AdProductCatalog();
    expect($catalog->getFillable())->toContain('name', 'source_type', 'source_url', 'customer_id', 'sync_status', 'product_count');
});

test('ad product catalog casts are correct', function () {
    $catalog = new AdProductCatalog();
    $casts = $catalog->getCasts();
    expect($casts)->toHaveKey('last_synced_at');
});

test('ad product catalog sync badge accessor works', function () {
    $catalog = new AdProductCatalog();
    $catalog->sync_status = 'completed';
    expect($catalog->sync_badge)->toBe('green');
    $catalog->sync_status = 'in_progress';
    expect($catalog->sync_badge)->toBe('blue');
    $catalog->sync_status = 'failed';
    expect($catalog->sync_badge)->toBe('red');
});

test('ad product catalog can be created via factory', function () {
    $catalog = AdProductCatalog::factory()->make(['customer_id' => 1]);
    expect($catalog->name)->not->toBeEmpty();
    expect($catalog->source_type)->toBe('manual');
});

test('ad product fillable fields are correct', function () {
    $product = new AdProduct();
    expect($product->getFillable())->toContain('ad_product_catalog_id', 'title', 'price', 'currency', 'image_url', 'availability');
});

test('ad product casts are correct', function () {
    $product = new AdProduct();
    $casts = $product->getCasts();
    expect($casts['price'])->toBe('decimal:2');
    expect($casts['custom'])->toBe('json');
});