diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index fa667f99baacc..1a60c630f1b7d 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -1350,29 +1350,16 @@ public function unlink( $file ) { * Does not delete files if their paths are set in the `$ignore_files` property. * * @since 4.0.0 - * @since 6.1.0 Removes the empty directory if there are no files left. * * @param string $path Directory path. */ public function rmdir( $path ) { - if ( ! is_dir( $path ) ) { - return; - } - $files = $this->files_in_dir( $path ); foreach ( $files as $file ) { if ( ! in_array( $file, self::$ignore_files, true ) ) { $this->unlink( $file ); } } - - /* - * If there were no ignored files, remove the empty directory. - * If there are any nested empty directories, remove them too. - */ - if ( ! array_intersect( $files, self::$ignore_files ) ) { - $this->delete_folders( $path ); - } } /** diff --git a/tests/phpunit/tests/multisite/cleanDirsizeCache.php b/tests/phpunit/tests/multisite/cleanDirsizeCache.php index a777feca8a37e..df38ee33d1645 100644 --- a/tests/phpunit/tests/multisite/cleanDirsizeCache.php +++ b/tests/phpunit/tests/multisite/cleanDirsizeCache.php @@ -295,6 +295,8 @@ public function test_5_5_transient_structure_compat() { // Cleanup. $this->remove_added_uploads(); + rmdir( $upload_dir['basedir'] . '/2/1' ); + restore_current_blog(); } diff --git a/tests/phpunit/tests/rest-api/rest-plugins-controller.php b/tests/phpunit/tests/rest-api/rest-plugins-controller.php index 60b74ddd283ca..3143c6a761e63 100644 --- a/tests/phpunit/tests/rest-api/rest-plugins-controller.php +++ b/tests/phpunit/tests/rest-api/rest-plugins-controller.php @@ -84,7 +84,10 @@ public static function wpTearDownAfterClass() { public function tear_down() { if ( file_exists( WP_PLUGIN_DIR . '/test-plugin/test-plugin.php' ) ) { + // Remove plugin files. $this->rmdir( WP_PLUGIN_DIR . '/test-plugin' ); + // Delete empty directory. + rmdir( WP_PLUGIN_DIR . '/test-plugin' ); } if ( file_exists( DIR_TESTDATA . '/link-manager.zip' ) ) { @@ -92,7 +95,10 @@ public function tear_down() { } if ( file_exists( WP_PLUGIN_DIR . '/link-manager/link-manager.php' ) ) { + // Remove plugin files. $this->rmdir( WP_PLUGIN_DIR . '/link-manager' ); + // Delete empty directory. + rmdir( WP_PLUGIN_DIR . '/link-manager' ); } parent::tear_down();