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