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