2019-10-23 02:05:11 +02:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
2021-03-29 08:40:20 +02:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 15:45:36 +01: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 02:05:11 +02:00
|
|
|
|
2020-09-11 19:38:41 +02:00
|
|
|
namespace Friendica\Test\src\Protocol;
|
2019-10-23 02:05:11 +02:00
|
|
|
|
|
|
|
use Friendica\Protocol\Activity;
|
2019-10-25 00:34:46 +02:00
|
|
|
use Friendica\Protocol\ActivityNamespace;
|
2019-10-23 02:05:11 +02:00
|
|
|
use Friendica\Test\MockedTest;
|
|
|
|
|
|
|
|
class ActivityTest extends MockedTest
|
|
|
|
{
|
|
|
|
public function dataMatch()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'empty' => [
|
|
|
|
'haystack' => '',
|
|
|
|
'needle' => '',
|
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'simple' => [
|
2019-10-25 00:10:20 +02:00
|
|
|
'haystack' => Activity\ObjectType::TAGTERM,
|
|
|
|
'needle' => Activity\ObjectType::TAGTERM,
|
2019-10-23 02:05:11 +02:00
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'withNamespace' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-25 00:34:46 +02:00
|
|
|
'needle' => ActivityNamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM,
|
2019-10-23 02:05:11 +02:00
|
|
|
'assert' => true,
|
|
|
|
],
|
|
|
|
'invalidSimple' => [
|
|
|
|
'haystack' => 'tagterm',
|
|
|
|
'needle' => '',
|
|
|
|
'assert' => false,
|
|
|
|
],
|
|
|
|
'invalidWithOutNamespace' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-25 00:10:20 +02:00
|
|
|
'needle' => Activity\ObjectType::TAGTERM,
|
2019-10-23 02:05:11 +02:00
|
|
|
'assert' => false,
|
|
|
|
],
|
|
|
|
'withSubPath' => [
|
|
|
|
'haystack' => 'tagterm',
|
2019-10-25 00:34:46 +02:00
|
|
|
'needle' => ActivityNamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM,
|
2019-10-23 02:05:11 +02: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 14:19:57 +02:00
|
|
|
self::assertEquals($assert, $activity->match($haystack, $needle));
|
2019-10-23 02:05:11 +02:00
|
|
|
}
|
2019-10-24 00:25:43 +02:00
|
|
|
|
|
|
|
public function testIsHidden()
|
|
|
|
{
|
|
|
|
$activity = new Activity();
|
|
|
|
|
2020-10-17 14:19:57 +02:00
|
|
|
self::assertTrue($activity->isHidden(Activity::LIKE));
|
|
|
|
self::assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
|
2019-10-24 00:25:43 +02:00
|
|
|
}
|
2019-10-23 02:05:11 +02:00
|
|
|
}
|