friendica_2021-01/tests/src/Protocol/ActivityTest.php

66 lines
1.5 KiB
PHP
Raw Normal View History

<?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,
'assert' => true,
],
'withNamespace' => [
'haystack' => 'tagterm',
2019-10-25 00:32:35 +02:00
'needle' => Activity\ActivityNamespace::ACTIVITY_SCHEMA . Activity\ObjectType::TAGTERM,
'assert' => true,
],
'invalidSimple' => [
'haystack' => 'tagterm',
'needle' => '',
'assert' => false,
],
'invalidWithOutNamespace' => [
'haystack' => 'tagterm',
2019-10-25 00:10:20 +02:00
'needle' => Activity\ObjectType::TAGTERM,
'assert' => false,
],
'withSubPath' => [
'haystack' => 'tagterm',
2019-10-25 00:32:35 +02:00
'needle' => Activity\ActivityNamespace::ACTIVITY_SCHEMA . '/bla/' . Activity\ObjectType::TAGTERM,
'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));
}
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));
}
}