From ffce0a705b98a6f5addbf0dea1f5ca2ae2178d4b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 5 Oct 2025 15:43:42 +0200 Subject: [PATCH] added test for Activity::pasteQuote() --- tests/unit/Lib/ActivityTest.php | 45 +++++++++++++++++++++++++++++++-- vendor/composer/installed.php | 12 ++++----- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/tests/unit/Lib/ActivityTest.php b/tests/unit/Lib/ActivityTest.php index 456a7535e..204725b0d 100644 --- a/tests/unit/Lib/ActivityTest.php +++ b/tests/unit/Lib/ActivityTest.php @@ -317,7 +317,48 @@ class ActivityTest extends UnitTestCase { ['zot6', 'activitypub', 'diaspora'] ], ]; - - } + + + private array $quote = [ + 'url' => 'https://example.tld/display/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b', + 'mid' => 'https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b', + 'bbcode' => "[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ]; + + /** + * @dataProvider pasteQuoteProvider + */ + public function testPasteQuote(string $body, string $expected) + { + $result = Activity::pasteQuote($body, $this->quote); + $this->assertSame($expected, $result); + } + + public function pasteQuoteProvider(): array + { + return [ + 'plain url replacement' => [ + 'RE: https://example.tld/display/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b', + "[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ], + 'bbcode url replacement' => [ + 'RE: [url=https://example.tld/display/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b]https://example.tld/display/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b[/url]', + "[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ], + 'append when no match' => [ + 'This is my message.', + "This is my message.\r\n\r\n[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ], + 'append when empty body' => [ + '', + "[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ], + 'alternate url replacement' => [ + 'RE: https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b', + "[share author='test' profile='https://example.tld/channel/test' avatar='https://example.tld/photo/profile/l/1?rev=1705823482' link='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b' auth='true' posted='2025-10-05T15:47:40Z' message_id='https://example.tld/item/1c8f5ba3-bd6e-4ea2-a403-e5b1c8627d4b']test[/share]" + ] + ]; + } + } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 871f948ee..b76f597f3 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,9 +1,9 @@ array( 'name' => 'zotlabs/hubzilla', - 'pretty_version' => 'dev-10.4RC', - 'version' => 'dev-10.4RC', - 'reference' => 'd566199423afb23882121994a9e480393aaf9fc3', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '49e65902d770ed404ad01490358c15c9a87f1687', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -497,9 +497,9 @@ 'dev_requirement' => false, ), 'zotlabs/hubzilla' => array( - 'pretty_version' => 'dev-10.4RC', - 'version' => 'dev-10.4RC', - 'reference' => 'd566199423afb23882121994a9e480393aaf9fc3', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '49e65902d770ed404ad01490358c15c9a87f1687', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),