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