mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 15:54:26 +02:00
Create events for bbcode hooks
This commit is contained in:
parent
81b6ed9fc2
commit
62d27de3b0
5 changed files with 104 additions and 3 deletions
|
@ -44,6 +44,8 @@ class HookEventBridgeTest extends TestCase
|
|||
ArrayFilterEvent::OEMBED_FETCH_END => 'onOembedFetchEndEvent',
|
||||
ArrayFilterEvent::PAGE_INFO => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::SMILEY_LIST => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::BBCODE_TO_HTML_START => 'onBbcodeToHtmlEvent',
|
||||
ArrayFilterEvent::BBCODE_TO_MARKDOWN_END => 'onBbcodeToMarkdownEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
@ -181,6 +183,50 @@ class HookEventBridgeTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testOnBbcodeToHtmlEventCallsHookWithCorrectValue(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent(ArrayFilterEvent::BBCODE_TO_HTML_START, ['bbcode2html' => '[b]original[/b]']);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, string $data): string {
|
||||
$this->assertSame('bbcode', $name);
|
||||
$this->assertSame('[b]original[/b]', $data);
|
||||
|
||||
return '<b>changed</b>';
|
||||
});
|
||||
|
||||
HookEventBridge::onBbcodeToHtmlEvent($event);
|
||||
|
||||
$this->assertSame(
|
||||
['bbcode2html' => '<b>changed</b>'],
|
||||
$event->getArray(),
|
||||
);
|
||||
}
|
||||
|
||||
public function testOnBbcodeToMarkdownEventCallsHookWithCorrectValue(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent(ArrayFilterEvent::BBCODE_TO_MARKDOWN_END, ['bbcode2markdown' => '[b]original[/b]']);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, string $data): string {
|
||||
$this->assertSame('bb2diaspora', $name);
|
||||
$this->assertSame('[b]original[/b]', $data);
|
||||
|
||||
return '**changed**';
|
||||
});
|
||||
|
||||
HookEventBridge::onBbcodeToMarkdownEvent($event);
|
||||
|
||||
$this->assertSame(
|
||||
['bbcode2markdown' => '**changed**'],
|
||||
$event->getArray(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getArrayFilterEventData(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -41,6 +41,8 @@ class ArrayFilterEventTest extends TestCase
|
|||
[ArrayFilterEvent::OEMBED_FETCH_END, 'friendica.data.oembed_fetch_end'],
|
||||
[ArrayFilterEvent::PAGE_INFO, 'friendica.data.page_info'],
|
||||
[ArrayFilterEvent::SMILEY_LIST, 'friendica.data.smiley_list'],
|
||||
[ArrayFilterEvent::BBCODE_TO_HTML_START, 'friendica.data.bbcode_to_html_start'],
|
||||
[ArrayFilterEvent::BBCODE_TO_MARKDOWN_END, 'friendica.data.bbcode_to_markdown_end'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue