1--TEST--
2ldap_set_option() - ldap_set_option() operation that should fail
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--SKIPIF--
7<?php require_once('skipif.inc'); ?>
8--FILE--
9<?php
10require "connect.inc";
11
12$link = ldap_connect($host, $port);
13$controls = array(
14	array(
15		array("xid" => "1.2.752.58.10.1", "iscritical" => true),
16		array("xid" => "1.2.752.58.1.10", "value" => "magic"),
17	),
18	array(
19		array("oid" => "1.2.752.58.10.1", "iscritical" => true),
20		array("oid" => "1.2.752.58.1.10", "value" => "magic"),
21		"weird"
22	),
23	"notanarray"
24);
25
26// Too few parameters
27var_dump(ldap_set_option());
28var_dump(ldap_set_option($link));
29var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION));
30
31// Too many parameters
32var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 3, "Additional data"));
33
34var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 10));
35
36foreach ($controls as $control)
37	var_dump(ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $control));
38
39var_dump(ldap_set_option($link, 999999, 999999));
40?>
41===DONE===
42--EXPECTF--
43Warning: ldap_set_option() expects exactly 3 parameters, 0 given in %s on line %d
44NULL
45
46Warning: ldap_set_option() expects exactly 3 parameters, 1 given in %s on line %d
47NULL
48
49Warning: ldap_set_option() expects exactly 3 parameters, 2 given in %s on line %d
50NULL
51
52Warning: ldap_set_option() expects exactly 3 parameters, 4 given in %s on line %d
53NULL
54bool(false)
55
56Warning: ldap_set_option(): Control must have an oid key in %s on line %d
57bool(false)
58
59Warning: ldap_set_option(): The array value must contain only arrays, where each array is a control in %s on line %d
60bool(false)
61
62Warning: ldap_set_option(): Expected array value for this option in %s on line %d
63bool(false)
64bool(false)
65===DONE===
66