55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Plan;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class FrontPlatformLeadStoreTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_can_submit_platform_lead_and_persist(): void
|
|
{
|
|
$plan = Plan::query()->create([
|
|
'code' => 'front_lead_plan_01',
|
|
'name' => '线索测试套餐',
|
|
'billing_cycle' => 'monthly',
|
|
'price' => 10,
|
|
'list_price' => 10,
|
|
'status' => 'active',
|
|
'sort' => 10,
|
|
'published_at' => now(),
|
|
]);
|
|
|
|
$res = $this->post('/platform/leads', [
|
|
'name' => '张三',
|
|
'mobile' => '13800000000',
|
|
'plan_id' => $plan->id,
|
|
'source' => 'platform_plans',
|
|
'note' => '想先试用一下',
|
|
]);
|
|
|
|
$res->assertRedirect('/platform/plans');
|
|
|
|
$this->assertDatabaseHas('platform_leads', [
|
|
'name' => '张三',
|
|
'mobile' => '13800000000',
|
|
'plan_id' => $plan->id,
|
|
'source' => 'platform_plans',
|
|
'status' => 'new',
|
|
]);
|
|
}
|
|
|
|
public function test_submit_platform_lead_should_validate_required_name(): void
|
|
{
|
|
$res = $this->post('/platform/leads', [
|
|
'name' => '',
|
|
]);
|
|
|
|
$res->assertStatus(302);
|
|
$res->assertSessionHasErrors(['name']);
|
|
}
|
|
}
|