Skip to:
Content

bbPress.org


Ignore:
Timestamp:
04/07/2015 12:35:06 PM (11 years ago)
Author:
netweb
Message:

Add support for BuddyPress PHPUnit test integration

  • Bootstrap and load /src/bbpress.php when loading the test environment
  • Detect and load BuddyPress when running the BuddyPress PHPUnit tests
  • Setup BP_UnitTest_Factory in BBP_UnitTestCase during new BuddyPress PHPUnit test integration
  • Bootstrap and load new factory class BBP_UnitTest_Factory_For_Forum for creating forums

Props boonebgorges. See #2782

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory.php

    r5610 r5673  
    22
    33class BBP_UnitTest_Factory extends WP_UnitTest_Factory {
    4     function __construct() {
     4
     5    public $forum = null;
     6
     7    public function __construct() {
    58        parent::__construct();
     9
     10        $this->forum = new BBP_UnitTest_Factory_For_Forum( $this );
    611    }
    712}
     13
     14class BBP_UnitTest_Factory_For_Forum extends WP_UnitTest_Factory_For_Thing {
     15
     16    public function __construct( $factory = null ) {
     17        parent::__construct( $factory );
     18
     19        $this->default_generation_definitions = array(
     20            'post_title'   => new WP_UnitTest_Generator_Sequence( 'Forum %s' ),
     21            'post_content' => new WP_UnitTest_Generator_Sequence( 'Content of Forum %s' ),
     22        );
     23    }
     24
     25    public function create_object( $args ) {
     26        return bbp_insert_forum( $args );
     27    }
     28
     29    public function update_object( $forum_id, $fields ) {
     30        $fields['forum_id'] = $forum_id;
     31        return bbp_update_forum( $fields );
     32    }
     33
     34    public function get_object_by_id( $forum_id ) {
     35        return bbp_get_forum( $forum_id );
     36    }
     37}
Note: See TracChangeset for help on using the changeset viewer.