Skip to:
Content

BuddyPress.org

Changeset 11880


Ignore:
Timestamp:
03/04/2018 07:55:02 PM (7 years ago)
Author:
r-a-y
Message:

Unit Tests: Improve performance of multisite directory page test.

The unit test in question was introduced in #6226.

Basically, the test needed to match a specific WordPress post ID.
Previously, the test did this by creating posts in a loop(!) until it
matched the post ID. However, there is a parameter in wp_insert_post()
that allows you to set the post ID from the get-go - 'import_id'.

This commit switches to using the 'import_id' parameter to create the
WordPress post and should speed up this test considerably.

Fixes #7709.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php

    r11737 r11880  
    266266        $b1 = self::factory()->blog->create( array( 'user_id' => $u ) );
    267267
    268         // switch to blog and create some dummy posts until we reach a post ID that
    269         // matches our BP activity page ID
     268        // Switch to blog and create a post with the same BP activity page ID.
    270269        switch_to_blog( $b1 );
    271         $p = self::factory()->post->create();
    272         while( $p <= $dir_pages->activity->id ) {
    273             $p = self::factory()->post->create();
    274         }
     270        $p = self::factory()->post->create( array(
     271            'import_id' => $dir_pages->activity->id
     272        ) );
    275273
    276274        // delete the post that matches the BP activity page ID on this sub-site
Note: See TracChangeset for help on using the changeset viewer.