1--TEST--
2Testing ftp_set_option errors while setting up
3--CREDITS--
4Gabriel Caruso (carusogabriel34@gmail.com)
5--EXTENSIONS--
6ftp
7pcntl
8--FILE--
9<?php
10require 'server.inc';
11define('FOO_BAR', 10);
12
13$ftp = ftp_connect('127.0.0.1', $port);
14ftp_login($ftp, 'user', 'pass');
15$ftp or die("Couldn't connect to the server");
16
17$options = [
18    [ 'option' => FTP_TIMEOUT_SEC, 'value' => 0 ],
19	[ 'option' => FTP_TIMEOUT_SEC, 'value' => '0' ],
20	[ 'option' => FTP_USEPASVADDRESS, 'value' => ['1'] ],
21	[ 'option' => FTP_AUTOSEEK, 'value' => 'true' ],
22	[ 'option' => FOO_BAR, 'value' => 1 ],
23];
24foreach ($options as $option) try {
25	var_dump(ftp_set_option($ftp, $option['option'], $option['value']));
26} catch (\Throwable $ex) {
27	echo "Exception: ", $ex->getMessage(), "\n";
28}
29
30--EXPECT--
31Exception: ftp_set_option(): Argument #3 ($value) must be greater than 0 for the FTP_TIMEOUT_SEC option
32Exception: ftp_set_option(): Argument #3 ($value) must be of type int for the FTP_TIMEOUT_SEC option, string given
33Exception: ftp_set_option(): Argument #3 ($value) must be of type bool for the FTP_USEPASVADDRESS option, array given
34Exception: ftp_set_option(): Argument #3 ($value) must be of type bool for the FTP_AUTOSEEK option, string given
35Exception: ftp_set_option(): Argument #2 ($option) must be one of FTP_TIMEOUT_SEC, FTP_AUTOSEEK, or FTP_USEPASVADDRESS
36