setRawAttributes(['sSlug' => $slug]); $ancestor = new Categories();$ancestor->setRawAttributes(['sSlug' => $parent]); $category->setRelation('oParent', $parent ? $ancestor : null); $article = new Articles();$article->setRawAttributes(['sContent' => $html]); $article->setRelation('oCategory', $category); return $article; } public function test_legacy_promotion_is_replaced_without_touching_subscription_or_account_content(): void { foreach (['freenode', 'shadowrocketids'] as $category) { $tail = '
account:example'; $html = '
文章开头
* 七折,折后8元
'.$tail; $article = $this->article($category, $html); $prepared = ArticleRecommendations::prepare($article); $this->assertTrue($prepared['inline']); $this->assertSame('文章开头
'.ArticleRecommendations::SLOT.$tail, $prepared['body']); $this->assertSame($html, $article->sContent); } } public function test_no_promotion_link_means_no_destructive_guess_and_a_single_append(): void { $html = '用户另写的内容
保留
'; $result = ArticleRecommendations::prepare($this->article('freenode', $html)); $this->assertTrue($result['enabled']);$this->assertFalse($result['inline']); $this->assertSame($html, $result['body']); } public function test_all_intro_subcategories_append_and_advanced_articles_have_one_working_jump(): void { $html = '先配置订阅。
连接线路。
正文
'))['enabled']); config(['airport_recommendations.enabled' => false]); $result = ArticleRecommendations::prepare($this->article('advanced', '订阅
')); $this->assertFalse($result['enabled']);$this->assertSame('订阅
', $result['body']); } public function test_shared_view_outputs_configured_prices_coupon_and_sponsored_links_without_javascript(): void { $html = view('components.airport-recommendations')->render(); foreach (['福云', 'DP-LINK.NET', 'hardnerd', '>18<', '>26<', '>28<'] as $text) $this->assertStringContainsString($text, $html); $this->assertSame(1, substr_count($html, '