2019-10-23 00:05:11 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
2021-03-29 06:40:20 +00:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 14:45:36 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-10-23 00:05:11 +00:00
|
|
|
|
2020-09-11 17:38:41 +00:00
|
|
|
namespace Friendica\Test\src\Protocol;
|
2019-10-23 00:05:11 +00:00
|
|
|
|
|
|
|
use Friendica\Protocol\Activity;
|
2019-10-24 22:34:46 +00:00
|
|
|
use Friendica\Protocol\ActivityNamespace;
|
2019-10-23 00:05:11 +00:00
|
|
|
use Friendica\Test\MockedTest;
|
|
|
|
|
|
|
|
class ActivityTest extends MockedTest
|
|
|
|
{
|
|
|
|
public function dataMatch()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'empty' => [
|
|
|
|
'haystack' => '',
|
|
|
|
'needle' => '',
|
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'simple' => [
|
2019-10-24 22:10:20 +00:00
|
|
|
'haystack' => Activity\ObjectType::TAGTERM,
|
|
|
|
'needle' => Activity\ObjectType::TAGTERM,
|
2019-10-23 00:05:11 +00:00
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'withNamespace' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-24 22:34:46 +00:00
|
|
|
'needle' => ActivityNamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM,
|
2019-10-23 00:05:11 +00:00
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'invalidSimple' => [
|
|
|
|
'haystack' => 'tagterm',
|
|
|
|
'needle' => '',
|
|
|
|
'assert' => false,
|
|
|
|
],
|
|
|
|
'invalidWithOutNamespace' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-24 22:10:20 +00:00
|
|
|
'needle' => Activity\ObjectType::TAGTERM,
|
2019-10-23 00:05:11 +00:00
|
|
|
'assert' => false,
|
|
|
|
],
|
|
|
|
'withSubPath' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-24 22:34:46 +00:00
|
|
|
'needle' => ActivityNamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM,
|
2019-10-23 00:05:11 +00:00
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the different, possible matchings
|
|
|
|
*
|
|
|
|
* @dataProvider dataMatch
|
|
|
|
*/
|
|
|
|
public function testMatch(string $haystack, string $needle, bool $assert)
|
|
|
|
{
|
|
|
|
$activity = new Activity();
|
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertEquals($assert, $activity->match($haystack, $needle));
|
2019-10-23 00:05:11 +00:00
|
|
|
}
|
2019-10-23 22:25:43 +00:00
|
|
|
|
|
|
|
public function testIsHidden()
|
|
|
|
{
|
|
|
|
$activity = new Activity();
|
|
|
|
|
2020-10-17 12:19:57 +00:00
|
|
|
self::assertTrue($activity->isHidden(Activity::LIKE));
|
|
|
|
self::assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
|
2019-10-23 22:25:43 +00:00
|
|
|
}
|
2019-10-23 00:05:11 +00:00
|
|
|
}
|