summaryrefslogtreecommitdiff
path: root/ext/ldap/tests/ldap_sort_basic.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/ldap/tests/ldap_sort_basic.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/ldap/tests/ldap_sort_basic.phpt')
-rw-r--r--ext/ldap/tests/ldap_sort_basic.phpt200
1 files changed, 200 insertions, 0 deletions
diff --git a/ext/ldap/tests/ldap_sort_basic.phpt b/ext/ldap/tests/ldap_sort_basic.phpt
new file mode 100644
index 0000000..f6ee5d1
--- /dev/null
+++ b/ext/ldap/tests/ldap_sort_basic.phpt
@@ -0,0 +1,200 @@
+--TEST--
+ldap_sort() - Basic ldap_sort test
+--CREDITS--
+Patrick Allaert <patrickallaert@php.net>
+# Belgian PHP Testfest 2009
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+<?php require_once('skipifbindfailure.inc'); ?>
+--FILE--
+<?php
+require "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+insert_dummy_data($link);
+ldap_add($link, "cn=userC,dc=my-domain,dc=com", array(
+ "objectclass" => "person",
+ "cn" => "userC",
+ "sn" => "zzz",
+ "userPassword" => "oops",
+ "description" => "a user",
+));
+ldap_add($link, "cn=userD,dc=my-domain,dc=com", array(
+ "objectclass" => "person",
+ "cn" => "userD",
+ "sn" => "aaa",
+ "userPassword" => "oops",
+ "description" => "another user",
+));
+ldap_add($link, "cn=userE,dc=my-domain,dc=com", array(
+ "objectclass" => "person",
+ "cn" => "userE",
+ "sn" => "a",
+ "userPassword" => "oops",
+ "description" => "yet another user",
+));
+$result = ldap_search($link, "dc=my-domain,dc=com", "(objectclass=person)", array("sn", "description"));
+var_dump(
+ ldap_sort($link, $result, "sn"),
+ ldap_get_entries($link, $result)
+);
+?>
+===DONE===
+--CLEAN--
+<?php
+include "connect.inc";
+
+$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
+ldap_delete($link, "cn=userC,dc=my-domain,dc=com");
+ldap_delete($link, "cn=userD,dc=my-domain,dc=com");
+ldap_delete($link, "cn=userE,dc=my-domain,dc=com");
+remove_dummy_data($link);
+?>
+--EXPECT--
+bool(true)
+array(7) {
+ ["count"]=>
+ int(6)
+ [0]=>
+ array(6) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(1) "a"
+ }
+ [0]=>
+ string(2) "sn"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(16) "yet another user"
+ }
+ [1]=>
+ string(11) "description"
+ ["count"]=>
+ int(2)
+ ["dn"]=>
+ string(28) "cn=userE,dc=my-domain,dc=com"
+ }
+ [1]=>
+ array(6) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(3) "aaa"
+ }
+ [0]=>
+ string(2) "sn"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(12) "another user"
+ }
+ [1]=>
+ string(11) "description"
+ ["count"]=>
+ int(2)
+ ["dn"]=>
+ string(28) "cn=userD,dc=my-domain,dc=com"
+ }
+ [2]=>
+ array(6) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(7) "testSN1"
+ }
+ [0]=>
+ string(2) "sn"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(6) "user A"
+ }
+ [1]=>
+ string(11) "description"
+ ["count"]=>
+ int(2)
+ ["dn"]=>
+ string(28) "cn=userA,dc=my-domain,dc=com"
+ }
+ [3]=>
+ array(6) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(7) "testSN2"
+ }
+ [0]=>
+ string(2) "sn"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(6) "user B"
+ }
+ [1]=>
+ string(11) "description"
+ ["count"]=>
+ int(2)
+ ["dn"]=>
+ string(28) "cn=userB,dc=my-domain,dc=com"
+ }
+ [4]=>
+ array(4) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(7) "testSN3"
+ }
+ [0]=>
+ string(2) "sn"
+ ["count"]=>
+ int(1)
+ ["dn"]=>
+ string(37) "cn=userC,cn=userB,dc=my-domain,dc=com"
+ }
+ [5]=>
+ array(6) {
+ ["sn"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(3) "zzz"
+ }
+ [0]=>
+ string(2) "sn"
+ ["description"]=>
+ array(2) {
+ ["count"]=>
+ int(1)
+ [0]=>
+ string(6) "a user"
+ }
+ [1]=>
+ string(11) "description"
+ ["count"]=>
+ int(2)
+ ["dn"]=>
+ string(28) "cn=userC,dc=my-domain,dc=com"
+ }
+}
+===DONE===