Skip to:
Content

BuddyPress.org

Ticket #6226: 6226.unit-test.patch

File 6226.unit-test.patch, 1.4 KB (added by r-a-y, 11 years ago)

Corresponding unit test for #6226.

  • tests/phpunit/testcases/core/functions.php

     
    689689        }
    690690
    691691        /**
     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 );
     724        }
     725
     726        /**
    692727         * @group bp_core_get_root_options
    693728         */
    694729        public function test_bp_core_get_root_options_cache_invalidate() {