]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Protocol/ActivityTest.php
Merge pull request #7765 from nupplaphil/task/move_text
[friendica.git] / tests / src / Protocol / ActivityTest.php
diff --git a/tests/src/Protocol/ActivityTest.php b/tests/src/Protocol/ActivityTest.php
new file mode 100644 (file)
index 0000000..b6fcbf3
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+namespace Friendica\Test\Protocol;
+
+use Friendica\Protocol\Activity;
+use Friendica\Test\MockedTest;
+
+class ActivityTest extends MockedTest
+{
+       public function dataMatch()
+       {
+               return [
+                       'empty' => [
+                               'haystack' => '',
+                               'needle' => '',
+                               'assert' => true,
+                       ],
+                       'simple' => [
+                               'haystack' => ACTIVITY_OBJ_TAGTERM,
+                               'needle' => ACTIVITY_OBJ_TAGTERM,
+                               'assert' => true,
+                       ],
+                       'withNamespace' => [
+                               'haystack' => 'tagterm',
+                               'needle' => NAMESPACE_ACTIVITY_SCHEMA . ACTIVITY_OBJ_TAGTERM,
+                               'assert' => true,
+                       ],
+                       'invalidSimple' => [
+                               'haystack' => 'tagterm',
+                               'needle' => '',
+                               'assert' => false,
+                       ],
+                       'invalidWithOutNamespace' => [
+                               'haystack' => 'tagterm',
+                               'needle' => ACTIVITY_OBJ_TAGTERM,
+                               'assert' => false,
+                       ],
+                       'withSubPath' => [
+                               'haystack' => 'tagterm',
+                               'needle' =>  NAMESPACE_ACTIVITY_SCHEMA . '/bla/' . ACTIVITY_OBJ_TAGTERM,
+                               'assert' => true,
+                       ],
+               ];
+       }
+
+       /**
+        * Test the different, possible matchings
+        *
+        * @dataProvider dataMatch
+        */
+       public function testMatch(string $haystack, string $needle, bool $assert)
+       {
+               $activity = new Activity();
+
+               $this->assertEquals($assert, $activity->match($haystack, $needle));
+       }
+}