35 lines
986 B
PHP
35 lines
986 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Models\AdCampaign;
|
||
|
|
use App\Models\AdCreativeJob;
|
||
|
|
use App\Models\Tenant;
|
||
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
|
||
|
|
uses(DatabaseTransactions::class);
|
||
|
|
|
||
|
|
it('creates a queued creative job for a campaign', 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',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$job = AdCreativeJob::create([
|
||
|
|
'tenant_id' => $tenant->id,
|
||
|
|
'campaign_id' => $campaign->id,
|
||
|
|
'status' => AdCreativeJob::STATUS_QUEUED,
|
||
|
|
'snapshot_before' => [111 => [300, 250]],
|
||
|
|
]);
|
||
|
|
|
||
|
|
$fresh = $job->fresh();
|
||
|
|
expect($fresh->status)->toBe('queued')
|
||
|
|
->and($fresh->attempts)->toBe(0)
|
||
|
|
->and($fresh->snapshot_before)->toBe(['111' => [300, 250]])
|
||
|
|
->and($fresh->failure_reason)->toBeNull();
|
||
|
|
});
|