diff --git tests/phpunit/tests/admin/includesPlugin.php tests/phpunit/tests/admin/includesPlugin.php
index b6dd5c2..0bf6fef 100644
|
|
class Tests_Admin_includesPlugin extends WP_UnitTestCase { |
224 | 224 | * @covers ::get_dropins |
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 | |
230 | 235 | /** |
231 | 236 | * @covers ::get_dropins |
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 ); |
236 | 243 | |
… |
… |
class Tests_Admin_includesPlugin extends WP_UnitTestCase { |
239 | 246 | |
240 | 247 | unlink( $p1[1] ); |
241 | 248 | unlink( $p2[1] ); |
| 249 | |
| 250 | // Clean up. |
| 251 | $this->_restore_drop_ins(); |
242 | 252 | } |
243 | 253 | |
244 | 254 | /** |
… |
… |
class Tests_Admin_includesPlugin extends WP_UnitTestCase { |
415 | 425 | rmdir( $mu_bu_dir ); |
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 | } |