5 use BookStack\Entities\Tools\PageIncludeParser;
8 class PageIncludeParserTest extends TestCase
10 public function test_include_simple_inline_text()
13 '<p>{{@45#content}}</p>',
14 ['45' => '<p id="content">Testing</p>'],
19 public function test_include_simple_inline_text_with_existing_siblings()
22 '<p>{{@45#content}} <strong>Hi</strong>there!</p>',
23 ['45' => '<p id="content">Testing</p>'],
24 '<p>Testing <strong>Hi</strong>there!</p>',
28 public function test_include_simple_inline_text_within_other_text()
31 '<p>Hello {{@45#content}}there!</p>',
32 ['45' => '<p id="content">Testing</p>'],
33 '<p>Hello Testingthere!</p>',
37 protected function runParserTest(string $html, array $contentById, string $expected)
39 $parser = new PageIncludeParser($html, function (int $id) use ($contentById) {
40 return $contentById[strval($id)] ?? '';
43 $result = $parser->parse();
44 $this->assertEquals($expected, $result);