Skip to:
Content

BuddyPress.org

Changeset 9510


Ignore:
Timestamp:
02/18/2015 01:51:43 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Unit test for bp_core_get_directory_pages(). Props r-a-y. See #6226 (2.2 branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/tests/phpunit/testcases/core/functions.php

    r9479 r9510  
    687687
    688688        bp_update_option( 'bp-pages', $v );
     689    }
     690
     691    /**
     692     * @group bp_core_get_directory_pages
     693     */
     694    public function test_bp_core_get_directory_pages_multisite_delete_post_with_same_bp_page_id() {
     695        if ( ! is_multisite() ) {
     696            return;
     697        }
     698
     699        $dir_pages = bp_core_get_directory_pages();
     700
     701        // create a blog
     702        $u = $this->factory->user->create();
     703        $b1 = $this->factory->blog->create( array( 'user_id' => $u ) );
     704
     705        // switch to blog and create some dummy posts until we reach a post ID that
     706        // matches our BP activity page ID
     707        switch_to_blog( $b1 );
     708        $p = $this->factory->post->create();
     709        while( $p <= $dir_pages->activity->id ) {
     710            $p = $this->factory->post->create();
     711        }
     712
     713        // delete the post that matches the BP activity page ID on this sub-site
     714        wp_delete_post( $dir_pages->activity->id, true );
     715
     716        // restore blog
     717        restore_current_blog();
     718
     719        // refetch BP directory pages
     720        $dir_pages = bp_core_get_directory_pages();
     721
     722        // Now verify that our BP activity page was not wiped out
     723        $this->assertNotEmpty( $dir_pages->activity );
    689724    }
    690725
Note: See TracChangeset for help on using the changeset viewer.