Files
larablog/tests/Unit/ContentRendererTest.php
ak 263b98b218 Initial baseline: LaraBlog core with plugin commerce surface.
Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
2026-08-12 01:15:38 +08:00

38 lines
1.1 KiB
PHP

<?php
namespace Tests\Unit;
use App\Domain\Blog\ContentFormat;
use App\Domain\Blog\ContentRenderer;
use Tests\TestCase;
class ContentRendererTest extends TestCase
{
public function test_markdown_renders_to_html(): void
{
$html = app(ContentRenderer::class)->toHtml("# Hello\n\n**world**", ContentFormat::MARKDOWN);
$this->assertMatchesRegularExpression('/<h1[^>]*>Hello<\/h1>/', $html);
$this->assertStringContainsString('<strong>world</strong>', $html);
}
public function test_html_format_passes_through_purifier(): void
{
$html = app(ContentRenderer::class)->toHtml(
'<p>ok</p><script>alert(1)</script>',
ContentFormat::HTML,
);
$this->assertStringContainsString('<p>ok</p>', $html);
$this->assertStringNotContainsString('<script>', $html);
}
public function test_html_to_markdown_roundtrip_basic(): void
{
$md = app(ContentRenderer::class)->htmlToMarkdown('<h2>Title</h2><p>Hello <strong>x</strong></p>');
$this->assertStringContainsString('Title', $md);
$this->assertStringContainsString('Hello', $md);
}
}