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