public function testWritable() { if (Sys::isWin()) { //skip('This functionality is not working on Windows.'); return false; } if (Sys::isRoot()) { skip('These tests don\'t work when run as root'); } isFalse(FS::writable('/no/such/file')); // Create a file to test with $dirname = dirname(__FILE__); $file = $dirname . '/test7'; touch($file); chmod($file, 0644); // The file is owned by us so it should be writable isTrue(is_writable($file)); is('-rw-r--r--', FS::perms($file)); // Toggle writable bit off for us FS::writable($file, false); clearstatcache(); isFalse(is_writable($file)); is('-r--r--r--', FS::perms($file)); // Toggle writable bit back on for us FS::writable($file, true); clearstatcache(); isTrue(is_writable($file)); is('-rw-r--r--', FS::perms($file)); unlink($file); }