1--TEST--
2ldap_modify() - Modify operations that should fail
3--CREDITS--
4Patrick Allaert <patrickallaert@php.net>
5# Belgian PHP Testfest 2009
6--SKIPIF--
7<?php require_once('skipif.inc'); ?>
8<?php require_once('skipifbindfailure.inc'); ?>
9--FILE--
10<?php
11require "connect.inc";
12
13$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
14
15// Too few parameters
16var_dump(ldap_modify());
17var_dump(ldap_modify($link));
18var_dump(ldap_modify($link, "$base"));
19
20// Too many parameters
21var_dump(ldap_modify($link, "$base", array(), [], "Additional data"));
22
23// DN not found
24var_dump(ldap_modify($link, "cn=not-found,$base", array()));
25
26// Invalid DN
27var_dump(ldap_modify($link, "weirdAttribute=val", array()));
28
29$entry = array(
30	"objectClass"	=> array(
31		"top",
32		"dcObject",
33		"organization"),
34	"dc"			=> "my-domain",
35	"o"				=> "my-domain",
36);
37
38ldap_add($link, "dc=my-domain,$base", $entry);
39
40$entry2 = $entry;
41$entry2["dc"] = "Wrong Domain";
42
43var_dump(ldap_modify($link, "dc=my-domain,$base", $entry2));
44
45$entry2 = $entry;
46$entry2["weirdAttribute"] = "weirdVal";
47
48var_dump(ldap_modify($link, "dc=my-domain,$base", $entry2));
49?>
50===DONE===
51--CLEAN--
52<?php
53require "connect.inc";
54
55$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
56
57ldap_delete($link, "dc=my-domain,$base");
58?>
59--EXPECTF--
60Warning: ldap_modify() expects at least 3 parameters, 0 given in %s on line %d
61NULL
62
63Warning: ldap_modify() expects at least 3 parameters, 1 given in %s on line %d
64NULL
65
66Warning: ldap_modify() expects at least 3 parameters, 2 given in %s on line %d
67NULL
68
69Warning: ldap_modify() expects at most 4 parameters, 5 given in %s on line %d
70NULL
71
72Warning: ldap_modify(): Modify: No such object in %s on line %d
73bool(false)
74
75Warning: ldap_modify(): Modify: Invalid DN syntax in %s on line %d
76bool(false)
77
78Warning: ldap_modify(): Modify: Naming violation in %s on line %d
79bool(false)
80
81Warning: ldap_modify(): Modify: Undefined attribute type in %s on line %d
82bool(false)
83===DONE===
84