Skip to:
Content

bbPress.org

Changeset 7799


Ignore:
Timestamp:
10/04/2026 09:14:39 AM (6 weeks ago)
Author:
johnjamesjacoby
Message:

Tests: Cover private group forum upgrades.

Remove a stub for the retired group-forum repair function and verify that its upgrade replacement remaps a legacy forum ID and hides a private group's forum.

In trunk, for 2.7.

See #3695.

Location:
trunk/tests/phpunit/testcases/admin
Files:
2 edited

Legend:

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

    r7798 r7799  
    351351                $count = bbp_get_topic_reply_count_hidden( $t, true );
    352352                $this->assertSame( 2, $count );
    353         }
    354 
    355         /**
    356          * @covers ::bbp_admin_repair_group_forum_relationship
    357          * @todo   Implement test_bbp_admin_repair_group_forum_relationship().
    358          */
    359         public function test_bbp_admin_repair_group_forum_relationship() {
    360                 // Remove the following lines when you implement this test.
    361                 $this->markTestIncomplete(
    362                         'This test has not been implemented yet.'
    363                 );
    364353        }
    365354
  • trunk/tests/phpunit/testcases/admin/upgrade-sql.php

    r7617 r7799  
    5252                $this->assertSame( 'unrelated', $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM `{$this->groupmeta_table}` WHERE group_id = %d", 2 ) ) );
    5353        }
     54
     55        /**
     56         * @covers ::bbp_admin_upgrade_group_forum_relationships
     57         */
     58        public function test_group_forum_upgrade_hides_private_group_forum() {
     59                global $wpdb;
     60
     61                $forum_id = $this->factory->forum->create();
     62                update_post_meta( $forum_id, '_bbp_old_forum_id', '42' );
     63                $wpdb->insert( $this->groups_table, array( 'id' => 7, 'status' => 'private' ) );
     64                $wpdb->insert( $this->groupmeta_table, array( 'group_id' => 7, 'meta_key' => 'forum_id', 'meta_value' => '42' ) );
     65
     66                $this->assertSame( 0, bbp_admin_upgrade_group_forum_relationships()[0] );
     67                $this->assertSame( (string) $forum_id, $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM `{$this->groupmeta_table}` WHERE group_id = %d", 7 ) ) );
     68                $this->assertSame( array( 7 ), get_post_meta( $forum_id, '_bbp_group_ids', true ) );
     69                $this->assertSame( bbp_get_hidden_status_id(), bbp_get_forum_visibility( $forum_id ) );
     70        }
    5471}
Note: See TracChangeset for help on using the changeset viewer.