Files
portal/app/tests/Feature/Sales/SalesProspectModelTest.php
T
Дмитрий 4b7463d1d9 feat(sales): модель SalesProspect + фабрика
Этап 1 Task 2. Дефолт stage=new в $attributes (доступен до refresh).
ide-helper мисин добавлен в локальный стаб (регенерация всех моделей).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 16:24:53 +03:00

31 lines
1022 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use App\Models\SalesProspect;
use App\Models\SalesUser;
use Illuminate\Foundation\Testing\DatabaseTransactions;
uses(DatabaseTransactions::class);
test('SalesProspect создаётся, payload кастуется в массив, дефолт stage=new', function () {
$head = SalesUser::create([
'name' => 'Н '.uniqid(), 'email' => 'ph'.uniqid().'@s.local',
'password' => bcrypt('x'), 'role' => 'head', 'is_active' => true,
]);
$p = SalesProspect::create([
'sales_user_id' => $head->id,
'firm_name' => 'ООО Ромашка',
'city' => 'Ростов-на-Дону',
'phone' => '+78001234567',
'inn' => '6161000000',
'payload' => ['director' => 'Иванов И.И.', 'direct_budget_max' => 200000],
]);
expect($p->stage)->toBe('new')
->and($p->payload)->toBeArray()
->and($p->payload['director'])->toBe('Иванов И.И.')
->and($p->salesUser->id)->toBe($head->id);
});