Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
38 lines
1.1 KiB
PHP
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);
|
|
}
|
|
}
|