From 5a7b528d16145a27bce3a850fe8e470a74bc847e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 03:07:45 +0000 Subject: [PATCH] =?UTF-8?q?refactor(test):=20=E6=8F=90=E5=8F=96=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E8=AF=A6=E6=83=85=E9=A1=B5=E6=B5=8B=E8=AF=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9E=84=E9=80=A0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Feature/AdminSiteSubscriptionShowTest.php | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tests/Feature/AdminSiteSubscriptionShowTest.php b/tests/Feature/AdminSiteSubscriptionShowTest.php index 4d2e631..de7624f 100644 --- a/tests/Feature/AdminSiteSubscriptionShowTest.php +++ b/tests/Feature/AdminSiteSubscriptionShowTest.php @@ -13,20 +13,8 @@ class AdminSiteSubscriptionShowTest extends TestCase { use RefreshDatabase; - protected function loginAsPlatformAdmin(): void + protected function seedSubscriptionForShow(): array { - $this->seed(); - - $this->post('/admin/login', [ - 'email' => 'platform.admin@demo.local', - 'password' => 'Platform@123456', - ])->assertRedirect('/admin'); - } - - public function test_platform_admin_can_open_site_subscription_show_page(): void - { - $this->loginAsPlatformAdmin(); - $merchant = Merchant::query()->firstOrFail(); $plan = Plan::query()->create([ 'code' => 'sub_show_test', @@ -103,6 +91,25 @@ class AdminSiteSubscriptionShowTest extends TestCase ], ]); + return [$merchant, $plan, $sub]; + } + + protected function loginAsPlatformAdmin(): void + { + $this->seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_admin_can_open_site_subscription_show_page(): void + { + $this->loginAsPlatformAdmin(); + + [$merchant, $plan, $sub] = $this->seedSubscriptionForShow(); + $this->get('/admin/site-subscriptions/' . $sub->id) ->assertOk() ->assertSee('订阅详情')