Skip to:
Content

bbPress.org


Ignore:
Timestamp:
10/04/2026 09:04:38 AM (3 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover user relationship repair routines.

Verify that favorite, topic subscription, and forum subscription repairs retain published objects while removing trashed objects from stored user relationships.

In trunk, for 2.7.

See #3695.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/admin/tools.php

    r7795 r7796  
    856856        /**
    857857         * @covers ::bbp_admin_repair_user_favorites
    858          * @todo   Implement test_bbp_admin_repair_user_favorites().
    859858         */
    860859        public function test_bbp_admin_repair_user_favorites() {
    861                 // Remove the following lines when you implement this test.
    862                 $this->markTestIncomplete(
    863                         'This test has not been implemented yet.'
    864                 );
     860                $user_id = $this->factory->user->create();
     861                $live_id = $this->factory->topic->create();
     862                $old_id  = $this->factory->topic->create();
     863                $key     = bbp_db()->prefix . '_bbp_favorites';
     864                wp_trash_post( $old_id );
     865                update_user_meta( $user_id, $key, "{$live_id},{$old_id}" );
     866
     867                $this->assertSame( 0, bbp_admin_repair_user_favorites()[0] );
     868                $this->assertSame( (string) $live_id, get_user_meta( $user_id, $key, true ) );
    865869        }
    866870
    867871        /**
    868872         * @covers ::bbp_admin_repair_user_topic_subscriptions
    869          * @todo   Implement test_bbp_admin_repair_user_topic_subscriptions().
    870873         */
    871874        public function test_bbp_admin_repair_user_topic_subscriptions() {
    872                 // Remove the following lines when you implement this test.
    873                 $this->markTestIncomplete(
    874                         'This test has not been implemented yet.'
    875                 );
     875                $user_id = $this->factory->user->create();
     876                $live_id = $this->factory->topic->create();
     877                $old_id  = $this->factory->topic->create();
     878                $key     = bbp_db()->prefix . '_bbp_subscriptions';
     879                wp_trash_post( $old_id );
     880                update_user_meta( $user_id, $key, "{$live_id},{$old_id}" );
     881
     882                $this->assertSame( 0, bbp_admin_repair_user_topic_subscriptions()[0] );
     883                $this->assertSame( (string) $live_id, get_user_meta( $user_id, $key, true ) );
    876884        }
    877885
    878886        /**
    879887         * @covers ::bbp_admin_repair_user_forum_subscriptions
    880          * @todo   Implement test_bbp_admin_repair_user_forum_subscriptions().
    881888         */
    882889        public function test_bbp_admin_repair_user_forum_subscriptions() {
    883                 // Remove the following lines when you implement this test.
    884                 $this->markTestIncomplete(
    885                         'This test has not been implemented yet.'
    886                 );
     890                $user_id = $this->factory->user->create();
     891                $live_id = $this->factory->forum->create();
     892                $old_id  = $this->factory->forum->create();
     893                $key     = bbp_db()->prefix . '_bbp_forum_subscriptions';
     894                wp_trash_post( $old_id );
     895                update_user_meta( $user_id, $key, "{$live_id},{$old_id}" );
     896
     897                $this->assertSame( 0, bbp_admin_repair_user_forum_subscriptions()[0] );
     898                $this->assertSame( (string) $live_id, get_user_meta( $user_id, $key, true ) );
    887899        }
    888900
Note: See TracChangeset for help on using the changeset viewer.