Skip to:
Content

bbPress.org

Changeset 6194


Ignore:
Timestamp:
12/28/2016 11:14:27 AM (4 years ago)
Author:
netweb
Message:

Tests: Add favorite, topic subscriptions, and forum subscription upgrade tool tests.

  • BBP_Tests_Admin_Tools::test_bbp_admin_upgrade_user_favorites
  • BBP_Tests_Admin_Tools::test_bbp_admin_upgrade_user_topic_subscriptions
  • BBP_Tests_Admin_Tools::test_bbp_admin_upgrade_user_forum_subscriptions

See #2959.

File:
1 edited

Legend:

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

    r6009 r6194  
    699699
    700700    /**
     701     * @covers ::bbp_admin_upgrade_user_favorites
     702     */
     703    public function test_bbp_admin_upgrade_user_favorites() {
     704
     705        $u = $this->factory->user->create_many( 2 );
     706        $t = $this->factory->topic->create();
     707
     708        // Create 2.5.x user meta favorites
     709        update_user_option( $u[0], '_bbp_favorites', $t );
     710        update_user_option( $u[1], '_bbp_favorites', $t );
     711
     712        // Upgrade the user favorites.
     713        bbp_admin_upgrade_user_favorites();
     714
     715        $expected            = array( $u[0], $u[1] );
     716        $favoriters          = bbp_get_topic_favoriters( $t );
     717        $post_meta_favorites = get_post_meta( $t, '_bbp_favorite', false );
     718
     719        $this->assertEqualSets( $expected, $favoriters );
     720        $this->assertEqualSets( $expected, $post_meta_favorites );
     721    }
     722
     723    /**
     724     * @covers ::bbp_admin_upgrade_user_topic_subscriptions
     725     */
     726    public function test_bbp_admin_upgrade_user_topic_subscriptions() {
     727
     728        $u = $this->factory->user->create_many( 2 );
     729
     730        $f = $this->factory->forum->create();
     731
     732        $t = $this->factory->topic->create( array(
     733            'post_parent' => $f,
     734            'topic_meta' => array(
     735                'forum_id' => $f,
     736            ),
     737        ) );
     738
     739        // Create 2.5.x user meta topic subscriptions.
     740        update_user_option( $u[0], '_bbp_subscriptions', $t );
     741        update_user_option( $u[1], '_bbp_subscriptions', $t );
     742
     743        // Upgrade the user topic subscriptions.
     744        bbp_admin_upgrade_user_topic_subscriptions();
     745
     746        $expected            = array( $u[0], $u[1] );
     747        $topic_subscribers   = bbp_get_topic_subscribers( $t );
     748        $post_meta_topic_sub = get_post_meta( $t, '_bbp_subscription', false );
     749
     750        $this->assertEqualSets( $expected, $topic_subscribers );
     751        $this->assertEqualSets( $expected, $post_meta_topic_sub );
     752    }
     753
     754    /**
     755     * @covers ::bbp_admin_upgrade_user_forum_subscriptions
     756     */
     757    public function test_bbp_admin_upgrade_user_forum_subscriptions() {
     758
     759        $u = $this->factory->user->create_many( 2 );
     760
     761        $f = $this->factory->forum->create();
     762
     763        // Create 2.5.x user meta forum subscriptions.
     764        update_user_option( $u[0], '_bbp_forum_subscriptions', $f );
     765        update_user_option( $u[1], '_bbp_forum_subscriptions', $f );
     766
     767        // Upgrade the user forum subscriptions.
     768        bbp_admin_upgrade_user_forum_subscriptions();
     769
     770        $expected            = array( $u[0], $u[1] );
     771        $forum_subscribers   = bbp_get_forum_subscribers( $f );
     772        $post_meta_forum_sub = get_post_meta( $f, '_bbp_subscription', false );
     773
     774        $this->assertEqualSets( $expected, $forum_subscribers );
     775        $this->assertEqualSets( $expected, $post_meta_forum_sub );
     776    }
     777
     778    /**
    701779     * @covers ::bbp_admin_reset
    702780     * @todo   Implement test_bbp_admin_reset().
Note: See TracChangeset for help on using the changeset viewer.