xref: /PHP-7.0/ext/ldap/tests/ldap_sort_basic.phpt (revision 667e9bd4)
1--TEST--
2ldap_sort() - Basic ldap_sort test
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);
14insert_dummy_data($link, $base);
15ldap_add($link, "cn=userC,$base", array(
16	"objectclass" => "person",
17	"cn" => "userC",
18	"sn" => "zzz",
19	"userPassword" => "oops",
20	"description" => "a user",
21));
22ldap_add($link, "cn=userD,$base", array(
23	"objectclass" => "person",
24	"cn" => "userD",
25	"sn" => "aaa",
26	"userPassword" => "oops",
27	"description" => "another user",
28));
29ldap_add($link, "cn=userE,$base", array(
30	"objectclass" => "person",
31	"cn" => "userE",
32	"sn" => "a",
33	"userPassword" => "oops",
34	"description" => "yet another user",
35));
36$result = ldap_search($link, "$base", "(objectclass=person)", array("sn", "description"));
37var_dump(
38	ldap_sort($link, $result, "sn"),
39	ldap_get_entries($link, $result)
40);
41?>
42===DONE===
43--CLEAN--
44<?php
45include "connect.inc";
46
47$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
48ldap_delete($link, "cn=userC,$base");
49ldap_delete($link, "cn=userD,$base");
50ldap_delete($link, "cn=userE,$base");
51remove_dummy_data($link, $base);
52?>
53--EXPECTF--
54Deprecated: Function ldap_sort() is deprecated in %s.php on line %d
55bool(true)
56array(7) {
57  ["count"]=>
58  int(6)
59  [0]=>
60  array(6) {
61    ["sn"]=>
62    array(2) {
63      ["count"]=>
64      int(1)
65      [0]=>
66      string(1) "a"
67    }
68    [0]=>
69    string(2) "sn"
70    ["description"]=>
71    array(2) {
72      ["count"]=>
73      int(1)
74      [0]=>
75      string(16) "yet another user"
76    }
77    [1]=>
78    string(11) "description"
79    ["count"]=>
80    int(2)
81    ["dn"]=>
82    string(%d) "cn=userE,%s"
83  }
84  [1]=>
85  array(6) {
86    ["sn"]=>
87    array(2) {
88      ["count"]=>
89      int(1)
90      [0]=>
91      string(3) "aaa"
92    }
93    [0]=>
94    string(2) "sn"
95    ["description"]=>
96    array(2) {
97      ["count"]=>
98      int(1)
99      [0]=>
100      string(12) "another user"
101    }
102    [1]=>
103    string(11) "description"
104    ["count"]=>
105    int(2)
106    ["dn"]=>
107    string(%d) "cn=userD,%s"
108  }
109  [2]=>
110  array(6) {
111    ["sn"]=>
112    array(2) {
113      ["count"]=>
114      int(1)
115      [0]=>
116      string(7) "testSN1"
117    }
118    [0]=>
119    string(2) "sn"
120    ["description"]=>
121    array(2) {
122      ["count"]=>
123      int(1)
124      [0]=>
125      string(6) "user A"
126    }
127    [1]=>
128    string(11) "description"
129    ["count"]=>
130    int(2)
131    ["dn"]=>
132    string(%d) "cn=userA,%s"
133  }
134  [3]=>
135  array(6) {
136    ["sn"]=>
137    array(2) {
138      ["count"]=>
139      int(1)
140      [0]=>
141      string(7) "testSN2"
142    }
143    [0]=>
144    string(2) "sn"
145    ["description"]=>
146    array(2) {
147      ["count"]=>
148      int(1)
149      [0]=>
150      string(6) "user B"
151    }
152    [1]=>
153    string(11) "description"
154    ["count"]=>
155    int(2)
156    ["dn"]=>
157    string(%d) "cn=userB,%s"
158  }
159  [4]=>
160  array(4) {
161    ["sn"]=>
162    array(2) {
163      ["count"]=>
164      int(1)
165      [0]=>
166      string(7) "testSN3"
167    }
168    [0]=>
169    string(2) "sn"
170    ["count"]=>
171    int(1)
172    ["dn"]=>
173    string(%d) "cn=userC,cn=userB,%s"
174  }
175  [5]=>
176  array(6) {
177    ["sn"]=>
178    array(2) {
179      ["count"]=>
180      int(1)
181      [0]=>
182      string(3) "zzz"
183    }
184    [0]=>
185    string(2) "sn"
186    ["description"]=>
187    array(2) {
188      ["count"]=>
189      int(1)
190      [0]=>
191      string(6) "a user"
192    }
193    [1]=>
194    string(11) "description"
195    ["count"]=>
196    int(2)
197    ["dn"]=>
198    string(%d) "cn=userC,%s"
199  }
200}
201===DONE===
202