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.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/unit/Lib/ActivityTest.php b/tests/unit/Lib/ActivityTest.php
new file mode 100644
index 000000000..c9ce79d8c
--- /dev/null
+++ b/tests/unit/Lib/ActivityTest.php
@@ -0,0 +1,39 @@
+<?php
+namespace Zotlabs\Tests\Unit\Lib;
+
+error_reporting(E_ALL);
+
+use Zotlabs\Tests\Unit\UnitTestCase;
+use Zotlabs\Lib\Activity;
+
+class ActivityTest extends UnitTestCase {
+ /**
+ * Test get a textfield from an activitystreams object
+ *
+ * @dataProvider get_textfield_provider
+ */
+ public function test_get_textfield(array $src, null|string|array $expected): void {
+ $this->assertEquals($expected, Activity::get_textfield($src, 'content'));
+ }
+
+ /**
+ * Dataprovider for test_get_textfield.
+ */
+ private function get_textfield_provider(): array {
+ return [
+ 'get content field' => [
+ ['content' => 'Some content'],
+ 'Some content'
+ ],
+ 'get content from map' => [
+ ['contentMap' => ['en' => 'Some content']],
+ ['en' => 'Some content']
+ ],
+ 'get not available content' => [
+ ['some_field' => 'Some content'],
+ null
+ ]
+ ];
+ }
+
+}