| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace Tests\Unit;
- use App\Services\AsyncMarkdownSplitter;
- use PHPUnit\Framework\TestCase;
- class AsyncMarkdownSplitterTest extends TestCase
- {
- /** @test */
- public function it_splits_markdown_by_question_number_and_keeps_indexes(): void
- {
- $markdown = <<<MD
- 一、选择题
- 1. 已知集合 A = {1,2},则 ...
- A. 1
- B. 2
- 2、计算:2+3=?
- 3) 解方程:x+1=2
- MD;
- $splitter = new AsyncMarkdownSplitter();
- $blocks = $splitter->split($markdown);
- $this->assertCount(3, $blocks);
- $this->assertSame(1, $blocks[0]['index']);
- $this->assertSame(2, $blocks[1]['index']);
- $this->assertSame(3, $blocks[2]['index']);
- $this->assertStringContainsString('1.', $blocks[0]['raw_markdown']);
- $this->assertStringContainsString('2、', $blocks[1]['raw_markdown']);
- $this->assertStringContainsString('3)', $blocks[2]['raw_markdown']);
- }
- }
|