@@ -81,8 +81,12 @@ function ftp_raw($connection, $command)
8181 return array ( 0 => '211-Status of somewhere/folder/dummy.txt: ' , 1 => ' -rw-r--r-- 1 ftp ftp 0 Nov 24 13:59 somewhere/folder/dummy.txt ' , 2 => '211 End of status ' );
8282}
8383
84- function ftp_rawlist ($ connection )
84+ function ftp_rawlist ($ connection, $ directory )
8585{
86+ if (strpos ($ directory , 'fail.rawlist ' ) !== false ) {
87+ return false ;
88+ }
89+
8690 return array (
8791 'drwxr-xr-x 4 ftp ftp 4096 Nov 24 13:58 . ' ,
8892 'drwxr-xr-x 16 ftp ftp 4096 Sep 2 13:01 .. ' ,
@@ -147,23 +151,22 @@ function ftp_chmod($connection, $mode, $path)
147151
148152class FtpTests extends \PHPUnit_Framework_TestCase
149153{
154+ protected $ options = array (
155+ 'host ' => 'example.org ' ,
156+ 'port ' => 40 ,
157+ 'ssl ' => true ,
158+ 'timeout ' => 35 ,
159+ 'root ' => '/somewhere ' ,
160+ 'permPublic ' => 0777 ,
161+ 'permPrivate ' => 0000 ,
162+ 'passive ' => false ,
163+ 'username ' => 'user ' ,
164+ 'password ' => 'password ' ,
165+ );
166+
150167 public function testInstantiable ()
151168 {
152- // 'host', 'port', 'username', 'password', 'ssl', 'timeout', 'root', 'permPrivate', 'permPublic'
153- $ options = array (
154- 'host ' => 'example.org ' ,
155- 'port ' => 40 ,
156- 'ssl ' => true ,
157- 'timeout ' => 35 ,
158- 'root ' => '/somewhere ' ,
159- 'permPublic ' => 0777 ,
160- 'permPrivate ' => 0000 ,
161- 'passive ' => false ,
162- 'username ' => 'user ' ,
163- 'password ' => 'password ' ,
164- );
165-
166- $ adapter = new Ftp ($ options );
169+ $ adapter = new Ftp ($ this ->options );
167170 $ this ->assertEquals ('example.org ' , $ adapter ->getHost ());
168171 $ this ->assertEquals (40 , $ adapter ->getPort ());
169172 $ this ->assertEquals (true , $ adapter ->getSsl ());
@@ -207,6 +210,15 @@ public function testConnectFail()
207210 $ adapter ->connect ();
208211 }
209212
213+ /**
214+ * @expectedException RuntimeException
215+ */
216+ public function testRawlistFail ()
217+ {
218+ $ adapter = new Ftp ($ this ->options );
219+ $ adapter ->listContents ('fail.rawlist ' );
220+ }
221+
210222 /**
211223 * @expectedException RuntimeException
212224 */
0 commit comments