Skip to:
Content

BuddyPress.org

Ticket #6128: 6128.pertest.patch

File 6128.pertest.patch, 9.5 KB (added by imath, 7 years ago)
  • tests/phpunit/testcases/activity/actions.php

    diff --git tests/phpunit/testcases/activity/actions.php tests/phpunit/testcases/activity/actions.php
    index 799a8fe..c21a5f7 100644
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    2323         */
    2424        public function test_bp_activity_catch_transition_post_type_status_publish() {
    2525                $bp = buddypress();
     26                $activity_actions = $bp->activity->actions;
     27                $bp->activity->actions = new stdClass();
    2628
    2729                register_post_type( 'foo', array(
    2830                        'label'   => 'foo',
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    4345                _unregister_post_type( 'foo' );
    4446
    4547                // Reset globals
    46                 unset( $bp->activity->actions->activity->new_foo );
     48                $bp->activity->actions = $activity_actions;
    4749                $bp->activity->track = array();
    4850        }
    4951
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    5355         */
    5456        public function test_bp_activity_catch_transition_post_type_status_publish_to_publish() {
    5557                $bp = buddypress();
     58                $activity_actions = $bp->activity->actions;
     59                $bp->activity->actions = new stdClass();
    5660
    5761                register_post_type( 'foo', array(
    5862                        'label'   => 'foo',
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    8387                _unregister_post_type( 'foo' );
    8488
    8589                // Reset globals
    86                 unset( $bp->activity->actions->activity->new_foo );
     90                $bp->activity->actions = $activity_actions;
    8791                $bp->activity->track = array();
    8892        }
    8993
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    9397         */
    9498        public function test_bp_activity_catch_transition_post_type_status_publish_password() {
    9599                $bp = buddypress();
     100                $activity_actions = $bp->activity->actions;
     101                $bp->activity->actions = new stdClass();
    96102
    97103                register_post_type( 'foo', array(
    98104                        'label'   => 'foo',
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    121127                _unregister_post_type( 'foo' );
    122128
    123129                // Reset globals
    124                 unset( $bp->activity->actions->activity->new_foo );
     130                $bp->activity->actions = $activity_actions;
    125131                $bp->activity->track = array();
    126132        }
    127133
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    131137         */
    132138        public function test_bp_activity_catch_transition_post_type_status_publish_trash() {
    133139                $bp = buddypress();
     140                $activity_actions = $bp->activity->actions;
     141                $bp->activity->actions = new stdClass();
    134142
    135143                register_post_type( 'foo', array(
    136144                        'label'   => 'foo',
    class BP_Tests_Activity_Actions extends BP_UnitTestCase { 
    156164                _unregister_post_type( 'foo' );
    157165
    158166                // Reset globals
    159                 unset( $bp->activity->actions->activity->new_foo );
     167                $bp->activity->actions = $activity_actions;
    160168                $bp->activity->track = array();
    161169        }
    162170
  • tests/phpunit/testcases/activity/functions.php

    diff --git tests/phpunit/testcases/activity/functions.php tests/phpunit/testcases/activity/functions.php
    index 4f8cad6..2b32c7f 100644
    Bar!'; 
    586586                }
    587587
    588588                $bp = buddypress();
     589                $activity_actions = $bp->activity->actions;
     590                $bp->activity->actions = new stdClass();
    589591
    590592                register_post_type( 'foo', array(
    591593                        'label'   => 'foo',
    Bar!'; 
    624626                _unregister_post_type( 'foo' );
    625627
    626628                // Reset globals
    627                 unset( $bp->activity->actions->activity->new_foo );
     629                $bp->activity->actions = $activity_actions;
    628630                $bp->activity->track = array();
    629631        }
    630632
    Bar!'; 
    639641                }
    640642
    641643                $bp = buddypress();
     644                $activity_actions = $bp->activity->actions;
     645                $bp->activity->actions = new stdClass();
    642646
    643647                $b = $this->factory->blog->create();
    644648                $u = $this->factory->user->create();
    Bar!'; 
    687691                $this->assertSame( $expected, $a_obj->action );
    688692
    689693                // Reset globals
    690                 unset( $bp->activity->actions->activity->new_foo );
     694                $bp->activity->actions = $activity_actions;
    691695                $bp->activity->track = array();
    692696        }
    693697
    Bar!'; 
    696700         * @group bp_activity_get_actions
    697701         */
    698702        public function test_bp_activity_get_actions_should_sort_by_position() {
    699                 $old_actions = bp_activity_get_actions();
    700                 buddypress()->activity->actions = new stdClass;
     703                $bp = buddypress();
     704                $old_actions = $bp->activity->actions;
     705                $bp->activity->actions = new stdClass;
    701706
    702707                register_post_type( 'foo5', array(
    703708                        'public'      => true,
    Bar!'; 
    739744                $foo_actions = (array) $actions->foo;
    740745                $this->assertEquals( $expected, array_values( wp_list_pluck( $foo_actions, 'key' ) ) );
    741746
    742                 buddypress()->activity->actions = $old_actions;
     747                $bp->activity->actions = $old_actions;
    743748        }
    744749
    745750        /**
    Bar!'; 
    752757                }
    753758
    754759                $bp = buddypress();
     760                $activity_actions = $bp->activity->actions;
     761                $bp->activity->actions = new stdClass();
    755762
    756763                $labels = array(
    757764                        'name'                 => 'bars',
    Bar!'; 
    798805                _unregister_post_type( 'foo' );
    799806
    800807                // Reset globals
    801                 unset( $bp->activity->actions->activity->foo_bar );
     808                $bp->activity->actions = $activity_actions;
    802809                $bp->activity->track = array();
    803810        }
    804811
    Bar!'; 
    814821
    815822                $bp = buddypress();
    816823                $reset = $bp->activity->actions;
     824                $bp->activity->actions = new stdClass();
    817825
    818826                $b = $this->factory->blog->create();
    819827                $u = $this->factory->user->create();
    Bar!'; 
    865873                $this->assertSame( $expected, $a_obj->action );
    866874
    867875                // Reset globals
    868                 unset( $bp->activity->actions->activity->new_foo );
     876                $bp->activity->actions = $reset;
    869877                $bp->activity->track = array();
    870878        }
    871879
    Bar!'; 
    874882         * @group activity_tracking
    875883         */
    876884        public function test_bp_activity_set_post_type_tracking_args() {
     885                global $wp_post_types;
     886
    877887                $bp = buddypress();
     888                $activity_actions = $bp->activity->actions;
     889                $bp->activity->actions = new stdClass();
    878890
    879891                add_post_type_support( 'page', 'buddypress-activity' );
    880892
    Bar!'; 
    905917                remove_post_type_support( 'page', 'buddypress-activity' );
    906918
    907919                // Reset globals
    908                 unset( $bp->activity->actions->blogs->new_page );
     920                $bp->activity->actions = $activity_actions;
     921
     922                unset( $wp_post_types['page']->bp_activity );
    909923                $bp->activity->track = array();
    910924        }
    911925
  • tests/phpunit/testcases/blogs/activity.php

    diff --git tests/phpunit/testcases/blogs/activity.php tests/phpunit/testcases/blogs/activity.php
    index 96b6ab6..bfb0d2c 100644
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    77         */
    88        public function test_bp_blogs_loader_post_tracking_args_filter() {
    99                $bp = buddypress();
     10                $activity_actions = $bp->activity->actions;
     11                $bp->activity->actions = new stdClass();
     12
     13                // Make sure regulare actions are populated
     14                do_action( 'bp_register_activity_actions' );
    1015
    1116                $expected = array( 'new_blog_post', 'new_blog_comment' );
    1217
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    1823                $actions = array_keys( (array) $actions->blogs );
    1924
    2025                $this->assertEquals( $expected, $actions );
     26
     27                // Reset globals
     28                $bp->activity->actions = $activity_actions;
    2129        }
    2230
    2331        /**
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    5462                        return;
    5563                }
    5664
     65                $bp = buddypress();
     66                $activity_actions = $bp->activity->actions;
     67                $bp->activity->actions = new stdClass();
     68
    5769                $u = $this->factory->user->create();
    5870                $p = $this->factory->post->create( array(
    5971                        'post_author' => $u,
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    7789                $expected = sprintf( '%s wrote a new post, %s', $user_link, $post_link );
    7890
    7991                $this->assertSame( $expected, $a_obj->action );
     92
     93                // Reset globals
     94                $bp->activity->actions = $activity_actions;
     95                $bp->activity->track = array();
    8096        }
    8197
    8298        /**
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    88104                        return;
    89105                }
    90106
     107                $bp = buddypress();
     108                $activity_actions = $bp->activity->actions;
     109                $bp->activity->actions = new stdClass();
     110
    91111                $u = $this->factory->user->create();
    92112                $p = $this->factory->post->create( array(
    93113                        'post_author' => $u,
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    111131                $expected = sprintf( '%s wrote a new post, %s, on the site %s', $user_link, $post_link, '<a href="' . $blog_url . '">' . bp_blogs_get_blogmeta( $a_obj->item_id, 'name' ) . '</a>' );
    112132
    113133                $this->assertSame( $expected, $a_obj->action );
     134
     135                // Reset globals
     136                $bp->activity->actions = $activity_actions;
     137                $bp->activity->track = array();
    114138        }
    115139
    116140        /**
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    122146                        return;
    123147                }
    124148
     149                $bp = buddypress();
     150                $activity_actions = $bp->activity->actions;
     151                $bp->activity->actions = new stdClass();
     152
    125153                $b = $this->factory->blog->create();
    126154                $u = $this->factory->user->create();
    127155
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    151179                $expected = sprintf( '%s wrote a new post, %s, on the site %s', $user_link, $post_link, '<a href="' . $blog_url . '">' . get_blog_option( $a_obj->item_id, 'blogname' ) . '</a>' );
    152180
    153181                $this->assertSame( $expected, $a_obj->action );
     182
     183                // Reset globals
     184                $bp->activity->actions = $activity_actions;
     185                $bp->activity->track = array();
    154186        }
    155187
    156188        /**
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    233265                        return;
    234266                }
    235267
     268                $bp = buddypress();
     269                $activity_actions = $bp->activity->actions;
     270                $bp->activity->actions = new stdClass();
     271
     272                // Make sure the filter will be fired
     273                bp_activity_get_actions();
     274
    236275                add_filter( 'bp_blogs_activity_new_post_action', array( $this, 'new_post_passthrough' ), 10, 2 );
    237276
    238277                $b = $this->factory->blog->create();
    class BP_Tests_Blogs_Activity extends BP_UnitTestCase { 
    251290                ) );
    252291
    253292                $this->assertEquals( $this->post_id, $p );
     293
     294                // Reset globals
     295                $bp->activity->actions = $activity_actions;
     296                $bp->activity->track = array();
    254297        }
    255298
    256299        /**