[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/tests/phpunit/includes/ -> factory.php (source)

   1  <?php
   2  
   3  class BBP_UnitTest_Factory extends WP_UnitTest_Factory {
   4  
   5      public $forum = null;
   6      public $topic = null;
   7      public $reply = null;
   8  
   9  	public function __construct() {
  10          parent::__construct();
  11  
  12          $this->forum = new BBP_UnitTest_Factory_For_Forum( $this );
  13          $this->topic = new BBP_UnitTest_Factory_For_Topic( $this );
  14          $this->reply = new BBP_UnitTest_Factory_For_Reply( $this );
  15      }
  16  }
  17  
  18  class BBP_UnitTest_Factory_For_Forum extends WP_UnitTest_Factory_For_Thing {
  19  
  20  	public function __construct( $factory = null ) {
  21          parent::__construct( $factory );
  22  
  23          $this->default_generation_definitions = array(
  24              'post_title'   => new WP_UnitTest_Generator_Sequence( 'Forum %s' ),
  25              'post_content' => new WP_UnitTest_Generator_Sequence( 'Content of Forum %s' ),
  26          );
  27      }
  28  
  29  	public function create_object( $args ) {
  30          $forum_meta = isset( $args['forum_meta'] ) ? $args['forum_meta'] : array();
  31          unset( $args['forum_meta'] );
  32          $forum_data = bbp_insert_forum( $args, $forum_meta );
  33          return $forum_data;
  34      }
  35  
  36  	public function update_object( $forum_id, $fields ) {
  37          $fields['forum_id'] = $forum_id;
  38          return bbp_update_forum( $fields );
  39      }
  40  
  41  	public function get_object_by_id( $forum_id ) {
  42          return bbp_get_forum( $forum_id );
  43      }
  44  }
  45  
  46  class BBP_UnitTest_Factory_For_Topic extends WP_UnitTest_Factory_For_Thing {
  47  
  48  	public function __construct( $factory = null ) {
  49          parent::__construct( $factory );
  50  
  51          $this->default_generation_definitions = array(
  52              'post_title'   => new WP_UnitTest_Generator_Sequence( 'Topic %s' ),
  53              'post_content' => new WP_UnitTest_Generator_Sequence( 'Content of Topic %s' ),
  54          );
  55      }
  56  
  57  	public function create_object( $args ) {
  58          $topic_meta = isset( $args['topic_meta'] ) ? $args['topic_meta'] : array();
  59          unset( $args['topic_meta'] );
  60          $topic_data = bbp_insert_topic( $args, $topic_meta );
  61          return $topic_data;
  62      }
  63  
  64  	public function update_object( $topic_id, $fields ) {
  65          $fields['topic_id'] = $topic_id;
  66          return bbp_update_topic( $fields );
  67      }
  68  
  69  	public function get_object_by_id( $topic_id ) {
  70          return bbp_get_topic( $topic_id );
  71      }
  72  }
  73  
  74  class BBP_UnitTest_Factory_For_Reply extends WP_UnitTest_Factory_For_Thing {
  75  
  76  	public function __construct( $factory = null ) {
  77          parent::__construct( $factory );
  78  
  79          $this->default_generation_definitions = array(
  80              'post_content' => new WP_UnitTest_Generator_Sequence( 'Content of Reply %s' ),
  81          );
  82      }
  83  
  84  	public function create_object( $args ) {
  85          $reply_meta = isset( $args['reply_meta'] ) ? $args['reply_meta'] : array();
  86          unset( $args['reply_meta'] );
  87          $reply_data = bbp_insert_reply( $args, $reply_meta );
  88          return $reply_data;
  89      }
  90  
  91  	public function update_object( $reply_id, $fields ) {
  92          $fields['reply_id'] = $reply_id;
  93          return bbp_update_reply( $fields );
  94      }
  95  
  96  	public function get_object_by_id( $reply_id ) {
  97          return bbp_get_reply( $reply_id );
  98      }
  99  }


Generated: Sat Apr 20 01:00:52 2024 Cross-referenced by PHPXref 0.7.1