Skip to content

Commit

Permalink
Create failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
obenland committed Jan 27, 2025
1 parent 0dce338 commit 3d45f8e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/includes/class-test-dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @coversDefaultClass Activitypub\Dispatcher
*/
class Test_Dispatcher extends WP_UnitTestCase {
class Test_Dispatcher extends \Activitypub\Tests\ActivityPub_Outbox_TestCase {
/**
* Tear down the test case.
*/
Expand Down Expand Up @@ -90,4 +90,27 @@ function ( $name ) {
$result = Dispatcher::maybe_add_inboxes_of_blog_user( $inboxes, 1, $activity );
$this->assertEquals( $inboxes, $result );
}

/**
* Test process_outbox.
*
* @covers ::process_outbox
*/
public function test_process_outbox() {
$post_id = self::factory()->post->create( array( 'post_author' => self::$user_id ) );

$test_callback = function ( $send, $activity ) {
$this->assertInstanceOf( Activity::class, $activity );
$this->assertEquals( 'Create', $activity->get_type() );

return $send;
};
add_filter( 'activitypub_send_activity_to_followers', $test_callback, 10, 2 );

$outbox_item = $this->get_latest_outbox_item( \add_query_arg( 'p', $post_id, \home_url( '/' ) ) );

Dispatcher::process_outbox( $outbox_item->ID );

remove_filter( 'activitypub_send_activity_to_followers', $test_callback );
}
}

0 comments on commit 3d45f8e

Please sign in to comment.