23 lines
795 B
PHP
23 lines
795 B
PHP
|
|
<?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,
|
||
|
|
'use_uploaded_list' => false, 'weekly_budget_rub' => '2500.00',
|
||
|
|
]);
|
||
|
|
AdCampaignAd::create([
|
||
|
|
'tenant_id' => $tenant->id, 'campaign_id' => $c->id,
|
||
|
|
'title' => 'Заголовок', 'text' => 'Текст', 'href' => 'https://example.com',
|
||
|
|
]);
|
||
|
|
expect($c->status)->toBe(AdCampaign::STATUS_DRAFT)
|
||
|
|
->and($c->ads()->count())->toBe(1)
|
||
|
|
->and($c->weekly_budget_rub)->toBe('2500.00');
|
||
|
|
});
|