Changeset 7789
- Timestamp:
- 10/04/2026 08:32:13 AM (6 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/testcases/core/update.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/core/update.php
r7753 r7789 10 10 /** 11 11 * @covers ::bbp_is_install 12 * @todo Implement test_bbp_is_install().13 12 */ 14 13 public function test_bbp_is_install() { 15 // Remove the following lines when you implement this test. 16 $this->markTestIncomplete( 17 'This test has not been implemented yet.' 18 ); 14 delete_option( '_bbp_db_version' ); 15 $this->assertTrue( bbp_is_install() ); 16 17 update_option( '_bbp_db_version', bbp_get_db_version() ); 18 $this->assertFalse( bbp_is_install() ); 19 19 } 20 20 21 21 /** 22 22 * @covers ::bbp_is_update 23 * @todo Implement test_bbp_is_update().24 23 */ 25 24 public function test_bbp_is_update() { 26 // Remove the following lines when you implement this test. 27 $this->markTestIncomplete( 28 'This test has not been implemented yet.' 29 ); 25 $current_version = (int) bbp_get_db_version(); 26 update_option( '_bbp_db_version', $current_version - 1 ); 27 $this->assertTrue( bbp_is_update() ); 28 29 update_option( '_bbp_db_version', $current_version ); 30 $this->assertFalse( bbp_is_update() ); 31 32 update_option( '_bbp_db_version', $current_version + 1 ); 33 $this->assertFalse( bbp_is_update() ); 30 34 } 31 35 32 36 /** 33 37 * @covers ::bbp_is_activation 34 * @todo Implement test_bbp_is_activation().35 38 */ 36 39 public function test_bbp_is_activation() { 37 // Remove the following lines when you implement this test. 38 $this->markTestIncomplete( 39 'This test has not been implemented yet.' 40 ); 40 global $pagenow; 41 42 $old_screen = isset( $GLOBALS['current_screen'] ) ? $GLOBALS['current_screen'] : null; 43 $old_pagenow = $pagenow; 44 $old_request = $_REQUEST; 45 $old_get = $_GET; 46 $old_post = $_POST; 47 $basename = bbpress()->basename; 48 49 try { 50 set_current_screen( 'plugins' ); 51 $pagenow = 'plugins.php'; 52 $_REQUEST['action'] = 'activate'; 53 $_GET['plugin'] = $basename; 54 $this->assertTrue( bbp_is_activation() ); 55 56 $_GET['plugin'] = 'another/plugin.php'; 57 $this->assertFalse( bbp_is_activation() ); 58 59 $_REQUEST['action'] = '-1'; 60 $_REQUEST['action2'] = 'activate-selected'; 61 $_POST['checked'] = array( $basename ); 62 $this->assertTrue( bbp_is_activation() ); 63 64 $pagenow = 'index.php'; 65 $this->assertFalse( bbp_is_activation() ); 66 } finally { 67 $GLOBALS['current_screen'] = $old_screen; 68 $pagenow = $old_pagenow; 69 $_REQUEST = $old_request; 70 $_GET = $old_get; 71 $_POST = $old_post; 72 } 41 73 } 42 74 43 75 /** 44 76 * @covers ::bbp_is_deactivation 45 * @todo Implement test_bbp_is_deactivation().46 77 */ 47 78 public function test_bbp_is_deactivation() { 48 // Remove the following lines when you implement this test. 49 $this->markTestIncomplete( 50 'This test has not been implemented yet.' 51 ); 79 global $pagenow; 80 81 $old_screen = isset( $GLOBALS['current_screen'] ) ? $GLOBALS['current_screen'] : null; 82 $old_pagenow = $pagenow; 83 $old_request = $_REQUEST; 84 $old_get = $_GET; 85 $old_post = $_POST; 86 $basename = bbpress()->basename; 87 88 try { 89 set_current_screen( 'plugins' ); 90 $pagenow = 'plugins.php'; 91 $_REQUEST['action'] = 'deactivate'; 92 $_GET['plugin'] = $basename; 93 $this->assertTrue( bbp_is_deactivation() ); 94 95 $_GET['plugin'] = 'another/plugin.php'; 96 $this->assertFalse( bbp_is_deactivation() ); 97 98 $_REQUEST['action'] = '-1'; 99 $_REQUEST['action2'] = 'deactivate-selected'; 100 $_POST['checked'] = array( $basename ); 101 $this->assertTrue( bbp_is_deactivation() ); 102 103 $pagenow = 'index.php'; 104 $this->assertFalse( bbp_is_deactivation() ); 105 } finally { 106 $GLOBALS['current_screen'] = $old_screen; 107 $pagenow = $old_pagenow; 108 $_REQUEST = $old_request; 109 $_GET = $old_get; 110 $_POST = $old_post; 111 } 52 112 } 53 113 54 114 /** 55 115 * @covers ::bbp_version_bump 56 * @todo Implement test_bbp_version_bump().57 116 */ 58 117 public function test_bbp_version_bump() { 59 // Remove the following lines when you implement this test. 60 $this->markTestIncomplete( 61 'This test has not been implemented yet.' 62 ); 118 update_option( '_bbp_db_version', 1 ); 119 bbp_version_bump(); 120 $this->assertSame( (int) bbp_get_db_version(), (int) bbp_get_db_version_raw() ); 63 121 } 64 122 … … 227 285 /** 228 286 * @covers ::bbp_version_updater 229 * @todo Implement test_bbp_version_updater().230 287 */ 231 288 public function test_bbp_version_updater() { 232 // Remove the following lines when you implement this test. 233 $this->markTestIncomplete( 234 'This test has not been implemented yet.' 235 ); 289 delete_option( '_bbp_db_version' ); 290 update_option( 'rewrite_rules', array( 'sentinel' => 'saved' ) ); 291 292 bbp_version_updater(); 293 294 $this->assertSame( (int) bbp_get_db_version(), (int) bbp_get_db_version_raw() ); 295 $this->assertFalse( get_option( 'rewrite_rules' ) ); 236 296 } 237 297 … … 251 311 /** 252 312 * @covers ::bbp_add_activation_redirect 253 * @todo Implement test_bbp_add_activation_redirect().254 313 */ 255 314 public function test_bbp_add_activation_redirect() { 256 // Remove the following lines when you implement this test. 257 $this->markTestIncomplete( 258 'This test has not been implemented yet.' 259 ); 315 $old_user = get_current_user_id(); 316 $old_get = $_GET; 317 $user_id = $this->factory->user->create(); 318 $this->set_current_user( $user_id ); 319 320 try { 321 bbp_add_activation_redirect(); 322 $this->assertTrue( (bool) get_user_option( '_bbp_activation_redirect', $user_id ) ); 323 324 delete_user_option( $user_id, '_bbp_activation_redirect' ); 325 $_GET['activate-multi'] = '1'; 326 bbp_add_activation_redirect(); 327 $this->assertFalse( (bool) get_user_option( '_bbp_activation_redirect', $user_id ) ); 328 } finally { 329 $_GET = $old_get; 330 $this->set_current_user( $old_user ); 331 } 260 332 } 261 333 262 334 /** 263 335 * @covers ::bbp_make_current_user_keymaster 264 * @todo Implement test_bbp_make_current_user_keymaster().265 336 */ 266 337 public function test_bbp_make_current_user_keymaster() { 267 // Remove the following lines when you implement this test. 268 $this->markTestIncomplete( 269 'This test has not been implemented yet.' 270 ); 338 $old_user = get_current_user_id(); 339 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); 340 if ( is_multisite() ) { 341 grant_super_admin( $user_id ); 342 } 343 $this->set_current_user( $user_id ); 344 $forum_role = bbp_get_user_role( $user_id ); 345 if ( $forum_role ) { 346 get_userdata( $user_id )->remove_role( $forum_role ); 347 } 348 349 try { 350 $this->assertFalse( bbp_get_user_role( $user_id ) ); 351 bbp_make_current_user_keymaster(); 352 $this->assertSame( bbp_get_keymaster_role(), bbp_get_user_role( $user_id ) ); 353 354 bbp_make_current_user_keymaster(); 355 $this->assertSame( bbp_get_keymaster_role(), bbp_get_user_role( $user_id ) ); 356 } finally { 357 $this->set_current_user( $old_user ); 358 if ( is_multisite() ) { 359 revoke_super_admin( $user_id ); 360 } 361 } 271 362 } 272 363 }
Note:
See TracChangeset
for help on using the changeset viewer.