219f262655
fake()->unique()->words(3,true) fixes quirk #77 deterministic collision on projects(tenant_id,name) UNIQUE in --parallel runs. test:parallel alias = pest --parallel --recreate-databases (quirk #62/#73). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Project;
|
|
use App\Models\Tenant;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Project>
|
|
*/
|
|
class ProjectFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'tenant_id' => Tenant::factory(),
|
|
'name' => fake()->unique()->words(3, true),
|
|
'type' => 'webhook',
|
|
'is_active' => true,
|
|
'daily_limit_target' => 10,
|
|
'region_mask' => 255,
|
|
'region_mode' => 'include',
|
|
'delivery_days_mask' => 127,
|
|
'assignment_strategy' => 'manual',
|
|
'ttfr_target_minutes' => 15,
|
|
// Supplier integration (Plan 1/5 Task 1+10) — по умолчанию пусто,
|
|
// CHECK constraint'ы projects не нарушаются (signal_type IS NULL → все остальные опциональны).
|
|
'signal_type' => null,
|
|
'signal_identifier' => null,
|
|
'sms_senders' => null,
|
|
'sms_keyword' => null,
|
|
'delivered_in_month' => 0,
|
|
'supplier_b1_project_id' => null,
|
|
'supplier_b2_project_id' => null,
|
|
'supplier_b3_project_id' => null,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Сайт-сигнал с указанным доменом.
|
|
*/
|
|
public function asSiteSignal(string $domain): self
|
|
{
|
|
return $this->state([
|
|
'signal_type' => 'site',
|
|
'signal_identifier' => $domain,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Звонок-сигнал с указанным телефоном.
|
|
*/
|
|
public function asCallSignal(string $phone): self
|
|
{
|
|
return $this->state([
|
|
'signal_type' => 'call',
|
|
'signal_identifier' => $phone,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* SMS-сигнал. Sender-имена в массиве (1+); keyword optional (пусто = только B3).
|
|
*
|
|
* @param array<int, string> $senders
|
|
*/
|
|
public function asSmsSignal(array $senders, ?string $keyword = null): self
|
|
{
|
|
return $this->state([
|
|
'signal_type' => 'sms',
|
|
'signal_identifier' => null,
|
|
'sms_senders' => $senders,
|
|
'sms_keyword' => $keyword,
|
|
]);
|
|
}
|
|
}
|