Skip to content

Commit 94a8107

Browse files
committed
add tests for 2 old bugs
1 parent 7172a53 commit 94a8107

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

ext/ftp/tests/bug27809.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #27809: ftp_systype returns null
3+
--SKIPIF--
4+
<?php
5+
require 'skipif.inc';
6+
?>
7+
--FILE--
8+
<?php
9+
$bug27809=true;
10+
require 'server.inc';
11+
12+
$ftp = ftp_connect('127.0.0.1', $port);
13+
if (!$ftp) die("Couldn't connect to the server");
14+
15+
var_dump(ftp_login($ftp, 'anonymous', 'IEUser@'));
16+
var_dump(ftp_systype($ftp));
17+
18+
?>
19+
--EXPECT--
20+
bool(true)
21+
string(6) "OS/400"

ext/ftp/tests/bug7216-2.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #7216: ftp_mkdir returns nothing (2)
3+
--SKIPIF--
4+
<?php
5+
require 'skipif.inc';
6+
?>
7+
--FILE--
8+
<?php
9+
require 'server.inc';
10+
11+
$ftp = ftp_connect('127.0.0.1', $port);
12+
if (!$ftp) die("Couldn't connect to the server");
13+
14+
var_dump(ftp_login($ftp, 'anonymous', 'IEUser@'));
15+
// test for the correct behavior this time
16+
var_dump(ftp_mkdir($ftp, 'CVS'));
17+
18+
?>
19+
--EXPECTREGEX--
20+
bool\(true\)
21+
string\(\d+\) ".+[\/\\]CVS"

ext/ftp/tests/bug7216.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #7216: ftp_mkdir returns nothing
3+
--SKIPIF--
4+
<?php
5+
require 'skipif.inc';
6+
?>
7+
--FILE--
8+
<?php
9+
$bug7216=true;
10+
require 'server.inc';
11+
12+
$ftp = ftp_connect('127.0.0.1', $port);
13+
if (!$ftp) die("Couldn't connect to the server");
14+
15+
var_dump(ftp_login($ftp, 'anonymous', 'IEUser@'));
16+
var_dump(ftp_mkdir($ftp, 'CVS'));
17+
18+
?>
19+
--EXPECT--
20+
bool(true)
21+
string(3) "CVS"

ext/ftp/tests/server.inc

+13-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ while($buf = fread($s, 4098)) {
151151
fputs($s, "250 CDUP command successful.\r\n");
152152

153153
} elseif ($buf === "SYST\r\n") {
154-
fputs($s, "215 UNIX Type: L8.\r\n");
154+
if (isset($bug27809)) {
155+
fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n");
156+
} else {
157+
fputs($s, "215 UNIX Type: L8.\r\n");
158+
}
155159

156160
} elseif ($buf === "QUIT\r\n") {
157161
break;
@@ -160,7 +164,14 @@ while($buf = fread($s, 4098)) {
160164
change_dir($m[1]);
161165
fputs($s, "250 CWD command successful.\r\n");
162166

163-
} else if(preg_match('/^USER /', $buf)) {
167+
} elseif (preg_match("~^MKD ([A-Za-z./]+)\r\n$~", $buf, $m)) {
168+
if (isset($bug7216)) {
169+
fputs($s, "257 OK.\r\n");
170+
} else {
171+
fputs($s, '257 "'.realpath($m[1])."\" created.\r\n");
172+
}
173+
174+
} elseif (preg_match('/^USER /', $buf)) {
164175
user_auth($buf);
165176

166177
} else {

0 commit comments

Comments
 (0)