Changeset 31009
- Timestamp:
- 12/31/2014 03:00:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesPlugin.php
r31003 r31009 225 225 */ 226 226 public function test_get_dropins_empty() { 227 $this->_back_up_drop_ins(); 228 227 229 $this->assertEquals( array(), get_dropins() ); 230 231 // Clean up. 232 $this->_restore_drop_ins(); 228 233 } 229 234 … … 232 237 */ 233 238 public function test_get_dropins_not_empty() { 239 $this->_back_up_drop_ins(); 240 234 241 $p1 = $this->_create_plugin( "<?php\n//Test", 'advanced-cache.php', WP_CONTENT_DIR ); 235 242 $p2 = $this->_create_plugin( "<?php\n//Test", 'not-a-dropin.php', WP_CONTENT_DIR ); … … 240 247 unlink( $p1[1] ); 241 248 unlink( $p2[1] ); 249 250 // Clean up. 251 $this->_restore_drop_ins(); 242 252 } 243 253 … … 416 426 } 417 427 } 428 429 /** 430 * Move existing drop-ins to wp-content/drop-ins-backup. 431 * 432 * @since 4.2.0 433 * 434 * @access private 435 */ 436 private function _back_up_drop_ins() { 437 $di_bu_dir = WP_CONTENT_DIR . '/drop-ins-backup'; 438 if ( ! is_dir( $di_bu_dir ) ) { 439 mkdir( $di_bu_dir ); 440 } 441 442 foreach( _get_dropins() as $file_to_move => $v ) { 443 if ( file_exists( WP_CONTENT_DIR . '/' . $file_to_move ) ) { 444 rename( WP_CONTENT_DIR . '/' . $file_to_move, $di_bu_dir . '/' . $file_to_move ); 445 } 446 } 447 } 448 449 /** 450 * Restore backed-up drop-ins. 451 * 452 * @since 4.2.0 453 * 454 * @access private 455 */ 456 private function _restore_drop_ins() { 457 $di_bu_dir = WP_CONTENT_DIR . '/drop-ins-backup'; 458 459 foreach( _get_dropins() as $file_to_move => $v ) { 460 if ( file_exists( $di_bu_dir . '/' . $file_to_move ) ) { 461 rename( $di_bu_dir . '/' . $file_to_move, WP_CONTENT_DIR . '/' . $file_to_move ); 462 } 463 } 464 465 if ( is_dir( $di_bu_dir ) ) { 466 rmdir( $di_bu_dir ); 467 } 468 } 418 469 }
Note: See TracChangeset
for help on using the changeset viewer.