Changeset 12599
- Timestamp:
- 03/28/2020 09:20:46 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/xprofile/activity.php
r12393 r12599 6 6 */ 7 7 class BP_Tests_XProfile_Activity extends BP_UnitTestCase { 8 protected $updated_profile_data = array(); 8 protected static $updated_profile_data = array(); 9 10 public static function wpSetUpBeforeClass( $factory ) { 11 self::$updated_profile_data['u'] = $factory->user->create(); 12 self::$updated_profile_data['g'] = $factory->xprofile_group->create(); 13 self::$updated_profile_data['f'] = $factory->xprofile_field->create( array( 14 'field_group_id' => self::$updated_profile_data['g'], 15 ) ); 16 } 17 18 public static function tearDownAfterClass() { 19 $d = self::$updated_profile_data; 20 21 xprofile_delete_field_group( $d['g'] ); 22 xprofile_delete_field( $d['f'] ); 23 24 self::delete_user( $d['u'] ); 25 26 self::commit_transaction(); 27 } 9 28 10 29 /** … … 12 31 */ 13 32 public function test_bp_xprofile_updated_profile_activity_with_errors() { 14 $d = $this->setup_updated_profile_data();33 $d = self::$updated_profile_data; 15 34 16 35 // Fake new/old values to ensure a change 17 36 $old_values = array( 18 $ this->updated_profile_data['f'] => array(19 'value' => 'foo', 20 'visibility' => 'public', 21 ), 22 ); 23 $new_values = array( 24 $ this->updated_profile_data['f'] => array(37 $d['f'] => array( 38 'value' => 'foo', 39 'visibility' => 'public', 40 ), 41 ); 42 $new_values = array( 43 $d['f'] => array( 25 44 'value' => 'foo2', 26 45 'visibility' => 'public', … … 28 47 ); 29 48 30 $this->assertFalse( bp_xprofile_updated_profile_activity( $d['u'], array( $d['f'] ), true ) ); 49 $du = isset( $d['u'] ) ? $d['u'] : ''; 50 $df = isset( $d['f'] ) ? $d['f'] : ''; 51 52 $this->assertFalse( bp_xprofile_updated_profile_activity( $du, array( $df ), true ) ); 31 53 } 32 54 … … 35 57 */ 36 58 public function test_bp_xprofile_updated_profile_activity_throttled() { 37 $d = $this->setup_updated_profile_data();59 $d = self::$updated_profile_data; 38 60 39 61 $time = time(); … … 50 72 // Fake new/old values to ensure a change 51 73 $old_values = array( 52 $ this->updated_profile_data['f'] => array(53 'value' => 'foo', 54 'visibility' => 'public', 55 ), 56 ); 57 $new_values = array( 58 $ this->updated_profile_data['f'] => array(74 $d['f'] => array( 75 'value' => 'foo', 76 'visibility' => 'public', 77 ), 78 ); 79 $new_values = array( 80 $d['f'] => array( 59 81 'value' => 'foo2', 60 82 'visibility' => 'public', … … 69 91 */ 70 92 public function test_bp_xprofile_updated_profile_activity_outside_of_throttle() { 71 $d = $this->setup_updated_profile_data();93 $d = self::$updated_profile_data; 72 94 73 95 $time = strtotime( bp_core_current_time() ); … … 84 106 // Fake new/old values to ensure a change 85 107 $old_values = array( 86 $ this->updated_profile_data['f'] => array(87 'value' => 'foo', 88 'visibility' => 'public', 89 ), 90 ); 91 $new_values = array( 92 $ this->updated_profile_data['f'] => array(108 $d['f'] => array( 109 'value' => 'foo', 110 'visibility' => 'public', 111 ), 112 ); 113 $new_values = array( 114 $d['f'] => array( 93 115 'value' => 'foo2', 94 116 'visibility' => 'public', … … 115 137 */ 116 138 public function test_bp_xprofile_updated_profile_activity_no_existing_activity() { 117 $d = $this->setup_updated_profile_data();139 $d = self::$updated_profile_data; 118 140 119 141 // Fake new/old values to ensure a change 120 142 $old_values = array( 121 $ this->updated_profile_data['f'] => array(122 'value' => 'foo', 123 'visibility' => 'public', 124 ), 125 ); 126 $new_values = array( 127 $ this->updated_profile_data['f'] => array(143 $d['f'] => array( 144 'value' => 'foo', 145 'visibility' => 'public', 146 ), 147 ); 148 $new_values = array( 149 $d['f'] => array( 128 150 'value' => 'foo2', 129 151 'visibility' => 'public', … … 150 172 */ 151 173 public function test_bp_xprofile_updated_profile_activity_no_changes() { 152 $d = $this->setup_updated_profile_data();153 154 $old_values = array( 155 $ this->updated_profile_data['f'] => array(156 'value' => 'foo', 157 'visibility' => 'public', 158 ), 159 ); 160 $new_values = array( 161 $ this->updated_profile_data['f'] => array(174 $d = self::$updated_profile_data; 175 176 $old_values = array( 177 $d['f'] => array( 178 'value' => 'foo', 179 'visibility' => 'public', 180 ), 181 ); 182 $new_values = array( 183 $d['f'] => array( 162 184 'value' => 'foo', 163 185 'visibility' => 'public', … … 172 194 */ 173 195 public function test_bp_xprofile_updated_profile_activity_no_public_changes() { 174 $d = $this->setup_updated_profile_data();175 176 $old_values = array( 177 $ this->updated_profile_data['f'] => array(196 $d = self::$updated_profile_data; 197 198 $old_values = array( 199 $d['f'] => array( 178 200 'value' => 'foo', 179 201 'visibility' => 'loggedin', … … 181 203 ); 182 204 $new_values = array( 183 $ this->updated_profile_data['f'] => array(205 $d['f'] => array( 184 206 'value' => 'bar', 185 207 'visibility' => 'loggedin', … … 194 216 */ 195 217 public function test_bp_xprofile_updated_profile_activity_public_changed_to_private() { 196 $d = $this->setup_updated_profile_data();197 198 $old_values = array( 199 $ this->updated_profile_data['f'] => array(200 'value' => 'foo', 201 'visibility' => 'public', 202 ), 203 ); 204 $new_values = array( 205 $ this->updated_profile_data['f'] => array(218 $d = self::$updated_profile_data; 219 220 $old_values = array( 221 $d['f'] => array( 222 'value' => 'foo', 223 'visibility' => 'public', 224 ), 225 ); 226 $new_values = array( 227 $d['f'] => array( 206 228 'value' => 'bar', 207 229 'visibility' => 'loggedin', … … 216 238 */ 217 239 public function test_bp_xprofile_updated_profile_activity_private_changed_to_public() { 218 $d = $this->setup_updated_profile_data();219 220 $old_values = array( 221 $ this->updated_profile_data['f'] => array(240 $d = self::$updated_profile_data; 241 242 $old_values = array( 243 $d['f'] => array( 222 244 'value' => 'foo', 223 245 'visibility' => 'loggedin', … … 225 247 ); 226 248 $new_values = array( 227 $ this->updated_profile_data['f'] => array(249 $d['f'] => array( 228 250 'value' => 'foo', 229 251 'visibility' => 'public', … … 238 260 */ 239 261 public function test_bp_xprofile_updated_profile_activity_field_didnt_previously_exist() { 240 $d = $this->setup_updated_profile_data();262 $d = self::$updated_profile_data; 241 263 242 264 $old_values = array(); 243 265 $new_values = array( 244 $ this->updated_profile_data['f'] => array(266 $d['f'] => array( 245 267 'value' => 'bar', 246 268 'visibility' => 'public', … … 255 277 */ 256 278 public function test_bp_xprofile_updated_profile_activity_public_changes() { 257 $d = $this->setup_updated_profile_data();258 259 $old_values = array( 260 $ this->updated_profile_data['f'] => array(261 'value' => 'foo', 262 'visibility' => 'public', 263 ), 264 ); 265 $new_values = array( 266 $ this->updated_profile_data['f'] => array(279 $d = self::$updated_profile_data; 280 281 $old_values = array( 282 $d['f'] => array( 283 'value' => 'foo', 284 'visibility' => 'public', 285 ), 286 ); 287 $new_values = array( 288 $d['f'] => array( 267 289 'value' => 'bar', 268 290 'visibility' => 'public', … … 310 332 $this->assertSame( $expected, $a_obj->action ); 311 333 } 312 313 protected function setup_updated_profile_data() {314 $this->updated_profile_data['u'] = self::factory()->user->create();315 $this->updated_profile_data['g'] = self::factory()->xprofile_group->create();316 $this->updated_profile_data['f'] = self::factory()->xprofile_field->create( array(317 'field_group_id' => $this->updated_profile_data['g'],318 ) );319 320 }321 334 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)