From 7872982b30ba245d7bab3b58f8f669174f9a6e61 Mon Sep 17 00:00:00 2001 From: Michael Kliewe Date: Thu, 26 Oct 2017 12:13:07 -0700 Subject: [PATCH 1/2] Add tests for ftp_rename --- ext/ftp/tests/ftp_rename_basic1.phpt | 23 +++++++++++++++++++++++ ext/ftp/tests/server.inc | 16 +++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 ext/ftp/tests/ftp_rename_basic1.phpt diff --git a/ext/ftp/tests/ftp_rename_basic1.phpt b/ext/ftp/tests/ftp_rename_basic1.phpt new file mode 100644 index 0000000000000..3e1facc503860 --- /dev/null +++ b/ext/ftp/tests/ftp_rename_basic1.phpt @@ -0,0 +1,23 @@ +--TEST-- +FTP basic ftp_rename calls +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: ftp_rename(): No such file or directory in %sftp_rename_basic1.php on line 10 +bool(false) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index a1bf074f90c05..11f6e8fa78599 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -471,11 +471,17 @@ if ($pid) { }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { fputs($s, "425 Error establishing connection\r\n"); - }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { - $GLOBALS['rest_pos'] = $matches[1]; + }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { + $GLOBALS['rest_pos'] = $matches[1]; fputs($s, "350 OK\r\n"); - }elseif (preg_match('/^SIZE largefile/', $buf)) { - fputs($s, "213 5368709120\r\n"); + }elseif (preg_match('/^SIZE largefile/', $buf)) { + fputs($s, "213 5368709120\r\n"); + }elseif (preg_match('/^RNFR existing_file/', $buf, $matches)) { + fputs($s, "350 File or directory exists, ready for destination name\r\n"); + }elseif (preg_match('/^RNFR nonexisting_file/', $buf, $matches)) { + fputs($s, "550 No such file or directory\r\n"); + }elseif (preg_match('/^RNTO nonexisting_file/', $buf, $matches)) { + fputs($s, "250 Rename successful\r\n"); }elseif (preg_match('/^MLSD no_exists\//', $buf, $matches)) { fputs($s, "425 Error establishing connection\r\n"); }elseif (preg_match("~^MLSD(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) { @@ -518,7 +524,7 @@ if ($pid) { fputs($s, "226 Closing data Connection.\r\n"); fclose($fs); - }else { + }else { fputs($s, "500 Syntax error, command unrecognized.\r\n"); dump_and_exit($buf); } From 114bb07fe441f7b048ea8d404867fc97ca160b74 Mon Sep 17 00:00:00 2001 From: Michael Kliewe Date: Thu, 26 Oct 2017 12:21:29 -0700 Subject: [PATCH 2/2] convert spaces to tabs in ext/ftp/tests/server.inc --- ext/ftp/tests/server.inc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index 11f6e8fa78599..0b161de221b98 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -286,7 +286,7 @@ if ($pid) { file_put_contents(__DIR__.'/'.$m[1], $data, FILE_APPEND); fputs($s, "226 Closing data Connection.\r\n"); fclose($fs); - } + } }elseif (preg_match("~^CWD ([A-Za-z./]+)\r\n$~", $buf, $m)) { change_dir($m[1]); @@ -395,17 +395,17 @@ if ($pid) { $transfer_type = $ascii? 'ASCII' : 'BINARY' ; fputs($fs, "Bar\r\n"); fputs($s, "226 Closing data Connection.\r\n"); - break; - case "fget_large": + break; + case "fget_large": fputs($s, "150 File status okay; about to open data connection.\r\n"); - $transfer_type = $ascii? 'ASCII' : 'BINARY' ; - if ($GLOBALS['rest_pos'] == '5368709119') { - fputs($fs, "X"); - } else { - fputs($fs, "Y"); - } + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + if ($GLOBALS['rest_pos'] == '5368709119') { + fputs($fs, "X"); + } else { + fputs($fs, "Y"); + } fputs($s, "226 Closing data Connection.\r\n"); - break; + break; case "mediumfile": fputs($s, "150 File status okay; about to open data connection.\r\n"); for($i = 0; $i < 150; $i++){ @@ -471,11 +471,11 @@ if ($pid) { }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { fputs($s, "425 Error establishing connection\r\n"); - }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { + }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { $GLOBALS['rest_pos'] = $matches[1]; fputs($s, "350 OK\r\n"); - }elseif (preg_match('/^SIZE largefile/', $buf)) { - fputs($s, "213 5368709120\r\n"); + }elseif (preg_match('/^SIZE largefile/', $buf)) { + fputs($s, "213 5368709120\r\n"); }elseif (preg_match('/^RNFR existing_file/', $buf, $matches)) { fputs($s, "350 File or directory exists, ready for destination name\r\n"); }elseif (preg_match('/^RNFR nonexisting_file/', $buf, $matches)) { @@ -524,7 +524,7 @@ if ($pid) { fputs($s, "226 Closing data Connection.\r\n"); fclose($fs); - }else { + }else { fputs($s, "500 Syntax error, command unrecognized.\r\n"); dump_and_exit($buf); }