Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (7 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/activity.php

    r10868 r11737  
    3030        }
    3131
    32         $b = $this->factory->blog->create();
    33         $u = $this->factory->user->create();
    34         $a = $this->factory->activity->create( array(
     32        $b = self::factory()->blog->create();
     33        $u = self::factory()->user->create();
     34        $a = self::factory()->activity->create( array(
    3535            'component' => buddypress()->blogs->id,
    3636            'type' => 'new_blog',
     
    5555        }
    5656
    57         $u = $this->factory->user->create();
    58         $p = $this->factory->post->create( array(
     57        $u = self::factory()->user->create();
     58        $p = self::factory()->post->create( array(
    5959            'post_author' => $u,
    6060        ) );
    61         $a = $this->factory->activity->create( array(
     61        $a = self::factory()->activity->create( array(
    6262            'component' => buddypress()->blogs->id,
    6363            'type' => 'new_blog_post',
     
    8989        }
    9090
    91         $u = $this->factory->user->create();
    92         $p = $this->factory->post->create( array(
     91        $u = self::factory()->user->create();
     92        $p = self::factory()->post->create( array(
    9393            'post_author' => $u,
    9494        ) );
    95         $a = $this->factory->activity->create( array(
     95        $a = self::factory()->activity->create( array(
    9696            'component' => buddypress()->blogs->id,
    9797            'type' => 'new_blog_post',
     
    123123        }
    124124
    125         $b = $this->factory->blog->create();
    126         $u = $this->factory->user->create();
     125        $b = self::factory()->blog->create();
     126        $u = self::factory()->user->create();
    127127
    128128        switch_to_blog( $b );
    129         $p = $this->factory->post->create( array(
     129        $p = self::factory()->post->create( array(
    130130            'post_author' => $u,
    131131        ) );
     
    133133        restore_current_blog();
    134134
    135         $a = $this->factory->activity->create( array(
     135        $a = self::factory()->activity->create( array(
    136136            'component' => buddypress()->blogs->id,
    137137            'type' => 'new_blog_post',
     
    164164        }
    165165
    166         $b = $this->factory->blog->create();
    167         $u = $this->factory->user->create();
     166        $b = self::factory()->blog->create();
     167        $u = self::factory()->user->create();
    168168
    169169        switch_to_blog( $b );
    170         $p = $this->factory->post->create( array(
     170        $p = self::factory()->post->create( array(
    171171            'post_author' => $u,
    172172        ) );
    173173        $p_obj = get_post( $p );
    174         $c = $this->factory->comment->create( array(
     174        $c = self::factory()->comment->create( array(
    175175            'comment_post_ID' => $p,
    176176        ) );
     
    178178        restore_current_blog();
    179179
    180         $a = $this->factory->activity->create( array(
     180        $a = self::factory()->activity->create( array(
    181181            'component' => buddypress()->blogs->id,
    182182            'type' => 'new_blog_comment',
     
    209209        add_filter( 'bp_blogs_activity_created_blog_action', array( $this, 'created_blog_passthrough' ), 10, 2 );
    210210
    211         $b = $this->factory->blog->create();
    212         $u = $this->factory->user->create();
     211        $b = self::factory()->blog->create();
     212        $u = self::factory()->user->create();
    213213
    214214        $recorded_blog          = new BP_Blogs_Blog;
     
    217217        $recorded_blog_id       = $recorded_blog->save();
    218218
    219         $a = $this->factory->activity->create( array(
     219        $a = self::factory()->activity->create( array(
    220220            'component' => buddypress()->blogs->id,
    221221            'type' => 'new_blog',
     
    237237        add_filter( 'bp_blogs_activity_new_post_action', array( $this, 'new_post_passthrough' ), 10, 2 );
    238238
    239         $b = $this->factory->blog->create();
     239        $b = self::factory()->blog->create();
    240240
    241241        switch_to_blog( $b );
    242         $p = $this->factory->post->create();
     242        $p = self::factory()->post->create();
    243243        restore_current_blog();
    244244
    245         $u = $this->factory->user->create();
    246         $a = $this->factory->activity->create( array(
     245        $u = self::factory()->user->create();
     246        $a = self::factory()->activity->create( array(
    247247            'component' => buddypress()->blogs->id,
    248248            'type' => 'new_blog_post',
     
    265265        add_filter( 'bp_blogs_activity_new_comment_action', array( $this, 'new_comment_passthrough' ), 10, 2 );
    266266
    267         $b = $this->factory->blog->create();
     267        $b = self::factory()->blog->create();
    268268
    269269        switch_to_blog( $b );
    270         $p = $this->factory->post->create();
    271         $c = $this->factory->comment->create( array(
     270        $p = self::factory()->post->create();
     271        $c = self::factory()->comment->create( array(
    272272            'comment_post_ID' => $p,
    273273        ) );
    274274        restore_current_blog();
    275275
    276         $u = $this->factory->user->create();
    277         $a = $this->factory->activity->create( array(
     276        $u = self::factory()->user->create();
     277        $a = self::factory()->activity->create( array(
    278278            'component' => buddypress()->blogs->id,
    279279            'type' => 'new_blog_comment',
     
    296296        }
    297297
    298         $u = $this->factory->user->create();
    299         $p = $this->factory->post->create( array( 'post_author' => $u, ) );
    300         $a = $this->factory->activity->create( array(
     298        $u = self::factory()->user->create();
     299        $p = self::factory()->post->create( array( 'post_author' => $u, ) );
     300        $a = self::factory()->activity->create( array(
    301301            'component'         => buddypress()->blogs->id,
    302302            'item_id'           => 1,
     
    322322        buddypress()->activity->actions = new stdClass();
    323323
    324         $u = $this->factory->user->create();
     324        $u = self::factory()->user->create();
    325325        $p = wp_insert_post( array(
    326326            'post_author' => $u,
     
    359359        buddypress()->activity->actions = new stdClass();
    360360
    361         $u = $this->factory->user->create();
     361        $u = self::factory()->user->create();
    362362        $p = wp_insert_post( array(
    363363            'post_author' => $u,
     
    409409    public function test_bp_blogs_sync_add_from_activity_comment() {
    410410        $old_user = get_current_user_id();
    411         $u = $this->factory->user->create();
     411        $u = self::factory()->user->create();
    412412        $this->set_current_user( $u );
    413413        $userdata = get_userdata( $u );
     
    417417
    418418        // create the blog post
    419         $post_id = $this->factory->post->create( array(
     419        $post_id = self::factory()->post->create( array(
    420420            'post_status' => 'publish',
    421421            'post_type'   => 'post',
     
    457457    public function test_bp_blogs_sync_delete_from_activity_comment() {
    458458        $old_user = get_current_user_id();
    459         $u = $this->factory->user->create();
     459        $u = self::factory()->user->create();
    460460        $this->set_current_user( $u );
    461461        $userdata = get_userdata( $u );
     
    465465
    466466        // create the blog post
    467         $post_id = $this->factory->post->create( array(
     467        $post_id = self::factory()->post->create( array(
    468468            'post_status' => 'publish',
    469469            'post_type'   => 'post',
     
    505505    public function test_bp_blogs_sync_activity_edit_to_post_comment_spam_unspam_activity_comment() {
    506506        $old_user = get_current_user_id();
    507         $u = $this->factory->user->create();
     507        $u = self::factory()->user->create();
    508508        $this->set_current_user( $u );
    509509        $userdata = get_userdata( $u );
     
    513513
    514514        // create the blog post
    515         $post_id = $this->factory->post->create( array(
     515        $post_id = self::factory()->post->create( array(
    516516            'post_status' => 'publish',
    517517            'post_type'   => 'post',
     
    565565    public function test_bp_blogs_sync_activity_edit_to_post_comment_spam_activity_comment_unspam_post_comment() {
    566566        $old_user = get_current_user_id();
    567         $u = $this->factory->user->create();
     567        $u = self::factory()->user->create();
    568568        $this->set_current_user( $u );
    569569        $userdata = get_userdata( $u );
     
    573573
    574574        // create the blog post
    575         $post_id = $this->factory->post->create( array(
     575        $post_id = self::factory()->post->create( array(
    576576            'post_status' => 'publish',
    577577            'post_type'   => 'post',
     
    623623    public function test_bp_blogs_sync_activity_edit_to_post_comment_trash_comment_ham_activity() {
    624624        $old_user = get_current_user_id();
    625         $u = $this->factory->user->create();
     625        $u = self::factory()->user->create();
    626626        $this->set_current_user( $u );
    627627        $userdata = get_userdata( $u );
     
    631631
    632632        // create the blog post
    633         $post_id = $this->factory->post->create( array(
     633        $post_id = self::factory()->post->create( array(
    634634            'post_status' => 'publish',
    635635            'post_type'   => 'post',
     
    680680    public function test_spammed_activity_comment_should_not_create_post_comment() {
    681681        $old_user = get_current_user_id();
    682         $u = $this->factory->user->create();
     682        $u = self::factory()->user->create();
    683683        $this->set_current_user( $u );
    684684        $userdata = get_userdata( $u );
     
    688688
    689689        // create the blog post.
    690         $post_id = $this->factory->post->create( array(
     690        $post_id = self::factory()->post->create( array(
    691691            'post_status' => 'publish',
    692692            'post_type'   => 'post',
Note: See TracChangeset for help on using the changeset viewer.