]> granicus.if.org Git - php/commitdiff
new test from Nat Mcugh
authorZoe Slattery <zoe@php.net>
Wed, 31 Dec 2008 20:04:55 +0000 (20:04 +0000)
committerZoe Slattery <zoe@php.net>
Wed, 31 Dec 2008 20:04:55 +0000 (20:04 +0000)
ext/ftp/tests/ftp_fget_basic.phpt [new file with mode: 0644]

diff --git a/ext/ftp/tests/ftp_fget_basic.phpt b/ext/ftp/tests/ftp_fget_basic.phpt
new file mode 100644 (file)
index 0000000..b81c726
--- /dev/null
@@ -0,0 +1,45 @@
+--TEST--
+FTP ftp_fget file for both binary and ASCII transfer modes
+--XFAIL--
+Mising implementation in PHP6
+--CREDITS--
+Nathaniel McHugh
+--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");
+
+var_dump(ftp_login($ftp, 'user', 'pass'));
+
+//test simple text transfer
+$fp = tmpfile();
+var_dump(ftp_fget($ftp, $fp ,'a story.txt', FTP_ASCII));
+fseek($fp, 0);
+echo fgets($fp);
+
+$postition = ftell($fp);
+//test binary data transfer
+var_dump(ftp_fget($ftp, $fp, 'binary data.bin', FTP_BINARY));
+fseek($fp, $postition);
+var_dump(urlencode(fgets($fp)));
+
+//test non-existant file request 
+ftp_fget($ftp, $fp ,'a warning.txt', FTP_ASCII);
+
+//remove file
+fclose($fp);
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+For sale: baby shoes, never worn.
+bool(true)
+string(21) "BINARYFoo%00Bar%0D%0A"
+
+Warning: ftp_fget(): a warning: No such file or directory  in %sftp_fget_basic.php on line %d