diff --git a/tests/phpunit/includes/class-wp-test-stream.php b/tests/phpunit/includes/class-wp-test-stream.php index 11997507d0..17d930b586 100644 --- a/tests/phpunit/includes/class-wp-test-stream.php +++ b/tests/phpunit/includes/class-wp-test-stream.php @@ -198,16 +198,27 @@ class WP_Test_Stream { * Creates a directory. * * @see streamWrapper::mkdir + * + * @param string $path Directory which should be created. + * @param int $mode The value passed to mkdir(). + * @param int $options A bitwise mask of values, such as STREAM_MKDIR_RECURSIVE. + * @return bool True on success, false on failure. */ public function mkdir( $path, $mode, $options ) { $this->open( $path ); + $plainfile = rtrim( $this->file, '/' ); - if ( isset( WP_Test_Stream::$data[ $this->bucket ][ $file ] ) ) { + // Check if a file or directory with the same name already exists. + if ( isset( WP_Test_Stream::$data[ $this->bucket ][ $plainfile ] ) + || isset( WP_Test_Stream::$data[ $this->bucket ][ $plainfile . '/' ] ) + ) { return false; } + $dir_ref = & $this->get_directory_ref(); $dir_ref = 'DIRECTORY'; + return true; }