Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
42 lines
937 B
PHP
42 lines
937 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Domain\Blog\ContentFormat;
|
|
use App\Domain\Blog\ContentRenderer;
|
|
use Tests\TestCase;
|
|
|
|
class ContentTocTest extends TestCase
|
|
{
|
|
public function test_markdown_headings_produce_toc_and_ids(): void
|
|
{
|
|
$markdown = <<<'MD'
|
|
Intro paragraph.
|
|
|
|
## First Section
|
|
|
|
Hello.
|
|
|
|
### Nested
|
|
|
|
More.
|
|
|
|
## Second Section
|
|
|
|
End.
|
|
MD;
|
|
|
|
$result = app(ContentRenderer::class)->render($markdown, ContentFormat::MARKDOWN);
|
|
|
|
$this->assertCount(3, $result['toc']);
|
|
$this->assertSame('First Section', $result['toc'][0]['text']);
|
|
$this->assertSame(2, $result['toc'][0]['level']);
|
|
$this->assertSame('Nested', $result['toc'][1]['text']);
|
|
$this->assertSame(3, $result['toc'][1]['level']);
|
|
$this->assertStringContainsString('id="', $result['html']);
|
|
$this->assertStringContainsString($result['toc'][0]['id'], $result['html']);
|
|
}
|
|
}
|