.
*/
namespace App\Tests\Services\Formatters;
use App\Services\Formatters\MarkdownParser;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\Translation\TranslatorInterface;
final class MarkdownParserTest extends TestCase
{
private MarkdownParser $service;
protected function setUp(): void
{
$translator = $this->createMock(TranslatorInterface::class);
$translator->method('trans')->willReturn('Loading...');
$this->service = new MarkdownParser($translator);
}
public function testOutputContainsDataMarkdownAttribute(): void
{
$result = $this->service->markForRendering('**hello**');
$this->assertStringContainsString('data-markdown=', $result);
$this->assertStringContainsString('data-controller="common--markdown"', $result);
}
public function testMarkdownContentIsHtmlescapedInAttribute(): void
{
$result = $this->service->markForRendering('');
// The raw < should not appear unescaped inside the attribute
$this->assertStringNotContainsString('