mirror of
https://github.com/friendica/friendica
synced 2025-04-27 13:10:10 +00:00
Create event for oembed_fetch_url hook
This commit is contained in:
parent
aff117284b
commit
b9a401454d
5 changed files with 51 additions and 3 deletions
|
@ -41,6 +41,7 @@ class HookEventBridgeTest extends TestCase
|
|||
ArrayFilterEvent::DISPLAY_ITEM => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::RENDER_LOCATION => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::ITEM_PHOTO_MENU => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::OEMBED_FETCH_END => 'onOembedFetchEndEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
@ -156,6 +157,28 @@ class HookEventBridgeTest extends TestCase
|
|||
HookEventBridge::onCollectRoutesEvent($event);
|
||||
}
|
||||
|
||||
public function testOnOembedFetchEndEventCallsHookWithCorrectValue(): void
|
||||
{
|
||||
$event = new ArrayFilterEvent(ArrayFilterEvent::OEMBED_FETCH_END, ['url' => 'original_url']);
|
||||
|
||||
$reflectionProperty = new \ReflectionProperty(HookEventBridge::class, 'mockedCallHook');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
|
||||
$reflectionProperty->setValue(null, function (string $name, $data): string {
|
||||
$this->assertSame('oembed_fetch_url', $name);
|
||||
$this->assertSame('original_url', $data);
|
||||
|
||||
return 'changed_url';
|
||||
});
|
||||
|
||||
HookEventBridge::onOembedFetchEndEvent($event);
|
||||
|
||||
$this->assertSame(
|
||||
['url' => 'changed_url'],
|
||||
$event->getArray(),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getArrayFilterEventData(): array
|
||||
{
|
||||
return [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue