mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Tests: Remove empty directory in WP_UnitTestCase_Base::rmdir().
The `WP_UnitTestCase_Base::rmdir()` method selectively deletes files from a directory, skipping any paths from the `$ignore_files` property. This commit updates the method to remove the empty directory if there are no files left, bringing some parity with PHP native `rmdir()` function. Follow-up to [677/tests], [29120]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@54300 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1349,6 +1349,9 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
|
||||
*
|
||||
* 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 ) {
|
||||
@@ -1358,6 +1361,11 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
|
||||
$this->unlink( $file );
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no ignored files, remove the empty directory.
|
||||
if ( ! array_intersect( $files, self::$ignore_files ) ) {
|
||||
rmdir( $path );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user