|
@@ 41-55 (lines=15) @@
|
| 38 |
|
$this->assertEquals(2, $times); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
public function testStripContentOutsideShortcodes() |
| 42 |
|
{ |
| 43 |
|
$handlers = new HandlerContainer(); |
| 44 |
|
$handlers->add('name', function(ShortcodeInterface $s) { return $s->getName(); }); |
| 45 |
|
$handlers->add('content', function(ShortcodeInterface $s) { return $s->getContent(); }); |
| 46 |
|
$handlers->add('root', function(ProcessedShortcode $s) { return 'root['.$s->getContent().']'; }); |
| 47 |
|
|
| 48 |
|
$events = new EventContainer(); |
| 49 |
|
$events->addListener(Events::REPLACE_SHORTCODES, new ReplaceJoinEventHandler(array('root'))); |
| 50 |
|
|
| 51 |
|
$processor = new Processor(new RegularParser(), $handlers); |
| 52 |
|
$processor = $processor->withEventContainer($events); |
| 53 |
|
|
| 54 |
|
$this->assertSame('a root[name name name] b', $processor->process('a [root]x [name] c[content] [name /] [/content] y[name/][/root] b')); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
public function testDefaultApplier() |
| 58 |
|
{ |
|
@@ 80-94 (lines=15) @@
|
| 77 |
|
$this->assertSame('a root[x name c name y] b', $processor->process('a [root]x [name] c[content] [name /] [/content] y[/root] b')); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
public function testRewriteReplacements() |
| 81 |
|
{ |
| 82 |
|
$handlers = new HandlerContainer(); |
| 83 |
|
$handlers->add('name', function(ShortcodeInterface $s) { return $s->getName(); }); |
| 84 |
|
$handlers->add('content', function(ShortcodeInterface $s) { return $s->getContent(); }); |
| 85 |
|
$handlers->add('root', function(ProcessedShortcode $s) { return 'root['.$s->getContent().']'; }); |
| 86 |
|
|
| 87 |
|
$events = new EventContainer(); |
| 88 |
|
$events->addListener(Events::REWRITE_REPLACEMENTS, new RewriteWrapEventHandler('>', '<')); |
| 89 |
|
|
| 90 |
|
$processor = new Processor(new RegularParser(), $handlers); |
| 91 |
|
$processor = $processor->withEventContainer($events); |
| 92 |
|
|
| 93 |
|
$this->assertSame('a >root[x >name< c> >name< < y]< b', $processor->process('a [root]x [name] c[content] [name /] [/content] y[/root] b')); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
public function testExceptionOnHandlerForUnknownEvent() |
| 97 |
|
{ |