]> git.mxchange.org Git - friendica.git/blob - tests/src/Protocol/ActivityTest.php
Fix PSR-0 for test classes
[friendica.git] / tests / src / Protocol / ActivityTest.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Protocol;
23
24 use Friendica\Protocol\Activity;
25 use Friendica\Protocol\ActivityNamespace;
26 use Friendica\Test\MockedTest;
27
28 class ActivityTest extends MockedTest
29 {
30         public function dataMatch()
31         {
32                 return [
33                         'empty' => [
34                                 'haystack' => '',
35                                 'needle' => '',
36                                 'assert' => true,
37                         ],
38                         'simple' => [
39                                 'haystack' => Activity\ObjectType::TAGTERM,
40                                 'needle' => Activity\ObjectType::TAGTERM,
41                                 'assert' => true,
42                         ],
43                         'withNamespace' => [
44                                 'haystack' => 'tagterm',
45                                 'needle' => ActivityNamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM,
46                                 'assert' => true,
47                         ],
48                         'invalidSimple' => [
49                                 'haystack' => 'tagterm',
50                                 'needle' => '',
51                                 'assert' => false,
52                         ],
53                         'invalidWithOutNamespace' => [
54                                 'haystack' => 'tagterm',
55                                 'needle' => Activity\ObjectType::TAGTERM,
56                                 'assert' => false,
57                         ],
58                         'withSubPath' => [
59                                 'haystack' => 'tagterm',
60                                 'needle' => ActivityNamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM,
61                                 'assert' => true,
62                         ],
63                 ];
64         }
65
66         /**
67          * Test the different, possible matchings
68          *
69          * @dataProvider dataMatch
70          */
71         public function testMatch(string $haystack, string $needle, bool $assert)
72         {
73                 $activity = new Activity();
74
75                 $this->assertEquals($assert, $activity->match($haystack, $needle));
76         }
77
78         public function testIsHidden()
79         {
80                 $activity = new Activity();
81
82                 $this->assertTrue($activity->isHidden(Activity::LIKE));
83                 $this->assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
84         }
85 }