aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib/ActivityTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Lib/ActivityTest.php')
-rw-r--r--tests/unit/Lib/ActivityTest.php48
1 files changed, 47 insertions, 1 deletions
diff --git a/tests/unit/Lib/ActivityTest.php b/tests/unit/Lib/ActivityTest.php
index 543bf60bc..456a7535e 100644
--- a/tests/unit/Lib/ActivityTest.php
+++ b/tests/unit/Lib/ActivityTest.php
@@ -46,7 +46,7 @@ class ActivityTest extends UnitTestCase {
*
* @dataProvider get_mid_and_uuid_provider
*/
- public function test_get_mid_and_uuid(string $payload, $mid, $uuid): void {
+ public function test_get_mid_and_uuid(string $payload, string $mid, string $uuid): void {
//
@@ -274,4 +274,50 @@ class ActivityTest extends UnitTestCase {
];
}
+ public function testBuildPacketWithEmptyChannel(): void {
+ $data = [ 'aKey' => 'aValue' ];
+ $packet = json_decode(Activity::build_packet($data, []), true);
+
+ $this->assertArrayHasKey('aKey', $packet);
+ $this->assertEquals('aValue', $packet['aKey']);
+ }
+
+ /**
+ * Test get protocols from an activitystreams actor object
+ *
+ * @dataProvider get_actor_protocols_provider
+ */
+ public function test_get_actor_protocols(array $actor, array $expected): void {
+ $this->assertEquals($expected, Activity::get_actor_protocols($actor));
+ }
+
+ /**
+ * Dataprovider for test_get_actor_protocols.
+ */
+ public static function get_actor_protocols_provider(): array {
+ return [
+ 'none' => [
+ ['tag' => [['type' => 'Note', 'name' => 'Website', 'content' => 'https://example.com']]],
+ []
+ ],
+ 'legacy' => [
+ ['tag' => [
+ ['type' => 'PropertyValue', 'name' => 'Protocol', 'value' => 'zot6'],
+ ['type' => 'PropertyValue', 'name' => 'Protocol', 'value' => 'activitypub'],
+ ['type' => 'PropertyValue', 'name' => 'Protocol', 'value' => 'diaspora']
+ ]],
+ ['zot6', 'activitypub', 'diaspora']
+ ],
+ 'fep-fb2a' => [
+ ['tag' => [['type' => 'Note', 'name' => 'Protocols', 'content' => 'zot6,activitypub,diaspora']]],
+ ['zot6', 'activitypub', 'diaspora']
+ ],
+ 'fep-fb2a with spaces' => [
+ ['tag' => [['type' => 'Note', 'name' => 'Protocols', 'content' => 'zot6, activitypub, diaspora']]],
+ ['zot6', 'activitypub', 'diaspora']
+ ],
+ ];
+
+
+ }
}