fix: 已解锁后 [paid] 标签裸露——替换为付费内容块

post.rendered 过滤原只在无权限时替换 [paid];有权限时原始标签直接显示在页面。现在:
- 有权限:替换为 <div class="paid-content"> 付费内容块(带「付费内容」小标签),三套主题补齐样式
- 先去掉 Markdown 转换产生的 <p>[paid]</p> 包裹,避免替换后残留未闭合标签
- 测试:游客与会员均断言不出现裸 [paid]
This commit is contained in:
ak
2026-08-12 17:40:53 +08:00
parent 2089832dc0
commit d7a9135456
5 changed files with 30 additions and 6 deletions
+6 -3
View File
@@ -87,21 +87,24 @@ class MembershipFlowTest extends TestCase
'published_at' => now(),
]);
// 游客:付费部分被替换为 teaser
// 游客:付费部分被替换为 teaser,且不出现裸 [paid] 标签
$this->get('/posts/paid-post.shtml')
->assertOk()
->assertDontSee('付费隐藏内容')
->assertDontSee('[paid]')
->assertSee('本文包含付费内容')
->assertSee('登录后查看');
// 会员:可见
// 会员:可见,且 [paid] 标签被替换为付费内容块(不裸露)
$this->actingAs($this->user)->post('/membership/'.$this->plan->id.'/subscribe');
$payment = Payment::query()->where('user_id', $this->user->id)->first();
$this->actingAs($this->user)->post('/pay/sandbox/'.$payment->order_no.'/confirm');
$this->actingAs($this->user)->get('/posts/paid-post.shtml')
->assertOk()
->assertSee('付费隐藏内容');
->assertSee('付费隐藏内容')
->assertSee('paid-content')
->assertDontSee('[paid]');
}
public function test_unlock_post_creates_payment_with_payable_and_grants_access(): void