007.phpt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. --TEST--
  2. FTP with bogus resource
  3. --CREDITS--
  4. Michael Paul da Rosa <michael [at] michaelpaul [dot] com [dot] br>
  5. PHP TestFest Dublin 2017
  6. --EXTENSIONS--
  7. ftp
  8. pcntl
  9. --FILE--
  10. <?php
  11. $ftp = tmpfile();
  12. try {
  13. var_dump(ftp_login($ftp, 'user', 'pass'));
  14. } catch (TypeError $e) {
  15. echo $e->getMessage(), "\n";
  16. }
  17. try {
  18. var_dump(ftp_pwd($ftp));
  19. } catch (TypeError $e) {
  20. echo $e->getMessage(), "\n";
  21. }
  22. try {
  23. var_dump(ftp_cdup($ftp));
  24. } catch (TypeError $e) {
  25. echo $e->getMessage(), "\n";
  26. }
  27. try {
  28. var_dump(ftp_chdir($ftp, '~'));
  29. } catch (TypeError $e) {
  30. echo $e->getMessage(), "\n";
  31. }
  32. try {
  33. var_dump(ftp_exec($ftp, 'x'));
  34. } catch (TypeError $e) {
  35. echo $e->getMessage(), "\n";
  36. }
  37. try {
  38. var_dump(ftp_raw($ftp, 'x'));
  39. } catch (TypeError $e) {
  40. echo $e->getMessage(), "\n";
  41. }
  42. try {
  43. var_dump(ftp_mkdir($ftp, '/'));
  44. } catch (TypeError $e) {
  45. echo $e->getMessage(), "\n";
  46. }
  47. try {
  48. var_dump(ftp_rmdir($ftp, '/'));
  49. } catch (TypeError $e) {
  50. echo $e->getMessage(), "\n";
  51. }
  52. try {
  53. var_dump(ftp_chmod($ftp, 7777, '/'));
  54. } catch (TypeError $e) {
  55. echo $e->getMessage(), "\n";
  56. }
  57. try {
  58. var_dump(ftp_alloc($ftp, 7777));
  59. } catch (TypeError $e) {
  60. echo $e->getMessage(), "\n";
  61. }
  62. try {
  63. var_dump(ftp_nlist($ftp, '/'));
  64. } catch (TypeError $e) {
  65. echo $e->getMessage(), "\n";
  66. }
  67. try {
  68. var_dump(ftp_rawlist($ftp, '~'));
  69. } catch (TypeError $e) {
  70. echo $e->getMessage(), "\n";
  71. }
  72. try {
  73. var_dump(ftp_mlsd($ftp, '~'));
  74. } catch (TypeError $e) {
  75. echo $e->getMessage(), "\n";
  76. }
  77. try {
  78. var_dump(ftp_systype($ftp));
  79. } catch (TypeError $e) {
  80. echo $e->getMessage(), "\n";
  81. }
  82. try {
  83. var_dump(ftp_fget($ftp, $ftp, 'remote', 7777));
  84. } catch (TypeError $e) {
  85. echo $e->getMessage(), "\n";
  86. }
  87. try {
  88. var_dump(ftp_nb_fget($ftp, $ftp, 'remote', 7777));
  89. } catch (TypeError $e) {
  90. echo $e->getMessage(), "\n";
  91. }
  92. try {
  93. var_dump(ftp_pasv($ftp, false));
  94. } catch (TypeError $e) {
  95. echo $e->getMessage(), "\n";
  96. }
  97. try {
  98. var_dump(ftp_get($ftp, 'local', 'remote', 7777));
  99. } catch (TypeError $e) {
  100. echo $e->getMessage(), "\n";
  101. }
  102. try {
  103. var_dump(ftp_nb_get($ftp, 'local', 'remote', 7777));
  104. } catch (TypeError $e) {
  105. echo $e->getMessage(), "\n";
  106. }
  107. try {
  108. var_dump(ftp_nb_continue($ftp));
  109. } catch (TypeError $e) {
  110. echo $e->getMessage(), "\n";
  111. }
  112. try {
  113. var_dump(ftp_fput($ftp, 'remote', $ftp, 9999));
  114. } catch (TypeError $e) {
  115. echo $e->getMessage(), "\n";
  116. }
  117. try {
  118. var_dump(ftp_nb_fput($ftp, 'remote', $ftp, 9999));
  119. } catch (TypeError $e) {
  120. echo $e->getMessage(), "\n";
  121. }
  122. try {
  123. var_dump(ftp_put($ftp, 'remote', 'local', 9999));
  124. } catch (TypeError $e) {
  125. echo $e->getMessage(), "\n";
  126. }
  127. try {
  128. var_dump(ftp_append($ftp, 'remote', 'local', 9999));
  129. } catch (TypeError $e) {
  130. echo $e->getMessage(), "\n";
  131. }
  132. try {
  133. var_dump(ftp_nb_put($ftp, 'remote', 'local', 9999));
  134. } catch (TypeError $e) {
  135. echo $e->getMessage(), "\n";
  136. }
  137. try {
  138. var_dump(ftp_size($ftp, '~'));
  139. } catch (TypeError $e) {
  140. echo $e->getMessage(), "\n";
  141. }
  142. try {
  143. var_dump(ftp_mdtm($ftp, '~'));
  144. } catch (TypeError $e) {
  145. echo $e->getMessage(), "\n";
  146. }
  147. try {
  148. var_dump(ftp_rename($ftp, 'old', 'new'));
  149. } catch (TypeError $e) {
  150. echo $e->getMessage(), "\n";
  151. }
  152. try {
  153. var_dump(ftp_delete($ftp, 'gone'));
  154. } catch (TypeError $e) {
  155. echo $e->getMessage(), "\n";
  156. }
  157. try {
  158. var_dump(ftp_site($ftp, 'localhost'));
  159. } catch (TypeError $e) {
  160. echo $e->getMessage(), "\n";
  161. }
  162. try {
  163. var_dump(ftp_close($ftp));
  164. } catch (TypeError $e) {
  165. echo $e->getMessage(), "\n";
  166. }
  167. try {
  168. var_dump(ftp_set_option($ftp, 1, 2));
  169. } catch (TypeError $e) {
  170. echo $e->getMessage(), "\n";
  171. }
  172. try {
  173. var_dump(ftp_get_option($ftp, 1));
  174. } catch (TypeError $e) {
  175. echo $e->getMessage(), "\n";
  176. }
  177. fclose($ftp);
  178. ?>
  179. --EXPECT--
  180. ftp_login(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  181. ftp_pwd(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  182. ftp_cdup(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  183. ftp_chdir(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  184. ftp_exec(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  185. ftp_raw(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  186. ftp_mkdir(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  187. ftp_rmdir(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  188. ftp_chmod(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  189. ftp_alloc(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  190. ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  191. ftp_rawlist(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  192. ftp_mlsd(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  193. ftp_systype(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  194. ftp_fget(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  195. ftp_nb_fget(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  196. ftp_pasv(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  197. ftp_get(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  198. ftp_nb_get(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  199. ftp_nb_continue(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  200. ftp_fput(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  201. ftp_nb_fput(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  202. ftp_put(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  203. ftp_append(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  204. ftp_nb_put(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  205. ftp_size(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  206. ftp_mdtm(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  207. ftp_rename(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  208. ftp_delete(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  209. ftp_site(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  210. ftp_close(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  211. ftp_set_option(): Argument #1 ($ftp) must be of type FTP\Connection, resource given
  212. ftp_get_option(): Argument #1 ($ftp) must be of type FTP\Connection, resource given