' . $contents . ''; } class StudipFormatTest extends \Codeception\Test\Unit { private $old_rules; function setUp(): void { $this->old_rules = StudipCoreFormat::getStudipMarkups(); } function tearDown(): void { foreach (StudipCoreFormat::getStudipMarkups() as $key => $value) { StudipCoreFormat::removeStudipMarkup($key); } foreach ($this->old_rules as $key => $value) { StudipCoreFormat::addStudipMarkup($key, @$value['start'], @$value['end'], @$value['callback']); } } public function testAddStudipMarkup() { StudipCoreFormat::addStudipMarkup('bb-bold', '\[b\]', '\[\/b\]', 'markupBold', 'links'); $markup = new StudipCoreFormat(); $input = '[b]some %%code%%[/b]'; $expected = 'some code'; $this->assertEquals($expected, $markup->format($input)); } public function testRemoveStudipMarkup() { StudipCoreFormat::removeStudipMarkup('bold'); $markup = new StudipCoreFormat(); $input = '**some %%code%%**'; $expected = '**some code**'; $this->assertEquals($expected, $markup->format($input)); } public function testTextSizing() { $markup = new StudipCoreFormat(); $input = '++++abc++++ **++123++**'; $expected = 'abc 123'; $this->assertEquals($expected, $markup->format($input)); } public function testHtmlEnclosedMarkup() { $markup = new StudipCoreFormat(); $index = 0; forEach ([ '

' . PHP_EOL . '- single item' . PHP_EOL . '

' => '

' . PHP_EOL . '

' . '

', '

' . PHP_EOL . '- a' . PHP_EOL . '- list' . PHP_EOL . '

' => '

' . PHP_EOL . '

' . '

' ] as $in => $out) { ++$index; $this->assertEquals($out, $markup->format($in), 'test number ' . $index); } } public function testTable() { $markup = new StudipCoreFormat(); $index = 0; forEach ([ '|a|table' . PHP_EOL => '' . '' . '
atable
', '| this | is a | table |' . PHP_EOL . '| with | two | rows |' => '' . '' . '' . '
thisis atable
withtworows
' ] as $in => $out) { ++$index; $this->assertEquals($out, $markup->format($in), 'test number ' . $index); } } }