Testing ftp_delete basic functionality
--CREDITS--
Gabriel Caruso (carusogabriel34@gmail.com)
+Contributed by Ward Cappelle <wardcappelle@gmail.com>
+User Group: PHP-WVL & PHPGent #PHPTestFest
--SKIPIF--
<?php require 'skipif.inc'; ?>
--FILE--
ftp_login($ftp, 'user', 'pass');
$ftp or die("Couldn't connect to the server");
-var_dump(ftp_delete($ftp, 'file'));
+echo "Test case #1: removal of existing file from FTP, should return true:", PHP_EOL;
+var_dump(ftp_delete($ftp, 'file1'));
+
+echo "Test case #2: removal of non-existent file from FTP, should return false:", PHP_EOL;
+var_dump(ftp_delete($ftp, 'false-file.boo'));
+
+ftp_close($ftp);
?>
---EXPECT--
+--EXPECTF--
+Test case #1: removal of existing file from FTP, should return true:
bool(true)
+Test case #2: removal of non-existent file from FTP, should return false:
+
+Warning: ftp_delete(): No such file or directory in %s on line %d
+bool(false)
} elseif (preg_match('/^SITE CHMOD/', $buf, $matches)) {
fputs($s, "200 OK\r\n");
- } elseif (preg_match('/^DELE/', $buf, $matches)) {
- fputs($s, "250 OK\r\n");
-
+ } elseif (preg_match('/^DELE ([\w\h]+)/', $buf, $matches)) {
+ if (isset($matches[1]) && in_array($matches[1], ['file1', "file\nb0rk"])){
+ fputs($s, "250 Delete successful\r\n");
+ } else {
+ fputs($s, "550 No such file or directory\r\n");
+ }
} elseif (preg_match('/^ALLO (\d+)/', $buf, $matches)) {
fputs($s, "200 " . $matches[1] . " bytes allocated\r\n");