xref: /PHP-5.5/ext/ldap/tests/ldap_explode_dn.phpt (revision 823b31d3)
1--TEST--
2ldap_explode_dn() test
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7
8/* Explode with attributes */
9var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 0));
10
11/* Explode with attributes */
12var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 0));
13
14/* Explode without attributes */
15var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 1));
16
17/* Explode without attributes */
18var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 1));
19
20/* Explode with attributes and < > characters */
21var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 0));
22
23/* Explode without attributes and < > characters */
24var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 1));
25
26/* Too few parameters */
27ldap_explode_dn("cn=bob,dc=example,dc=com");
28
29/* Too many parameters */
30ldap_explode_dn("cn=bob,dc=example,dc=com", 1, 1);
31
32/* Bad DN value with attributes */
33var_dump(ldap_explode_dn("bob,dc=example,dc=com", 0));
34
35/* Bad DN value without attributes */
36var_dump(ldap_explode_dn("bob,dc=example,dc=com", 1));
37
38echo "Done\n";
39
40?>
41--EXPECTF--
42array(4) {
43  ["count"]=>
44  int(3)
45  [0]=>
46  string(6) "cn=bob"
47  [1]=>
48  string(10) "dc=example"
49  [2]=>
50  string(6) "dc=com"
51}
52array(5) {
53  ["count"]=>
54  int(4)
55  [0]=>
56  string(6) "cn=bob"
57  [1]=>
58  string(8) "ou=users"
59  [2]=>
60  string(10) "dc=example"
61  [3]=>
62  string(6) "dc=com"
63}
64array(4) {
65  ["count"]=>
66  int(3)
67  [0]=>
68  string(3) "bob"
69  [1]=>
70  string(7) "example"
71  [2]=>
72  string(3) "com"
73}
74array(5) {
75  ["count"]=>
76  int(4)
77  [0]=>
78  string(3) "bob"
79  [1]=>
80  string(5) "users"
81  [2]=>
82  string(7) "example"
83  [3]=>
84  string(3) "com"
85}
86bool(false)
87bool(false)
88
89Warning: ldap_explode_dn() expects exactly 2 parameters, 1 given in %s on line %d
90
91Warning: ldap_explode_dn() expects exactly 2 parameters, 3 given in %s on line %d
92bool(false)
93bool(false)
94Done
95