enhance tests to also test announce and blog wide activities
This commit is contained in:
parent
be6d8a1792
commit
0fab95bfff
1 changed files with 37 additions and 0 deletions
|
@ -39,11 +39,15 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
|
|||
$this->assertSame( 2, $pre_http_request->get_call_count() );
|
||||
$all_args = $pre_http_request->get_args();
|
||||
$first_call_args = array_shift( $all_args );
|
||||
|
||||
$this->assertEquals( 'https://example.com/author/jon/inbox', $first_call_args[2] );
|
||||
|
||||
$second_call_args = array_shift( $all_args );
|
||||
$this->assertEquals( 'https://example.org/users/username/inbox', $second_call_args[2] );
|
||||
|
||||
$json = json_decode( $second_call_args[1]['body'] );
|
||||
$this->assertEquals( 'Create', $json->type );
|
||||
|
||||
remove_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 );
|
||||
}
|
||||
|
||||
|
@ -88,6 +92,39 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
|
|||
remove_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 );
|
||||
}
|
||||
|
||||
public function test_dispatch_announce() {
|
||||
$followers = array( 'https://example.com/author/jon' );
|
||||
|
||||
foreach ( $followers as $follower ) {
|
||||
\Activitypub\Collection\Followers::add_follower( \Activitypub\Collection\Users::BLOG_USER_ID, $follower );
|
||||
}
|
||||
|
||||
$post = \wp_insert_post(
|
||||
array(
|
||||
'post_author' => 1,
|
||||
'post_content' => 'hello',
|
||||
)
|
||||
);
|
||||
|
||||
$pre_http_request = new MockAction();
|
||||
add_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10, 3 );
|
||||
|
||||
\Activitypub\Activity_Dispatcher::send_activity_or_announce( get_post( $post ), 'Create' );
|
||||
|
||||
$all_args = $pre_http_request->get_args();
|
||||
$first_call_args = $all_args[0];
|
||||
|
||||
$this->assertSame( 1, $pre_http_request->get_call_count() );
|
||||
|
||||
$user = new \Activitypub\Model\Blog_User();
|
||||
|
||||
$json = json_decode( $first_call_args[1]['body'] );
|
||||
$this->assertEquals( 'Announce', $json->type );
|
||||
$this->assertEquals( $user->get_url(), $json->actor );
|
||||
|
||||
remove_filter( 'pre_http_request', array( $pre_http_request, 'filter' ), 10 );
|
||||
}
|
||||
|
||||
public function set_up() {
|
||||
parent::set_up();
|
||||
add_filter( 'pre_get_remote_metadata_by_actor', array( get_called_class(), 'pre_get_remote_metadata_by_actor' ), 10, 2 );
|
||||
|
|
Loading…
Reference in a new issue