Add new Strings::performWithEscapedBlocks methods

- Add new BBCode::performWithEscapedTags method
- Add tests
This commit is contained in:
Hypolite Petovan 2020-06-04 19:25:48 -04:00
parent 6665eb76f9
commit 348b71d0b0
3 changed files with 92 additions and 0 deletions

View file

@ -194,4 +194,30 @@ class StringsTest extends TestCase
)
);
}
public function testPerformWithEscapedBlocks()
{
$originalText = '[noparse][/noparse][nobb]nobb[/nobb][noparse]noparse[/noparse]';
$text = Strings::performWithEscapedBlocks($originalText, '#[(?:noparse|nobb)].*?\[/(?:noparse|nobb)]#is', function ($text) {
return $text;
});
$this->assertEquals($originalText, $text);
}
public function testPerformWithEscapedBlocksNested()
{
$originalText = '[noparse][/noparse][nobb]nobb[/nobb][noparse]noparse[/noparse]';
$text = Strings::performWithEscapedBlocks($originalText, '#[nobb].*?\[/nobb]#is', function ($text) {
$text = Strings::performWithEscapedBlocks($text, '#[noparse].*?\[/noparse]#is', function ($text) {
return $text;
});
return $text;
});
$this->assertEquals($originalText, $text);
}
}