summaryrefslogtreecommitdiff
path: root/ext/ftp/tests
diff options
context:
space:
mode:
authorGabriel Caruso <carusogabriel34@gmail.com>2018-02-03 07:56:03 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2018-02-06 16:28:42 +0100
commit91b09c7aa6b88b276a02ee0f00277917efc54570 (patch)
treea19bcc11bf8056f5e5c5f58017cf6ae183e6f691 /ext/ftp/tests
parentc73e8a07a599b6ac0557d76dfb7ee92f326e8f8e (diff)
downloadphp-git-91b09c7aa6b88b276a02ee0f00277917efc54570.tar.gz
Increase ext/ftp coverage
Diffstat (limited to 'ext/ftp/tests')
-rw-r--r--ext/ftp/tests/ftp_get_basic.phpt10
-rw-r--r--ext/ftp/tests/ftp_site_basic.phpt23
-rw-r--r--ext/ftp/tests/server.inc10
3 files changed, 33 insertions, 10 deletions
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--
+<?php require 'skipif.inc'; ?>
+--FILE--
+<?php
+require 'server.inc';
+
+$ftp = ftp_connect('127.0.0.1', $port);
+$ftp or die("Couldn't connect to the server");
+
+ftp_login($ftp, 'user', 'pass') or die("Couldn't login into the server");
+
+var_dump(ftp_site($ftp, 'CHMOD 0600 file'));
+var_dump(ftp_site($ftp, 'foo bar baz'));
+?>
+--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);
}
}