2019-10-23 02:05:11 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Test\Protocol;
|
|
|
|
|
|
|
|
use Friendica\Protocol\Activity;
|
|
|
|
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:32:35 +02:00
|
|
|
'needle' => Activity\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:32:35 +02:00
|
|
|
'needle' => Activity\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();
|
|
|
|
|
|
|
|
$this->assertEquals($assert, $activity->match($haystack, $needle));
|
|
|
|
}
|
2019-10-24 00:25:43 +02:00
|
|
|
|
|
|
|
public function testIsHidden()
|
|
|
|
{
|
|
|
|
$activity = new Activity();
|
|
|
|
|
|
|
|
$this->assertTrue($activity->isHidden(Activity::LIKE));
|
2019-10-25 00:10:20 +02:00
|
|
|
$this->assertFalse($activity->isHidden(Activity\ObjectType::BOOKMARK));
|
2019-10-24 00:25:43 +02:00
|
|
|
}
|
2019-10-23 02:05:11 +02:00
|
|
|
}
|