]> git.mxchange.org Git - friendica.git/blob - tests/src/Protocol/ActivityTest.php
Move Activity/Namespaces defines to constants
[friendica.git] / tests / src / Protocol / ActivityTest.php
1 <?php
2
3 namespace Friendica\Test\Protocol;
4
5 use Friendica\Protocol\Activity;
6 use Friendica\Test\MockedTest;
7
8 class ActivityTest extends MockedTest
9 {
10         public function dataMatch()
11         {
12                 return [
13                         'empty' => [
14                                 'haystack' => '',
15                                 'needle' => '',
16                                 'assert' => true,
17                         ],
18                         'simple' => [
19                                 'haystack' => Activity::OBJ_TAGTERM,
20                                 'needle' => Activity::OBJ_TAGTERM,
21                                 'assert' => true,
22                         ],
23                         'withNamespace' => [
24                                 'haystack' => 'tagterm',
25                                 'needle' => Activity\Namespaces::ACTIVITY_SCHEMA . Activity::OBJ_TAGTERM,
26                                 'assert' => true,
27                         ],
28                         'invalidSimple' => [
29                                 'haystack' => 'tagterm',
30                                 'needle' => '',
31                                 'assert' => false,
32                         ],
33                         'invalidWithOutNamespace' => [
34                                 'haystack' => 'tagterm',
35                                 'needle' => Activity::OBJ_TAGTERM,
36                                 'assert' => false,
37                         ],
38                         'withSubPath' => [
39                                 'haystack' => 'tagterm',
40                                 'needle' =>  Activity\Namespaces::ACTIVITY_SCHEMA . '/bla/' . Activity::OBJ_TAGTERM,
41                                 'assert' => true,
42                         ],
43                 ];
44         }
45
46         /**
47          * Test the different, possible matchings
48          *
49          * @dataProvider dataMatch
50          */
51         public function testMatch(string $haystack, string $needle, bool $assert)
52         {
53                 $activity = new Activity();
54
55                 $this->assertEquals($assert, $activity->match($haystack, $needle));
56         }
57
58         public function testIsHidden()
59         {
60                 $activity = new Activity();
61
62                 $this->assertTrue($activity->isHidden(Activity::LIKE));
63                 $this->assertFalse($activity->isHidden(Activity::OBJ_BOOKMARK));
64         }
65 }