63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Models\AdCampaign;
|
||
|
|
use App\Models\AdCampaignBanner;
|
||
|
|
use App\Models\Tenant;
|
||
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
|
||
|
|
uses(DatabaseTransactions::class);
|
||
|
|
|
||
|
|
it('stores yandex creative id, ad id and moderation state on a banner', function () {
|
||
|
|
$tenant = Tenant::factory()->create();
|
||
|
|
$campaign = AdCampaign::create([
|
||
|
|
'tenant_id' => $tenant->id,
|
||
|
|
'name' => 'C',
|
||
|
|
'mode' => AdCampaign::MODE_MANUAL,
|
||
|
|
'audience_days' => 10,
|
||
|
|
'client_cpm_rub' => '120.00',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$banner = AdCampaignBanner::create([
|
||
|
|
'tenant_id' => $tenant->id,
|
||
|
|
'campaign_id' => $campaign->id,
|
||
|
|
'width' => 300,
|
||
|
|
'height' => 250,
|
||
|
|
'path' => 'ad-banners/x/300x250.jpg',
|
||
|
|
'bytes' => 1000,
|
||
|
|
'yandex_creative_id' => 1163586673,
|
||
|
|
'yandex_ad_id' => 17786692536,
|
||
|
|
'moderation_status' => AdCampaignBanner::MOD_ACCEPTED,
|
||
|
|
'moderation_reason' => null,
|
||
|
|
]);
|
||
|
|
|
||
|
|
$fresh = $banner->fresh();
|
||
|
|
expect($fresh->yandex_creative_id)->toBe(1163586673)
|
||
|
|
->and($fresh->yandex_ad_id)->toBe(17786692536)
|
||
|
|
->and($fresh->moderation_status)->toBe('ACCEPTED');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('defaults moderation status to draft', function () {
|
||
|
|
$tenant = Tenant::factory()->create();
|
||
|
|
$campaign = AdCampaign::create([
|
||
|
|
'tenant_id' => $tenant->id,
|
||
|
|
'name' => 'C',
|
||
|
|
'mode' => AdCampaign::MODE_MANUAL,
|
||
|
|
'audience_days' => 10,
|
||
|
|
'client_cpm_rub' => '120.00',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$banner = AdCampaignBanner::create([
|
||
|
|
'tenant_id' => $tenant->id,
|
||
|
|
'campaign_id' => $campaign->id,
|
||
|
|
'width' => 728,
|
||
|
|
'height' => 90,
|
||
|
|
'path' => 'ad-banners/x/728x90.jpg',
|
||
|
|
'bytes' => 1000,
|
||
|
|
]);
|
||
|
|
|
||
|
|
expect($banner->fresh()->moderation_status)->toBe('draft')
|
||
|
|
->and($banner->fresh()->yandex_creative_id)->toBeNull();
|
||
|
|
});
|