64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\Tenant;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
it('creates ad_campaign_ads and ad_campaign_phones rows scoped to tenant and campaign', function () {
|
|
$tenant = Tenant::factory()->create();
|
|
|
|
$campaignId = DB::table('ad_campaigns')->insertGetId([
|
|
'tenant_id' => $tenant->id,
|
|
'channel' => 'yandex',
|
|
'name' => 'Кампания №1',
|
|
'status' => 'draft',
|
|
'audience_days' => 10,
|
|
'use_uploaded_list' => false,
|
|
'weekly_budget_rub' => '2500.00',
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('ad_campaign_ads')->insert([
|
|
'tenant_id' => $tenant->id,
|
|
'campaign_id' => $campaignId,
|
|
'title' => 'Заголовок объявления',
|
|
'title2' => 'Второй заголовок',
|
|
'text' => 'Текст объявления с описанием услуги',
|
|
'href' => 'https://liderra.ru/promo',
|
|
'image_normal_hash' => null,
|
|
'image_wide_hash' => null,
|
|
'yandex_ad_id' => null,
|
|
'moderation_status' => 'draft',
|
|
'moderation_reason' => null,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
DB::table('ad_campaign_phones')->insert([
|
|
'tenant_id' => $tenant->id,
|
|
'campaign_id' => $campaignId,
|
|
'phone' => '79990000001',
|
|
'expires_at' => null,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
|
|
expect(DB::table('ad_campaign_ads')->where('campaign_id', $campaignId)->count())->toBe(1)
|
|
->and(DB::table('ad_campaign_phones')->where('campaign_id', $campaignId)->count())->toBe(1);
|
|
|
|
$ad = DB::table('ad_campaign_ads')->where('campaign_id', $campaignId)->first();
|
|
expect($ad->tenant_id)->toBe($tenant->id)
|
|
->and($ad->title)->toBe('Заголовок объявления')
|
|
->and($ad->title2)->toBe('Второй заголовок')
|
|
->and($ad->text)->toBe('Текст объявления с описанием услуги')
|
|
->and($ad->href)->toBe('https://liderra.ru/promo')
|
|
->and($ad->moderation_status)->toBe('draft');
|
|
|
|
$phone = DB::table('ad_campaign_phones')->where('campaign_id', $campaignId)->first();
|
|
expect($phone->tenant_id)->toBe($tenant->id)
|
|
->and($phone->phone)->toBe('79990000001')
|
|
->and($phone->expires_at)->toBeNull();
|
|
});
|