2022-12-08 21:23:19 +01:00
|
|
|
<?php
|
|
|
|
class Test_Activitypub_Activity extends WP_UnitTestCase {
|
|
|
|
public function test_activity_mentions() {
|
|
|
|
$post = \wp_insert_post(
|
|
|
|
array(
|
|
|
|
'post_author' => 1,
|
|
|
|
'post_content' => '@alex hello',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
add_filter(
|
|
|
|
'activitypub_extract_mentions',
|
2022-12-09 11:59:11 +01:00
|
|
|
function( $mentions ) {
|
|
|
|
$mentions['@alex'] = 'https://example.com/alex';
|
2022-12-08 21:23:19 +01:00
|
|
|
return $mentions;
|
|
|
|
},
|
2022-12-09 11:59:11 +01:00
|
|
|
10
|
2022-12-08 21:23:19 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$activitypub_post = new \Activitypub\Model\Post( $post );
|
|
|
|
|
2023-02-02 02:36:29 +01:00
|
|
|
$activitypub_activity = new \Activitypub\Model\Activity( 'Create' );
|
2022-12-08 21:23:19 +01:00
|
|
|
$activitypub_activity->from_post( $activitypub_post );
|
|
|
|
|
2023-05-12 21:58:50 +02:00
|
|
|
$this->assertContains( get_rest_url_by_path( 'users/1/followers' ), $activitypub_activity->get_to() );
|
2022-12-08 21:23:19 +01:00
|
|
|
$this->assertContains( 'https://example.com/alex', $activitypub_activity->get_cc() );
|
|
|
|
|
2022-12-09 11:59:11 +01:00
|
|
|
remove_all_filters( 'activitypub_extract_mentions' );
|
2022-12-08 21:23:19 +01:00
|
|
|
\wp_trash_post( $post );
|
|
|
|
}
|
|
|
|
}
|