27 lines
1.3 KiB
PHP
27 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace Tests\Unit;
|
||
|
||
use App\Services\ResourceArticlePresentation;
|
||
use PHPUnit\Framework\TestCase;
|
||
|
||
final class ResourceArticlePresentationTest extends TestCase
|
||
{
|
||
public function test_daily_resource_prompts_are_removed_without_changing_resource_markup(): void
|
||
{
|
||
$prompts = '<p><b><a href="https://t.me/clashfreenode">👉 点击加入我们的tg频道,每日获取最新节点与苹果账号。</a></b></p><p></p>'
|
||
.'<p><b><a href="https://github.com/example">👉 点击关注我们的github仓库,永不失联。</a></b></p><p></p>';
|
||
$resource = '<p><a data-clipboard-text="fixture-subscription">复制订阅</a></p><p>App Store 使用说明</p>';
|
||
foreach (['freenode', 'shadowrocketids'] as $category) {
|
||
self::assertSame($resource, ResourceArticlePresentation::body($prompts.$resource, $category));
|
||
}
|
||
self::assertSame($prompts.$resource, ResourceArticlePresentation::body($prompts.$resource, 'advanced'));
|
||
}
|
||
|
||
public function test_unrelated_github_and_telegram_links_are_kept(): void
|
||
{
|
||
$body = '<p>在 <a href="https://github.com/example">GitHub</a> 下载客户端。</p><p>Telegram 客户端教程</p>';
|
||
self::assertSame($body, ResourceArticlePresentation::body($body, 'freenode'));
|
||
}
|
||
}
|