aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-07 10:00:02 +0100
committerMario <mario@mariovavti.com>2024-03-07 10:00:02 +0100
commit6262d351b777443bee2a1b5b534082268ebe72f9 (patch)
tree4eb6d2b7f4677f76a3c392552691b8726d75522b /tests/unit/Lib
parent27e57ff7aad9b70a4d088b880fac4af2920fdd31 (diff)
downloadvolse-hubzilla-6262d351b777443bee2a1b5b534082268ebe72f9.tar.gz
volse-hubzilla-6262d351b777443bee2a1b5b534082268ebe72f9.tar.bz2
volse-hubzilla-6262d351b777443bee2a1b5b534082268ebe72f9.zip
fix deprecation warning and add test
Diffstat (limited to 'tests/unit/Lib')
-rw-r--r--tests/unit/Lib/ActivityTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/Lib/ActivityTest.php b/tests/unit/Lib/ActivityTest.php
new file mode 100644
index 000000000..38c3d584c
--- /dev/null
+++ b/tests/unit/Lib/ActivityTest.php
@@ -0,0 +1,42 @@
+<?php
+namespace Zotlabs\Tests\Unit\Lib;
+
+error_reporting(E_ALL);
+
+use Zotlabs\Tests\Unit\UnitTestCase;
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\ActivityStreams;
+
+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
+ ]
+ ];
+ }
+
+}