From: Gabriel Caruso Date: Sat, 3 Feb 2018 06:56:03 +0000 (+0100) Subject: Increase ext/ftp coverage X-Git-Tag: php-7.3.0alpha1~468^2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91b09c7aa6b88b276a02ee0f00277917efc54570;p=php Increase ext/ftp coverage --- diff --git a/ext/ftp/tests/ftp_get_basic.phpt b/ext/ftp/tests/ftp_get_basic.phpt index 2fd8c79149..60f1b1de79 100644 --- a/ext/ftp/tests/ftp_get_basic.phpt +++ b/ext/ftp/tests/ftp_get_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -FTP ftp_get file for both binary and ASCII transfer modes +FTP ftp_get file for both binary and ASCII transfer modes --CREDITS-- Nathaniel McHugh --SKIPIF-- @@ -27,8 +27,11 @@ var_dump(ftp_get($ftp, $tmpfname, 'binary data.bin', FTP_BINARY)); var_dump(urlencode(file_get_contents($tmpfname))); unlink($tmpfname); -//test non-existent file request +//test non-existent file request ftp_get($ftp, $tmpfname ,'a warning.txt', FTP_ASCII); + +//test invalid ftp_get params +var_dump(ftp_get('foo', 'bar', 'baz')); ?> --EXPECTF-- bool(true) @@ -38,3 +41,6 @@ bool(true) string(21) "BINARYFoo%00Bar%0D%0A" Warning: ftp_get(): a warning: No such file or directory in %sftp_get_basic.php on line %d + +Warning: ftp_get() expects parameter 1 to be resource, string given in %s on line %d +NULL diff --git a/ext/ftp/tests/ftp_site_basic.phpt b/ext/ftp/tests/ftp_site_basic.phpt new file mode 100644 index 0000000000..7dfaf1a307 --- /dev/null +++ b/ext/ftp/tests/ftp_site_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +ftp_site function basic functionality +--CREDITS-- +Gabriel Caruso (carusogabriel34@gmail.com) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: ftp_site(): Syntax error, command unrecognized. in %s on line %d +bool(false) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index 0b161de221..d94844b218 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -19,13 +19,8 @@ if (!$socket) { die("could not start/bind the ftp server\n"); } - - - $pid = pcntl_fork(); - - function pasv_listen($action){ global $pasv_port, $tmp_file; $tmp_file = 'nm2.php'; @@ -56,8 +51,6 @@ function pasv_listen($action){ } } - - if ($pid) { function dump_and_exit($buf) @@ -524,8 +517,9 @@ if ($pid) { fputs($s, "226 Closing data Connection.\r\n"); fclose($fs); - }else { + }elseif (preg_match("/^SITE/", $buf)) { fputs($s, "500 Syntax error, command unrecognized.\r\n"); + }else { dump_and_exit($buf); } }