Skip to:
Content

bbPress.org

Changeset 5965


Ignore:
Timestamp:
12/21/2015 08:07:42 AM (10 years ago)
Author:
netweb
Message:

Tests: Add a parent forum category for each test in ::BBP_Tests_Forums_Template_Forum_Last_Thing

This changeset adds a parent category forum for each forum test to ensure hierarchal forum assertions are tested with parent/child forum relationships for the bbp_get_forum_last_*() template functions.

File:
1 edited

Legend:

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

    r5947 r5965  
    1515     */
    1616    public function test_bbp_get_forum_last_active_id() {
    17         $f = $this->factory->forum->create();
    18 
    19         $last_id = bbp_get_forum_last_active_id( $f );
     17        $c = $this->factory->forum->create();
     18
     19        $f = $this->factory->forum->create( array(
     20            'post_parent' => $c,
     21            'forum_meta' => array(
     22                'forum_id'        => $c,
     23                '_bbp_forum_type' => 'forum',
     24                '_bbp_status'     => 'open',
     25            ),
     26        ) );
     27
     28        // Get the forums last active id.
     29        $last_id = bbp_get_forum_last_active_id( $f );
     30        $this->assertSame( 0, $last_id );
     31
     32        // Get the categories last active id.
     33        $last_id = bbp_get_forum_last_active_id( $c );
    2034        $this->assertSame( 0, $last_id );
    2135
    2236        bbp_update_forum_last_active_id( $f );
    2337
    24         $last_id = bbp_get_forum_last_active_id( $f );
     38        // Get the forums last active id.
     39        $last_id = bbp_get_forum_last_active_id( $f );
     40        $this->assertSame( 0, $last_id );
     41
     42        // Get the categories last active id.
     43        $last_id = bbp_get_forum_last_active_id( $c );
    2544        $this->assertSame( 0, $last_id );
    2645
     
    3453        bbp_update_forum_last_active_id( $f );
    3554
     55        // Get the forums last active id.
    3656        $last_id = bbp_get_forum_last_active_id( $f );
    3757        $this->assertSame( $t, $last_id );
    3858
     59        // Get the categories last active id.
     60        $last_id = bbp_get_forum_last_active_id( $c );
     61        $this->assertSame( $t, $last_id );
     62
    3963        $r = $this->factory->reply->create( array(
    4064            'post_parent' => $t,
     
    4771        bbp_update_forum_last_active_id( $f );
    4872
    49         $last_id = bbp_get_forum_last_active_id( $f );
     73        // Get the forums last active id.
     74        $last_id = bbp_get_forum_last_active_id( $f );
     75        $this->assertSame( $r, $last_id );
     76
     77        // Get the categories last active id.
     78        $last_id = bbp_get_forum_last_active_id( $c );
    5079        $this->assertSame( $r, $last_id );
    5180    }
     
    5786    public function test_bbp_get_forum_last_active_id_with_pending_reply() {
    5887        $u = $this->factory->user->create_many( 2 );
    59         $f = $this->factory->forum->create();
    60 
    61         $last_id = bbp_get_forum_last_active_id( $f );
     88
     89        $c = $this->factory->forum->create();
     90
     91        $f = $this->factory->forum->create( array(
     92            'post_parent' => $c,
     93            'forum_meta' => array(
     94                'forum_id'        => $c,
     95                '_bbp_forum_type' => 'forum',
     96                '_bbp_status'     => 'open',
     97            ),
     98        ) );
     99
     100        // Get the forums last active id.
     101        $last_id = bbp_get_forum_last_active_id( $f );
     102        $this->assertSame( 0, $last_id );
     103
     104        // Get the categories last active id.
     105        $last_id = bbp_get_forum_last_active_id( $c );
    62106        $this->assertSame( 0, $last_id );
    63107
    64108        bbp_update_forum_last_active_id( $f );
    65109
    66         $last_id = bbp_get_forum_last_active_id( $f );
     110        // Get the forums last active id.
     111        $last_id = bbp_get_forum_last_active_id( $f );
     112        $this->assertSame( 0, $last_id );
     113
     114        // Get the categories last active id.
     115        $last_id = bbp_get_forum_last_active_id( $c );
    67116        $this->assertSame( 0, $last_id );
    68117
     
    76125        bbp_update_forum_last_active_id( $f );
    77126
     127        // Get the forums last active id.
    78128        $last_id = bbp_get_forum_last_active_id( $f );
    79129        $this->assertSame( $t, $last_id );
    80130
     131        // Get the categories last active id.
     132        $last_id = bbp_get_forum_last_active_id( $c );
     133        $this->assertSame( $t, $last_id );
     134
    81135        $r1 = $this->factory->reply->create( array(
    82136            'post_parent' => $t,
     
    89143        bbp_update_forum_last_active_id( $f );
    90144
    91         $last_id = bbp_get_forum_last_active_id( $f );
     145        // Get the forums last active id.
     146        $last_id = bbp_get_forum_last_active_id( $f );
     147        $this->assertSame( $r1, $last_id );
     148
     149        // Get the categories last active id.
     150        $last_id = bbp_get_forum_last_active_id( $c );
     151
    92152        $this->assertSame( $r1, $last_id );
    93153
     
    102162        ) );
    103163
     164        // Get the forums last active id.
    104165        $last_id = bbp_get_forum_last_active_id( $f );
    105166        $this->assertSame( $r1, $last_id );
    106167
     168        // Get the categories last active id.
     169        $last_id = bbp_get_forum_last_active_id( $c );
     170        $this->assertSame( $r1, $last_id );
     171
    107172        bbp_approve_reply( $r2 );
    108173
    109         $last_id = bbp_get_forum_last_active_id( $f );
     174        // Get the forums last active id.
     175        $last_id = bbp_get_forum_last_active_id( $f );
     176        $this->assertSame( $r2, $last_id );
     177
     178        // Get the categories last active id.
     179        $last_id = bbp_get_forum_last_active_id( $c );
    110180        $this->assertSame( $r2, $last_id );
    111181    }
     
    116186     */
    117187    public function test_bbp_get_forum_last_active_time() {
    118         $f = $this->factory->forum->create();
     188        $c = $this->factory->forum->create();
     189
     190        $f = $this->factory->forum->create( array(
     191            'post_parent' => $c,
     192            'forum_meta' => array(
     193                'forum_id'        => $c,
     194                '_bbp_forum_type' => 'forum',
     195                '_bbp_status'     => 'open',
     196            ),
     197        ) );
    119198
    120199        $now = time();
    121         $post_date = date( 'Y-m-d H:i:s', $now - 60*60*100 );
    122 
     200        $post_date = date( 'Y-m-d H:i:s', $now - 60 * 60 * 100 );
     201
     202        // Get the forums last active time.
    123203        $last_time = bbp_get_forum_last_active_time( $f );
    124204        $this->assertSame( '', $last_time );
    125205
     206        // Get the categories last active time.
     207        $last_time = bbp_get_forum_last_active_time( $c );
     208        $this->assertSame( '', $last_time );
     209
    126210        $t = $this->factory->topic->create( array(
    127211            'post_parent' => $f,
     
    133217
    134218        bbp_update_forum_last_active_time( $f );
     219
     220        // Get the forums last active time.
    135221        $last_time = bbp_get_forum_last_active_time( $f );
    136222        $this->assertSame( '4 days, 4 hours ago', $last_time );
    137223
     224        // Get the categories last active time.
     225        $last_time = bbp_get_forum_last_active_time( $c );
     226        $this->assertSame( '4 days, 4 hours ago', $last_time );
     227
    138228        $this->factory->reply->create( array(
    139229            'post_parent' => $t,
     
    147237        bbp_update_forum_last_active_time( $f );
    148238
     239        // Get the forums last active time.
    149240        $last_time = bbp_get_forum_last_active_time( $f );
    150241        $this->assertSame( '4 days, 4 hours ago', $last_time );
     242
     243        // Get the categories last active time.
     244        $last_time = bbp_get_forum_last_active_time( $c );
     245        $this->assertSame( '4 days, 4 hours ago', $last_time );
    151246    }
    152247
     
    156251     */
    157252    public function test_bbp_get_forum_last_topic_id() {
    158         $f = $this->factory->forum->create();
    159 
     253        $c = $this->factory->forum->create();
     254
     255        $f = $this->factory->forum->create( array(
     256            'post_parent' => $c,
     257            'forum_meta' => array(
     258                'forum_id'        => $c,
     259                '_bbp_forum_type' => 'forum',
     260                '_bbp_status'     => 'open',
     261            ),
     262        ) );
     263
     264        // Get the forums last topic id.
    160265        $last_id = bbp_get_forum_last_topic_id( $f );
    161266        $this->assertSame( 0, $last_id );
    162267
     268        // Get the categories last topic id.
     269        $last_id = bbp_get_forum_last_topic_id( $c );
     270        $this->assertSame( 0, $last_id );
     271
    163272        bbp_update_forum_last_topic_id( $f );
    164273
     274        // Get the forums last topic id.
    165275        $last_id = bbp_get_forum_last_topic_id( $f );
    166276        $this->assertSame( 0, $last_id );
    167277
     278        // Get the categories last topic id.
     279        $last_id = bbp_get_forum_last_topic_id( $c );
     280        $this->assertSame( 0, $last_id );
     281
    168282        $t = $this->factory->topic->create( array(
    169283            'post_parent' => $f,
     
    175289        bbp_update_forum_last_topic_id( $f );
    176290
     291        // Get the forums last topic id.
    177292        $last_id = bbp_get_forum_last_topic_id( $f );
    178293        $this->assertSame( $t, $last_id );
     294
     295        // Get the categories last topic id.
     296        $last_id = bbp_get_forum_last_topic_id( $c );
     297        $this->assertSame( $t, $last_id );
    179298    }
    180299
     
    184303     */
    185304    public function test_bbp_get_forum_last_topic_title() {
    186         $f = $this->factory->forum->create();
     305        $c = $this->factory->forum->create();
     306
     307        $f = $this->factory->forum->create( array(
     308            'post_parent' => $c,
     309            'forum_meta' => array(
     310                'forum_id'        => $c,
     311                '_bbp_forum_type' => 'forum',
     312                '_bbp_status'     => 'open',
     313            ),
     314        ) );
    187315
    188316        $t = $this->factory->topic->create( array(
     
    202330        ) );
    203331
     332        // Get the forums last topic title.
    204333        $forum = bbp_get_forum_last_topic_title( $f );
    205334        $this->assertSame( 'Topic 1', $forum );
     335
     336        // Get the categories last topic title.
     337        $category = bbp_get_forum_last_topic_title( $c );
     338        $this->assertSame( 'Topic 1', $category );
    206339    }
    207340
     
    212345    public function test_bbp_get_forum_last_topic_permalink() {
    213346        if ( is_multisite() ) {
    214             $this->markTestSkipped( 'Skipping URL tests in multiste for now.' );
     347            $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
    215348        }
    216349
    217         $f = $this->factory->forum->create();
     350        $c = $this->factory->forum->create();
     351
     352        $f = $this->factory->forum->create( array(
     353            'post_parent' => $c,
     354            'forum_meta' => array(
     355                'forum_id'        => $c,
     356                '_bbp_forum_type' => 'forum',
     357                '_bbp_status'     => 'open',
     358            ),
     359        ) );
    218360
    219361        $t = $this->factory->topic->create( array(
     
    224366        ) );
    225367
     368        // Get the forums last topic permalink.
    226369        $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $f );
    227370        $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink );
     371
     372        // Get the categories last topic permalink.
     373        $forum_last_topic_permalink = bbp_get_forum_last_topic_permalink( $c );
     374        $this->assertSame( bbp_get_topic_permalink( $t ), $forum_last_topic_permalink );
    228375    }
    229376
     
    234381        $u = $this->factory->user->create();
    235382
    236         $f = $this->factory->forum->create( array(
    237             'post_author' => $u,
     383        $c = $this->factory->forum->create();
     384
     385        $f = $this->factory->forum->create( array(
     386            'post_author' => $u,
     387            'post_parent' => $c,
     388            'forum_meta' => array(
     389                'forum_id'        => $c,
     390                '_bbp_forum_type' => 'forum',
     391                '_bbp_status'     => 'open',
     392            ),
    238393        ) );
    239394
     
    255410        ) );
    256411
     412        // Get the forums last author id.
    257413        $forum = bbp_get_forum_last_topic_author_id( $f );
     414        $this->assertSame( $u, $forum );
     415
     416        // Get the categories last author id.
     417        $forum = bbp_get_forum_last_topic_author_id( $c );
    258418        $this->assertSame( $u, $forum );
    259419    }
     
    264424    public function test_bbp_get_forum_last_topic_author_link() {
    265425        if ( is_multisite() ) {
    266             $this->markTestSkipped( 'Skipping URL tests in multiste for now.' );
     426            $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
    267427        }
    268428
    269429        $u = $this->factory->user->create();
    270430
    271         $f = $this->factory->forum->create();
     431        $c = $this->factory->forum->create();
     432
     433        $f = $this->factory->forum->create( array(
     434            'post_parent' => $c,
     435            'forum_meta' => array(
     436                'forum_id'        => $c,
     437                '_bbp_forum_type' => 'forum',
     438                '_bbp_status'     => 'open',
     439            ),
     440        ) );
    272441
    273442        $t = $this->factory->topic->create( array(
     
    279448        ) );
    280449
     450        // Get the forums last topic author link.
    281451        $last_topic_author_link = bbp_get_forum_last_topic_author_link( $f );
    282452        $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link );
     453
     454        // Get the categories last topic author link.
     455        $last_topic_author_link = bbp_get_forum_last_topic_author_link( $c );
     456        $this->assertSame( bbp_get_user_profile_link( $u ), $last_topic_author_link );
    283457    }
    284458
     
    288462     */
    289463    public function test_bbp_get_forum_last_reply_id() {
    290         $f = $this->factory->forum->create();
     464        $c = $this->factory->forum->create();
     465
     466        $f = $this->factory->forum->create( array(
     467            'post_parent' => $c,
     468            'forum_meta' => array(
     469                'forum_id'        => $c,
     470                '_bbp_forum_type' => 'forum',
     471                '_bbp_status'     => 'open',
     472            ),
     473        ) );
    291474
    292475        $t = $this->factory->topic->create( array(
     
    305488        ) );
    306489
    307         $last_reply_id = bbp_get_forum_last_reply_id( $f );
    308 
    309         $this->assertSame( $last_reply_id, bbp_forum_query_last_reply_id( $f ) );
    310 
    311         bbp_get_forum_last_reply_id( $f );
     490        // Get the forums last reply id.
     491        $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
     492        $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) );
     493
     494        // Get the categories last reply id.
     495        $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
     496        $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) );
    312497
    313498        $this->factory->reply->create( array(
     
    319504        ) );
    320505
    321         $last_reply_id = bbp_get_forum_last_reply_id( $f );
    322 
    323         bbp_get_forum_last_reply_id( $f );
    324         $this->assertSame( $last_reply_id, bbp_forum_query_last_reply_id( $f ) );
    325 
     506        // Get the forums last reply id.
     507        $last_reply_id_f = bbp_get_forum_last_reply_id( $f );
     508        $this->assertSame( $last_reply_id_f, bbp_forum_query_last_reply_id( $f ) );
     509
     510        // Get the categories last reply id.
     511        $last_reply_id_c = bbp_get_forum_last_reply_id( $c );
     512        $this->assertSame( $last_reply_id_c, bbp_forum_query_last_reply_id( $c ) );
    326513    }
    327514
     
    331518     */
    332519    public function test_bbp_get_forum_last_reply_title() {
    333         $f = $this->factory->forum->create();
     520        $c = $this->factory->forum->create();
     521
     522        $f = $this->factory->forum->create( array(
     523            'post_parent' => $c,
     524            'forum_meta' => array(
     525                'forum_id'        => $c,
     526                '_bbp_forum_type' => 'forum',
     527                '_bbp_status'     => 'open',
     528            ),
     529        ) );
    334530
    335531        $t = $this->factory->topic->create( array(
     
    349545        ) );
    350546
     547        // Get the forums last reply title.
    351548        $forum = bbp_get_forum_last_reply_title( $f );
    352549        $this->assertSame( 'Reply To: Topic 1', $forum );
     550
     551        // Get the categories last reply title.
     552        $category = bbp_get_forum_last_reply_title( $c );
     553        $this->assertSame( 'Reply To: Topic 1', $category );
    353554    }
    354555
     
    384585        $u = $this->factory->user->create();
    385586
    386         $f = $this->factory->forum->create( array(
    387             'post_author' => $u,
     587        $c = $this->factory->forum->create();
     588
     589        $f = $this->factory->forum->create( array(
     590            'post_author' => $u,
     591            'post_parent' => $c,
     592            'forum_meta' => array(
     593                'forum_id'        => $c,
     594                '_bbp_forum_type' => 'forum',
     595                '_bbp_status'     => 'open',
     596            ),
    388597        ) );
    389598
     
    405614        ) );
    406615
    407         $last_reply_id = bbp_get_topic_last_active_id( $f );
    408         $this->assertSame( $r, $last_reply_id );
    409 
     616        // Get the forums last reply author id.
    410617        $forum = bbp_get_forum_last_reply_author_id( $f );
    411618        $this->assertSame( $u, $forum );
     619
     620        // Get the categories last reply author id.
     621        $category = bbp_get_forum_last_reply_author_id( $c );
     622        $this->assertSame( $u, $category );
    412623    }
    413624
     
    418629    public function test_bbp_get_forum_last_reply_author_link() {
    419630        if ( is_multisite() ) {
    420             $this->markTestSkipped( 'Skipping URL tests in multiste for now.' );
     631            $this->markTestSkipped( 'Skipping URL tests in multisite for now.' );
    421632        }
    422633
    423634        $u = $this->factory->user->create();
    424635
    425         $f = $this->factory->forum->create();
     636        $c = $this->factory->forum->create();
     637
     638        $f = $this->factory->forum->create( array(
     639            'post_author' => $u,
     640            'post_parent' => $c,
     641            'forum_meta' => array(
     642                'forum_id'        => $c,
     643                '_bbp_forum_type' => 'forum',
     644                '_bbp_status'     => 'open',
     645            ),
     646        ) );
    426647
    427648        $t = $this->factory->topic->create( array(
     
    442663        ) );
    443664
     665        // Get the forums last reply author link.
    444666        $last_reply_author_link = bbp_get_forum_last_reply_author_link( $f );
     667        $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link );
     668
     669        // Get the categories last reply author link.
     670        $last_reply_author_link = bbp_get_forum_last_reply_author_link( $c );
    445671        $this->assertSame( bbp_get_user_profile_link( $u ), $last_reply_author_link );
    446672    }
     
    455681     */
    456682    public function test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id() {
    457 
    458         $f = $this->factory->forum->create();
    459 
    460         // Get the forums last topic id _bbp_last_topic_id
     683        $c = $this->factory->forum->create();
     684
     685        $f = $this->factory->forum->create( array(
     686            'post_parent' => $c,
     687            'forum_meta' => array(
     688                'forum_id'        => $c,
     689                '_bbp_forum_type' => 'forum',
     690                '_bbp_status'     => 'open',
     691            ),
     692        ) );
     693
     694        // Get the forums last topic id _bbp_last_topic_id.
    461695        $this->assertSame( 0, bbp_get_forum_last_topic_id( $f ) );
    462696
    463         // Get the forums last reply id _bbp_last_reply_id
     697        // Get the category last topic id _bbp_last_topic_id.
     698        $this->assertSame( 0, bbp_get_forum_last_topic_id( $c ) );
     699
     700        // Get the forums last reply id _bbp_last_reply_id.
    464701        $this->assertSame( 0, bbp_get_forum_last_reply_id( $f ) );
    465702
     703        // Get the category last reply id _bbp_last_reply_id.
     704        $this->assertSame( 0, bbp_get_forum_last_reply_id( $c ) );
     705
    466706        $t = $this->factory->topic->create( array(
    467707            'post_parent' => $f,
     
    471711        ) );
    472712
    473         // Get the forums last topic id _bbp_last_topic_id
     713        // Get the forums last topic id _bbp_last_topic_id.
    474714        $this->assertSame( $t, bbp_get_forum_last_topic_id( $f ) );
    475715
    476         // Get the topics last reply id _bbp_last_reply_id
    477         $this->assertSame( 0, bbp_get_topic_last_reply_id( $t ) );
    478 
    479         // Create another reply
     716        // Get the category last topic id _bbp_last_topic_id.
     717        $this->assertSame( $t, bbp_get_forum_last_topic_id( $c ) );
     718
     719        // Create another reply.
    480720        $r = $this->factory->reply->create( array(
    481721            'post_parent' => $t,
     
    486726        ) );
    487727
    488         // Get the forums last reply id _bbp_last_reply_id
     728        // Get the forums last reply id _bbp_last_reply_id.
    489729        $this->assertSame( $r, bbp_get_forum_last_reply_id( $f ) );
    490730
    491         // Get the topics last reply id _bbp_last_reply_id
     731        // Get the category last reply id _bbp_last_reply_id.
     732        $this->assertSame( $r, bbp_get_forum_last_reply_id( $c ) );
     733
     734        // Get the topics last reply id _bbp_last_reply_id.
    492735        $this->assertSame( $r, bbp_get_topic_last_reply_id( $t ) );
    493736    }
Note: See TracChangeset for help on using the changeset viewer.