Changeset 9139 for trunk/tests/phpunit/includes/factory.php
- Timestamp:
- 11/14/2014 02:01:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory.php
r9120 r9139 6 6 parent::__construct(); 7 7 8 $this->user = new BP_UnitTest_Factory_For_User( $this ); 8 9 $this->activity = new BP_UnitTest_Factory_For_Activity( $this ); 9 10 $this->group = new BP_UnitTest_Factory_For_Group( $this ); … … 16 17 } 17 18 19 class BP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_User { 20 /** 21 * When creating a new user, it's almost always necessary to have the 22 * last_activity usermeta set right away, so that the user shows up in 23 * directory queries. This is a shorthand wrapper for the user factory 24 * create() method. 25 * 26 * Also set a display name 27 */ 28 public function create_object( $args ) { 29 $r = wp_parse_args( $args, array( 30 'role' => 'subscriber', 31 'last_activity' => date( 'Y-m-d H:i:s', strtotime( bp_core_current_time() ) - 60*60*24*365 ), 32 ) ); 33 34 $last_activity = $r['last_activity']; 35 unset( $r['last_activity'] ); 36 37 $user_id = wp_insert_user( $r ); 38 39 bp_update_user_last_activity( $user_id, $last_activity ); 40 41 if ( bp_is_active( 'xprofile' ) ) { 42 $user = new WP_User( $user_id ); 43 xprofile_set_field_data( 1, $user_id, $user->display_name ); 44 } 45 46 return $user_id; 47 } 48 } 49 18 50 class BP_UnitTest_Factory_For_Activity extends WP_UnitTest_Factory_For_Thing { 19 51
Note: See TracChangeset
for help on using the changeset viewer.