Skip to:
Content

bbPress.org

Changeset 6004


Ignore:
Timestamp:
04/18/2016 12:46:23 PM (10 years ago)
Author:
netweb
Message:

Tests: Include forum category and forum category meta in test_bbp_insert_forum()

This changeset improves bbp_insert_forum() testing using hierarchical category/forum (parent/child) forums post and post meta integrity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/forums/functions/forum.php

    r5947 r6004  
    1616    public function test_bbp_insert_forum() {
    1717
     18        $c = $this->factory->forum->create( array(
     19            'post_title' => 'Category 1',
     20            'post_content' => 'Content of Category 1',
     21            'forum_meta' => array(
     22                'forum_type' => 'category',
     23                'status'     => 'open',
     24            ),
     25        ) );
     26
    1827        $f = $this->factory->forum->create( array(
    1928            'post_title' => 'Forum 1',
    2029            'post_content' => 'Content of Forum 1',
     30            'post_parent' => $c,
     31            'forum_meta' => array(
     32                'forum_id'   => $c,
     33                'forum_type' => 'forum',
     34                'status'     => 'open',
     35            ),
    2136        ) );
    2237
     
    4156        ) );
    4257
     58        // Get the category.
     59        $category = bbp_get_forum( $c );
     60
    4361        // Get the forum.
    4462        $forum = bbp_get_forum( $f );
     63
     64        // Category post.
     65        $this->assertSame( 'Category 1', bbp_get_forum_title( $c ) );
     66        $this->assertSame( 'Content of Category 1', bbp_get_forum_content( $c ) );
     67        $this->assertSame( 'open', bbp_get_forum_status( $c ) );
     68        $this->assertSame( 'category', bbp_get_forum_type( $c ) );
     69        $this->assertTrue( bbp_is_forum( $c ) );
     70        $this->assertTrue( bbp_is_forum_category( $c ) );
     71        $this->assertTrue( bbp_is_forum_open( $c ) );
     72        $this->assertTrue( bbp_is_forum_public( $c ) );
     73        $this->assertFalse( bbp_is_forum_closed( $c ) );
     74        $this->assertFalse( bbp_is_forum_hidden( $c ) );
     75        $this->assertFalse( bbp_is_forum_private( $c ) );
     76        $this->assertSame( 0, bbp_get_forum_parent_id( $c ) );
     77        $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name, $category->guid );
    4578
    4679        // Forum post.
     
    4982        $this->assertSame( 'open', bbp_get_forum_status( $f ) );
    5083        $this->assertSame( 'forum', bbp_get_forum_type( $f ) );
     84        $this->assertTrue( bbp_is_forum( $f ) );
     85        $this->assertTrue( bbp_is_forum_open( $f ) );
    5186        $this->assertTrue( bbp_is_forum_public( $f ) );
    52         $this->assertSame( 0, bbp_get_forum_parent_id( $f ) );
    53         $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?forum=' . $forum->post_name, $forum->guid );
     87        $this->assertFalse( bbp_is_forum_closed( $f ) );
     88        $this->assertFalse( bbp_is_forum_hidden( $f ) );
     89        $this->assertFalse( bbp_is_forum_private( $f ) );
     90        $this->assertSame( $c, bbp_get_forum_parent_id( $f ) );
     91        $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/?forum=' . $category->post_name . '/' . $forum->post_name, $forum->guid );
     92
     93        // Category meta.
     94        $this->assertSame( 1, bbp_get_forum_subforum_count( $c, true ) );
     95        $this->assertSame( 0, bbp_get_forum_topic_count( $c, false, true ) );
     96        $this->assertSame( 1, bbp_get_forum_topic_count( $c, true, true ) );
     97        $this->assertSame( 0, bbp_get_forum_topic_count_hidden( $c, true ) );
     98        $this->assertSame( 0, bbp_get_forum_reply_count( $c, false, true ) );
     99        $this->assertSame( 1, bbp_get_forum_reply_count( $c, true, true ) );
     100        $this->assertSame( 0, bbp_get_forum_post_count( $c, false, true ) );
     101        $this->assertSame( 2, bbp_get_forum_post_count( $c, true, true ) );
     102        $this->assertSame( $t, bbp_get_forum_last_topic_id( $c ) );
     103        $this->assertSame( $r, bbp_get_forum_last_reply_id( $c ) );
     104        $this->assertSame( $r, bbp_get_forum_last_active_id( $c ) );
     105        $this->assertSame( '4 days, 4 hours ago', bbp_get_forum_last_active_time( $c ) );
    54106
    55107        // Forum meta.
     
    60112        $this->assertSame( 1, bbp_get_forum_reply_count( $f, false, true ) );
    61113        $this->assertSame( 1, bbp_get_forum_reply_count( $f, true, true ) );
     114
    62115        $this->assertSame( 2, bbp_get_forum_post_count( $f, false, true ) );
    63116        $this->assertSame( 2, bbp_get_forum_post_count( $f, true, true ) );
Note: See TracChangeset for help on using the changeset viewer.