Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/07/2016 04:55:04 PM (10 years ago)
Author:
imath
Message:

Post Type Activities: add unit tests and improve existing ones.

See #6482
Fixes #6128

File:
1 edited

Legend:

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

    r10297 r10545  
    5050        // Clean up after autocommits.
    5151        add_action( 'bp_blogs_recorded_existing_blogs', array( $this, 'set_autocommit_flag' ) );
     52
     53        // Make sure Activity actions are reset before each test
     54        $this->reset_bp_activity_actions();
     55
     56        // Make sure all Post types activities globals are reset before each test
     57        $this->reset_bp_activity_post_types_globals();
    5258    }
    5359
     
    96102
    97103        parent::clean_up_global_scope();
     104    }
     105
     106    protected function reset_bp_activity_actions() {
     107        buddypress()->activity->actions = new stdClass();
     108
     109        /**
     110         * Populate the global with default activity actions only
     111         * before each test.
     112         */
     113        do_action( 'bp_register_activity_actions' );
     114    }
     115
     116    protected function reset_bp_activity_post_types_globals() {
     117        global $wp_post_types;
     118
     119        // Remove all remaining tracking arguments to each post type
     120        foreach ( $wp_post_types as $post_type => $post_type_arg ) {
     121            if ( post_type_supports( $post_type, 'buddypress-activity' ) ) {
     122                remove_post_type_support( $post_type, 'buddypress-activity' );
     123            }
     124
     125            if ( isset( $post_type_arg->bp_activity ) ) {
     126                unset( $post_type_arg->bp_activity );
     127            }
     128        }
     129
     130        buddypress()->activity->track = array();
    98131    }
    99132
Note: See TracChangeset for help on using the changeset viewer.