Files
portal/app/tests/Feature/Sales/SalesProspectModelTest.php
T

31 lines
1022 B
PHP
Raw Normal View History

<?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);
});