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, "description"),
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(4) {
61    ["sn"]=>
62    array(2) {
63      ["count"]=>
64      int(1)
65      [0]=>
66      string(7) "testSN3"
67    }
68    [0]=>
69    string(2) "sn"
70    ["count"]=>
71    int(1)
72    ["dn"]=>
73    string(%d) "cn=userC,cn=userB,%s"
74  }
75  [1]=>
76  array(6) {
77    ["sn"]=>
78    array(2) {
79      ["count"]=>
80      int(1)
81      [0]=>
82      string(3) "zzz"
83    }
84    [0]=>
85    string(2) "sn"
86    ["description"]=>
87    array(2) {
88      ["count"]=>
89      int(1)
90      [0]=>
91      string(6) "a user"
92    }
93    [1]=>
94    string(11) "description"
95    ["count"]=>
96    int(2)
97    ["dn"]=>
98    string(%d) "cn=userC,%s"
99  }
100  [2]=>
101  array(6) {
102    ["sn"]=>
103    array(2) {
104      ["count"]=>
105      int(1)
106      [0]=>
107      string(3) "aaa"
108    }
109    [0]=>
110    string(2) "sn"
111    ["description"]=>
112    array(2) {
113      ["count"]=>
114      int(1)
115      [0]=>
116      string(12) "another user"
117    }
118    [1]=>
119    string(11) "description"
120    ["count"]=>
121    int(2)
122    ["dn"]=>
123    string(%d) "cn=userD,%s"
124  }
125  [3]=>
126  array(6) {
127    ["sn"]=>
128    array(2) {
129      ["count"]=>
130      int(1)
131      [0]=>
132      string(7) "testSN1"
133    }
134    [0]=>
135    string(2) "sn"
136    ["description"]=>
137    array(2) {
138      ["count"]=>
139      int(1)
140      [0]=>
141      string(6) "user A"
142    }
143    [1]=>
144    string(11) "description"
145    ["count"]=>
146    int(2)
147    ["dn"]=>
148    string(%d) "cn=userA,%s"
149  }
150  [4]=>
151  array(6) {
152    ["sn"]=>
153    array(2) {
154      ["count"]=>
155      int(1)
156      [0]=>
157      string(7) "testSN2"
158    }
159    [0]=>
160    string(2) "sn"
161    ["description"]=>
162    array(2) {
163      ["count"]=>
164      int(1)
165      [0]=>
166      string(6) "user B"
167    }
168    [1]=>
169    string(11) "description"
170    ["count"]=>
171    int(2)
172    ["dn"]=>
173    string(%d) "cn=userB,%s"
174  }
175  [5]=>
176  array(6) {
177    ["sn"]=>
178    array(2) {
179      ["count"]=>
180      int(1)
181      [0]=>
182      string(1) "a"
183    }
184    [0]=>
185    string(2) "sn"
186    ["description"]=>
187    array(2) {
188      ["count"]=>
189      int(1)
190      [0]=>
191      string(16) "yet another user"
192    }
193    [1]=>
194    string(11) "description"
195    ["count"]=>
196    int(2)
197    ["dn"]=>
198    string(%d) "cn=userE,%s"
199  }
200}
201===DONE===
202