Skip to:
Content

bbPress.org

Changeset 6423


Ignore:
Timestamp:
05/23/2017 02:50:42 AM (7 years ago)
Author:
netweb
Message:

Tests: Improve test_bbp_get_forum_last_reply_id() test performance.

No need to query for the last reply ID as we already knew what to expect.t.

See #3108.
Props thebrandonallen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/forums/template/get-last-thing.php

    r5997 r6423  
    516516        ) );
    517517
    518 
    519         $f = $this->factory->forum->create( array(
    520             'post_parent' => $c,
    521             'forum_meta' => array(
    522                 'forum_id'   => $c,
    523                 'forum_type' => 'forum',
    524                 'status'     => 'open',
    525             ),
    526         ) );
    527 
    528         $t = $this->factory->topic->create( array(
    529             'post_parent' => $f,
    530             'topic_meta' => array(
    531                 'forum_id' => $f,
    532             ),
    533         ) );
    534 
    535         $this->factory->reply->create( array(
     518        $f = $this->factory->forum->create( array(
     519            'post_parent' => $c,
     520            'forum_meta' => array(
     521                'forum_id'   => $c,
     522                'forum_type' => 'forum',
     523                'status'     => 'open',
     524            ),
     525        ) );
     526
     527        $t = $this->factory->topic->create( array(
     528            'post_parent' => $f,
     529            'topic_meta' => array(
     530                'forum_id' => $f,
     531            ),
     532        ) );
     533
     534        $r1 = $this->factory->reply->create( array(
    536535            'post_parent' => $t,
    537536            'reply_meta' => array(
     
    543542        // Get the forums last reply id.
    544543        $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
    545         $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) );
     544        $this->assertSame( $r1, $last_reply_id_f );
    546545
    547546        // Get the categories last reply id.
    548547        $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
    549         $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) );
    550 
    551         $this->factory->reply->create( array(
     548        $this->assertSame( $r1, $last_reply_id_c );
     549
     550        $r2 = $this->factory->reply->create( array(
    552551            'post_parent' => $t,
    553552            'reply_meta' => array(
     
    559558        // Get the forums last reply id.
    560559        $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
    561         $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) );
     560        $this->assertSame( $r2, $last_reply_id_f );
    562561
    563562        // Get the categories last reply id.
    564563        $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
    565         $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) );
     564        $this->assertSame( $r2, $last_reply_id_c );
    566565    }
    567566
Note: See TracChangeset for help on using the changeset viewer.