Changeset 59216 for trunk/tests/phpunit/tests/user.php
- Timestamp:
- 10/11/2024 05:18:03 PM (19 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/user.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user.php
r59128 r59216 2246 2246 return $additional_profile_data; 2247 2247 } 2248 2249 /** 2250 * Test that update_user_meta for 'use_ssl' doesn't write to DB unnecessarily. 2251 * 2252 * @ticket 60299 2253 */ 2254 public function test_unnecessary_assignment_of_use_ssl_in_meta() { 2255 $user_id = self::$contrib_id; 2256 // Keep track of db writing calls. 2257 $set_db_counts = 0; 2258 2259 // Track db updates with calls to do_action( "update_user_meta", ... with 'use_ssl' meta key. 2260 add_action( 2261 'update_user_meta', 2262 function ( $meta_id, $object_id, $meta_key ) use ( &$set_db_counts ) { 2263 if ( 'use_ssl' !== $meta_key ) { 2264 return; 2265 } 2266 $set_db_counts++; 2267 }, 2268 10, 2269 3 2270 ); 2271 2272 $_POST = array( 2273 'nickname' => 'nickname_test', 2274 'email' => 'email_test_1@example.com', 2275 'use_ssl' => 1, 2276 ); 2277 2278 $user_id = edit_user( $user_id ); 2279 2280 $this->assertIsInt( $user_id ); 2281 $this->assertEquals( 1, $set_db_counts ); 2282 2283 // Update the user without changing the 'use_ssl' meta. 2284 $_POST['email'] = 'email_test_2@example.com'; 2285 $user_id = edit_user( $user_id ); 2286 2287 // Verify there are no updates to use_ssl user meta. 2288 $this->assertEquals( 1, $set_db_counts ); 2289 } 2248 2290 }
Note: See TracChangeset
for help on using the changeset viewer.