diff options
author | Michael Kliewe <mk@tendermaker.solutions> | 2017-10-26 12:13:07 -0700 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-10-28 13:02:23 +0200 |
commit | 7d5bf6e2695970345f11c3d137a6b5597d5f67ca (patch) | |
tree | 6699e784d85550bb83cd892c084add93d0418730 /ext/ftp | |
parent | 8d54f98e3312ebb3b683b4a92e38e5ed038782e8 (diff) | |
download | php-git-7d5bf6e2695970345f11c3d137a6b5597d5f67ca.tar.gz |
Add tests for ftp_rename
Diffstat (limited to 'ext/ftp')
-rw-r--r-- | ext/ftp/tests/ftp_rename_basic1.phpt | 23 | ||||
-rw-r--r-- | ext/ftp/tests/server.inc | 16 |
2 files changed, 34 insertions, 5 deletions
diff --git a/ext/ftp/tests/ftp_rename_basic1.phpt b/ext/ftp/tests/ftp_rename_basic1.phpt new file mode 100644 index 0000000000..3e1facc503 --- /dev/null +++ b/ext/ftp/tests/ftp_rename_basic1.phpt @@ -0,0 +1,23 @@ +--TEST-- +FTP basic ftp_rename calls +--SKIPIF-- +<?php +require 'skipif.inc'; +?> +--FILE-- +<?php +require 'server.inc'; + +$ftp = ftp_connect('127.0.0.1', $port); +if (!$ftp) die("Couldn't connect to the server"); + +ftp_login($ftp, 'user', 'pass'); + +var_dump(ftp_rename($ftp, 'existing_file', 'nonexisting_file')); +var_dump(ftp_rename($ftp, 'nonexisting_file', 'nonexisting_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 a1bf074f90..11f6e8fa78 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); } |