1--TEST--
2Testing ftp_set_option errors while setting up
3--CREDITS--
4Gabriel Caruso (carusogabriel34@gmail.com)
5--SKIPIF--
6<?php require 'skipif.inc'; ?>
7--FILE--
8<?php
9require 'server.inc';
10define('FOO_BAR', 10);
11
12$ftp = ftp_connect('127.0.0.1', $port);
13ftp_login($ftp, 'user', 'pass');
14$ftp or die("Couldn't connect to the server");
15
16try {
17    ftp_set_option($ftp, FTP_TIMEOUT_SEC, 0);
18} catch (ValueError $exception) {
19    echo $exception->getMessage() . "\n";
20}
21
22try {
23    ftp_set_option($ftp, FTP_TIMEOUT_SEC, '0');
24} catch (TypeError $exception) {
25    echo $exception->getMessage() . "\n";
26}
27
28try {
29    ftp_set_option($ftp, FTP_USEPASVADDRESS, ['1']);
30} catch (TypeError $exception) {
31    echo $exception->getMessage() . "\n";
32}
33
34try {
35    ftp_set_option($ftp, FTP_AUTOSEEK, 'true');
36} catch (TypeError $exception) {
37    echo $exception->getMessage() . "\n";
38}
39
40try {
41    ftp_set_option($ftp, FOO_BAR, 1);
42} catch (ValueError $exception) {
43    echo $exception->getMessage() . "\n";
44}
45
46?>
47--EXPECT--
48ftp_set_option(): Argument #3 ($value) must be greater than 0 for the FTP_TIMEOUT_SEC option
49ftp_set_option(): Argument #3 ($value) must be of type int for the FTP_TIMEOUT_SEC option, string given
50ftp_set_option(): Argument #3 ($value) must be of type bool for the FTP_USEPASVADDRESS option, array given
51ftp_set_option(): Argument #3 ($value) must be of type bool for the FTP_AUTOSEEK option, string given
52ftp_set_option(): Argument #2 ($option) must be one of FTP_TIMEOUT_SEC, FTP_AUTOSEEK, or FTP_USEPASVADDRESS
53