mirror of
https://github.com/friendica/friendica
synced 2025-05-01 19:04:23 +02:00
Add new Strings::performWithEscapedBlocks methods
- Add new BBCode::performWithEscapedTags method - Add tests
This commit is contained in:
parent
6665eb76f9
commit
348b71d0b0
3 changed files with 92 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue