4b7463d1d9
Этап 1 Task 2. Дефолт stage=new в $attributes (доступен до refresh). ide-helper мисин добавлен в локальный стаб (регенерация всех моделей). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
1022 B
PHP
31 lines
1022 B
PHP
<?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);
|
||
});
|