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
26var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 10));
27
28foreach ($controls as $control) {
29    try {
30        var_dump(ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $control));
31    } catch (Error $exception) {
32        echo get_class($exception) . ": " . $exception->getMessage() . "\n";
33    }
34}
35
36var_dump(ldap_set_option($link, 999999, 999999));
37?>
38--EXPECT--
39bool(false)
40ValueError: ldap_set_option(): Control must have an "oid" key
41TypeError: ldap_set_option(): Argument #3 ($value) must contain only arrays, where each array is a control
42TypeError: ldap_set_option(): Argument #3 ($value) must be of type array for the LDAP_OPT_CLIENT_CONTROLS option, string given
43bool(false)
44