Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/phpunit/tests/functions/wpIsWritable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* Tests for wp_is_writable().
*
* @group functions
*
* @covers ::wp_is_writable
*/
class Tests_Functions_wpIsWritable extends WP_UnitTestCase {

/**
* @ticket 65819
*/
public function test_returns_true_for_writable_directory() {
$this->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 );
}
}
Loading