mirror of
https://github.com/friendica/friendica
synced 2025-04-22 04:30:10 +00:00
Move activity_match() to Protocol\Activity::match()
- With tests
This commit is contained in:
parent
9e94e8b48c
commit
52c42491c4
9 changed files with 135 additions and 37 deletions
57
tests/src/Protocol/ActivityTest.php
Normal file
57
tests/src/Protocol/ActivityTest.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?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' => [
|
||||
'haystack' => ACTIVITY_OBJ_TAGTERM,
|
||||
'needle' => ACTIVITY_OBJ_TAGTERM,
|
||||
'assert' => true,
|
||||
],
|
||||
'withNamespace' => [
|
||||
'haystack' => 'tagterm',
|
||||
'needle' => NAMESPACE_ACTIVITY_SCHEMA . ACTIVITY_OBJ_TAGTERM,
|
||||
'assert' => true,
|
||||
],
|
||||
'invalidSimple' => [
|
||||
'haystack' => 'tagterm',
|
||||
'needle' => '',
|
||||
'assert' => false,
|
||||
],
|
||||
'invalidWithOutNamespace' => [
|
||||
'haystack' => 'tagterm',
|
||||
'needle' => ACTIVITY_OBJ_TAGTERM,
|
||||
'assert' => false,
|
||||
],
|
||||
'withSubPath' => [
|
||||
'haystack' => 'tagterm',
|
||||
'needle' => NAMESPACE_ACTIVITY_SCHEMA . '/bla/' . ACTIVITY_OBJ_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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue