2026-07-24 22:46:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Models\AdCampaign;
|
|
|
|
|
use App\Models\AdCampaignAd;
|
|
|
|
|
use App\Models\Tenant;
|
|
|
|
|
|
|
|
|
|
it('creates a campaign with ads relation and status constants', function () {
|
|
|
|
|
$tenant = Tenant::factory()->create();
|
|
|
|
|
$c = AdCampaign::create([
|
|
|
|
|
'tenant_id' => $tenant->id, 'name' => 'Свежие клиенты', 'audience_days' => 10,
|
2026-07-27 08:48:08 +03:00
|
|
|
'use_uploaded_list' => false,
|
2026-07-24 22:46:03 +03:00
|
|
|
]);
|
|
|
|
|
AdCampaignAd::create([
|
|
|
|
|
'tenant_id' => $tenant->id, 'campaign_id' => $c->id,
|
|
|
|
|
'title' => 'Заголовок', 'text' => 'Текст', 'href' => 'https://example.com',
|
|
|
|
|
]);
|
|
|
|
|
expect($c->status)->toBe(AdCampaign::STATUS_DRAFT)
|
2026-07-27 08:48:08 +03:00
|
|
|
->and($c->ads()->count())->toBe(1);
|
2026-07-24 22:46:03 +03:00
|
|
|
});
|