diff --git a/tests/phpunit/tests/functions/wpIsWritable.php b/tests/phpunit/tests/functions/wpIsWritable.php new file mode 100644 index 0000000000000..f2bdb2b013c3d --- /dev/null +++ b/tests/phpunit/tests/functions/wpIsWritable.php @@ -0,0 +1,40 @@ +assertTrue( wp_is_writable( get_temp_dir() ) ); + } + + /** + * @ticket 65819 + */ + public function test_returns_false_for_path_with_missing_parent() { + // Parent directory must not exist so Windows win_is_writable() cannot create the file. + $path = trailingslashit( get_temp_dir() ) . 'wp-is-writable-missing-' . wp_generate_password( 8, false ) . '/file.txt'; + + $this->assertFalse( wp_is_writable( $path ) ); + } + + /** + * @ticket 65819 + */ + public function test_returns_true_for_writable_file() { + $file = wp_tempnam( 'wp-is-writable-' ); + + $this->assertNotFalse( $file ); + $this->assertTrue( wp_is_writable( $file ) ); + + unlink( $file ); + } +}