-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update StatusTagsPipeline, fix object tags and slug normalization
- Loading branch information
Showing
2 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class ActivityPubTagObjectTest extends TestCase | ||
{ | ||
/** | ||
* A basic unit test example. | ||
*/ | ||
public function test_gotosocial(): void | ||
{ | ||
$res = [ | ||
"tag" => [ | ||
"href" => "https://gotosocial.example.org/users/GotosocialUser", | ||
"name" => "@GotosocialUser@gotosocial.example.org", | ||
"type" => "Mention" | ||
] | ||
]; | ||
|
||
if(isset($res['tag']['type'], $res['tag']['name'])) { | ||
$res['tag'] = [$res['tag']]; | ||
} | ||
|
||
$tags = collect($res['tag']) | ||
->filter(function($tag) { | ||
return $tag && | ||
$tag['type'] == 'Mention' && | ||
isset($tag['href']) && | ||
substr($tag['href'], 0, 8) === 'https://'; | ||
}); | ||
$this->assertTrue($tags->count() === 1); | ||
} | ||
|
||
public function test_pixelfed_hashtags(): void | ||
{ | ||
$res = [ | ||
"tag" => [ | ||
[ | ||
"type" => "Mention", | ||
"href" => "https://pixelfed.social/dansup", | ||
"name" => "@dansup@pixelfed.social" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/dogsofpixelfed", | ||
"name" => "#dogsOfPixelFed" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/doggo", | ||
"name" => "#doggo" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/dog", | ||
"name" => "#dog" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/drake", | ||
"name" => "#drake" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/blacklab", | ||
"name" => "#blacklab" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/iconic", | ||
"name" => "#Iconic" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/majestic", | ||
"name" => "#majestic" | ||
] | ||
] | ||
]; | ||
|
||
if(isset($res['tag']['type'], $res['tag']['name'])) { | ||
$res['tag'] = [$res['tag']]; | ||
} | ||
|
||
$tags = collect($res['tag']) | ||
->filter(function($tag) { | ||
return $tag && | ||
$tag['type'] == 'Hashtag' && | ||
isset($tag['href']) && | ||
substr($tag['href'], 0, 8) === 'https://'; | ||
}); | ||
$this->assertTrue($tags->count() === 7); | ||
} | ||
|
||
|
||
public function test_pixelfed_mentions(): void | ||
{ | ||
$res = [ | ||
"tag" => [ | ||
[ | ||
"type" => "Mention", | ||
"href" => "https://pixelfed.social/dansup", | ||
"name" => "@dansup@pixelfed.social" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/dogsofpixelfed", | ||
"name" => "#dogsOfPixelFed" | ||
], | ||
[ | ||
"type" => "Hashtag", | ||
"href" => "https://pixelfed.social/discover/tags/doggo", | ||
"name" => "#doggo" | ||
], | ||
] | ||
]; | ||
|
||
if(isset($res['tag']['type'], $res['tag']['name'])) { | ||
$res['tag'] = [$res['tag']]; | ||
} | ||
|
||
$tags = collect($res['tag']) | ||
->filter(function($tag) { | ||
return $tag && | ||
$tag['type'] == 'Mention' && | ||
isset($tag['href']) && | ||
substr($tag['href'], 0, 8) === 'https://'; | ||
}); | ||
$this->assertTrue($tags->count() === 1); | ||
} | ||
} |