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