49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Plan;
|
|
use App\Models\PlatformLead;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class FrontPlatformLeadSubmitTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_platform_can_submit_lead_and_redirect_back_to_plans(): void
|
|
{
|
|
$this->seed();
|
|
|
|
$plan = Plan::query()->create([
|
|
'code' => 'front_lead_plan_01',
|
|
'name' => '线索提交测试套餐',
|
|
'billing_cycle' => 'monthly',
|
|
'price' => 99,
|
|
'list_price' => 99,
|
|
'status' => 'active',
|
|
'sort' => 10,
|
|
'published_at' => now(),
|
|
]);
|
|
|
|
$res = $this->post('/platform/leads', [
|
|
'name' => '张三',
|
|
'mobile' => '13800000000',
|
|
'company' => '测试公司',
|
|
'plan_id' => $plan->id,
|
|
'source' => 'platform_plans',
|
|
]);
|
|
|
|
$res->assertRedirect('/platform/plans');
|
|
|
|
$lead = PlatformLead::query()->latest('id')->first();
|
|
$this->assertNotNull($lead);
|
|
$this->assertSame('张三', $lead->name);
|
|
$this->assertSame('13800000000', $lead->mobile);
|
|
$this->assertSame('测试公司', $lead->company);
|
|
$this->assertSame($plan->id, $lead->plan_id);
|
|
$this->assertSame('platform_plans', $lead->source);
|
|
$this->assertSame('new', $lead->status);
|
|
}
|
|
}
|