Changeset 7821
- Timestamp:
- 10/04/2026 06:24:47 PM (3 weeks ago)
- Location:
- trunk/tests/phpunit/testcases/users/functions
- Files:
-
- 3 edited
-
counts.php (modified) (2 diffs)
-
functions.php (modified) (1 diff)
-
permissions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/users/functions/counts.php
r7526 r7821 654 654 /** 655 655 * @covers ::bbp_update_counts_on_post_author_change 656 * @covers ::bbp_recalculate_engagements_on_post_author_change 656 657 */ 657 658 public function test_changing_post_authors_updates_user_counts() { … … 675 676 wp_update_post( array( 'ID' => $topic_id, 'post_author' => $new_user_id ) ); 676 677 $this->assertSame( 2, bbp_get_topic_voice_count( $topic_id, true ) ); 678 $this->assertEqualsCanonicalizing( array( $old_user_id, $new_user_id ), bbp_get_topic_engagements( $topic_id ) ); 677 679 678 680 wp_update_post( array( 'ID' => $reply_id, 'post_author' => $new_user_id ) ); 679 681 $this->assertSame( 1, bbp_get_topic_voice_count( $topic_id, true ) ); 682 $this->assertSame( array( $new_user_id ), bbp_get_topic_engagements( $topic_id ) ); 680 683 681 684 $this->assertSame( 0, bbp_get_user_topic_count( $old_user_id, true ) ); -
trunk/tests/phpunit/testcases/users/functions/functions.php
r7820 r7821 261 261 262 262 $this->assertTrue( $r ); 263 } 264 265 /** 266 * @covers ::bbp_get_user_ids_from_nicenames 267 */ 268 public function test_bbp_get_user_ids_from_nicenames() { 269 $first_id = $this->factory->user->create( array( 'user_nicename' => 'bbp-nicename-a' ) ); 270 $second_id = $this->factory->user->create( array( 'user_nicename' => 'bbp-nicename-b' ) ); 271 $seen = null; 272 $record = function ( $ids, $nicenames ) use ( &$seen ) { 273 $seen = $nicenames; 274 return $ids; 275 }; 276 277 $this->assertSame( array(), bbp_get_user_ids_from_nicenames() ); 278 $this->assertSame( array(), bbp_get_user_ids_from_nicenames( 'missing-nicename' ) ); 279 add_filter( 'bbp_get_user_ids_from_nicenames', $record, 10, 2 ); 280 281 try { 282 $ids = bbp_get_user_ids_from_nicenames( 'BBP NICENAME A,BBP NICENAME B' ); 283 $this->assertEqualsCanonicalizing( array( $first_id, $second_id ), array_map( 'intval', $ids ) ); 284 $this->assertSame( array( 'bbp-nicename-a', 'bbp-nicename-b' ), $seen ); 285 } finally { 286 remove_filter( 'bbp_get_user_ids_from_nicenames', $record, 10 ); 287 } 288 } 289 290 /** 291 * @covers ::bbp_get_user_nicenames_from_ids 292 */ 293 public function test_bbp_get_user_nicenames_from_ids() { 294 $first_id = $this->factory->user->create( array( 'user_nicename' => 'bbp-nicename-a' ) ); 295 $second_id = $this->factory->user->create( array( 'user_nicename' => 'bbp-nicename-b' ) ); 296 $input = array( $first_id, $second_id ); 297 $seen = null; 298 $record = function ( $nicenames, $ids ) use ( &$seen ) { 299 $seen = $ids; 300 return $nicenames; 301 }; 302 303 $this->assertSame( array(), bbp_get_user_nicenames_from_ids() ); 304 $this->assertSame( array(), bbp_get_user_nicenames_from_ids( array( PHP_INT_MAX ) ) ); 305 add_filter( 'bbp_get_user_nicenames_from_ids', $record, 10, 2 ); 306 307 try { 308 $nicenames = bbp_get_user_nicenames_from_ids( $input ); 309 $this->assertEqualsCanonicalizing( array( 'bbp-nicename-a', 'bbp-nicename-b' ), $nicenames ); 310 $this->assertSame( $input, $seen ); 311 } finally { 312 remove_filter( 'bbp_get_user_nicenames_from_ids', $record, 10 ); 313 } 263 314 } 264 315 -
trunk/tests/phpunit/testcases/users/functions/permissions.php
r7689 r7821 317 317 } 318 318 319 /** 320 * @covers ::bbp_filter_user_edit_post_data 321 */ 319 322 public function test_user_edit_post_data_enforces_field_permissions() { 320 323 $moderator_id = $this->factory->user->create(); … … 349 352 } 350 353 354 /** 355 * @covers ::bbp_filter_user_edit_post_data 356 */ 351 357 public function test_user_edit_post_data_removes_contact_methods_with_profile_fields() { 352 358 $moderator_id = $this->factory->user->create(); … … 373 379 } 374 380 381 /** 382 * @covers ::bbp_user_email_change_requires_confirmation 383 */ 375 384 public function test_email_confirmation_policy_distinguishes_self_and_moderator_edits() { 376 385 $moderator_id = $this->factory->user->create();
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)