From ad07fa214ece383f361a90f71bd164147bcf0991 Mon Sep 17 00:00:00 2001 From: Patrick Allaert Date: Fri, 3 Jul 2009 10:57:04 +0000 Subject: [PATCH] MFH: Tests for ext/ldap from PHPBelgium TestFest --- ext/ldap/tests/README | 53 ++++ ext/ldap/tests/ldap_add_basic.phpt | 83 +++++++ ext/ldap/tests/ldap_add_error.phpt | 136 +++++++++++ ext/ldap/tests/ldap_bind_basic.phpt | 19 ++ ext/ldap/tests/ldap_bind_error.phpt | 35 +++ ext/ldap/tests/ldap_bind_variation.phpt | 19 ++ ext/ldap/tests/ldap_compare_basic.phpt | 31 +++ ext/ldap/tests/ldap_compare_error.phpt | 55 +++++ ext/ldap/tests/ldap_connect_basic.phpt | 18 ++ ext/ldap/tests/ldap_connect_error.phpt | 31 +++ ext/ldap/tests/ldap_connect_variation.phpt | 39 +++ ext/ldap/tests/ldap_count_entries_basic.phpt | 28 +++ ext/ldap/tests/ldap_count_entries_error.phpt | 23 ++ ext/ldap/tests/ldap_delete_basic.phpt | 40 +++ ext/ldap/tests/ldap_delete_error.phpt | 62 +++++ ext/ldap/tests/ldap_err2str_basic.phpt | 15 ++ ext/ldap/tests/ldap_err2str_error.phpt | 23 ++ ext/ldap/tests/ldap_errno_basic.phpt | 30 +++ ext/ldap/tests/ldap_errno_error.phpt | 23 ++ ext/ldap/tests/ldap_error_basic.phpt | 30 +++ ext/ldap/tests/ldap_error_error.phpt | 23 ++ .../tests/ldap_first_attribute_basic.phpt | 31 +++ .../tests/ldap_first_attribute_error.phpt | 23 ++ ext/ldap/tests/ldap_first_entry_basic.phpt | 37 +++ ext/ldap/tests/ldap_first_entry_error.phpt | 27 ++ .../tests/ldap_first_reference_basic.phpt | 43 ++++ .../tests/ldap_first_reference_error.phpt | 27 ++ ext/ldap/tests/ldap_free_result_basic.phpt | 28 +++ ext/ldap/tests/ldap_free_result_error.phpt | 23 ++ ext/ldap/tests/ldap_get_attributes_basic.phpt | 65 +++++ ext/ldap/tests/ldap_get_attributes_error.phpt | 23 ++ ext/ldap/tests/ldap_get_dn_basic.phpt | 31 +++ ext/ldap/tests/ldap_get_dn_error.phpt | 23 ++ ext/ldap/tests/ldap_get_entries_basic.phpt | 74 ++++++ ext/ldap/tests/ldap_get_entries_error.phpt | 33 +++ .../tests/ldap_get_entries_variation.phpt | 33 +++ ext/ldap/tests/ldap_get_option_basic.phpt | 25 ++ ext/ldap/tests/ldap_get_option_error.phpt | 40 +++ ext/ldap/tests/ldap_get_option_variation.phpt | 61 +++++ ext/ldap/tests/ldap_get_values_len_basic.phpt | 36 +++ ext/ldap/tests/ldap_get_values_len_error.phpt | 45 ++++ ext/ldap/tests/ldap_list_basic.phpt | 150 ++++++++++++ ext/ldap/tests/ldap_list_error.phpt | 35 +++ ext/ldap/tests/ldap_mod_add_basic.phpt | 90 +++++++ ext/ldap/tests/ldap_mod_add_error.phpt | 83 +++++++ ext/ldap/tests/ldap_mod_del_basic.phpt | 40 +++ ext/ldap/tests/ldap_mod_del_error.phpt | 62 +++++ ext/ldap/tests/ldap_mod_replace_basic.phpt | 59 +++++ ext/ldap/tests/ldap_mod_replace_error.phpt | 62 +++++ ext/ldap/tests/ldap_modify_basic.phpt | 96 ++++++++ ext/ldap/tests/ldap_modify_error.phpt | 83 +++++++ ext/ldap/tests/ldap_next_attribute_basic.phpt | 36 +++ ext/ldap/tests/ldap_next_attribute_error.phpt | 40 +++ ext/ldap/tests/ldap_next_entry_basic.phpt | 40 +++ ext/ldap/tests/ldap_next_entry_error.phpt | 27 ++ ext/ldap/tests/ldap_next_reference_basic.phpt | 49 ++++ ext/ldap/tests/ldap_next_reference_error.phpt | 27 ++ .../tests/ldap_parse_reference_basic.phpt | 45 ++++ .../tests/ldap_parse_reference_error.phpt | 31 +++ ext/ldap/tests/ldap_parse_result_basic.phpt | 47 ++++ ext/ldap/tests/ldap_parse_result_error.phpt | 17 ++ ext/ldap/tests/ldap_read_basic.phpt | 75 ++++++ ext/ldap/tests/ldap_read_error.phpt | 35 +++ ext/ldap/tests/ldap_rename_basic.phpt | 62 +++++ ext/ldap/tests/ldap_rename_error.phpt | 21 ++ ext/ldap/tests/ldap_sasl_bind_basic.phpt | 20 ++ ext/ldap/tests/ldap_sasl_bind_error.phpt | 53 ++++ ext/ldap/tests/ldap_search_basic.phpt | 194 +++++++++++++++ ext/ldap/tests/ldap_search_error.phpt | 62 +++++ ext/ldap/tests/ldap_search_variation1.phpt | 56 +++++ ext/ldap/tests/ldap_search_variation2.phpt | 80 ++++++ ext/ldap/tests/ldap_search_variation3.phpt | 108 ++++++++ ext/ldap/tests/ldap_search_variation4.phpt | 55 +++++ ext/ldap/tests/ldap_search_variation5.phpt | 105 ++++++++ ext/ldap/tests/ldap_search_variation6.phpt | 230 ++++++++++++++++++ ext/ldap/tests/ldap_set_option_basic.phpt | 23 ++ ext/ldap/tests/ldap_set_option_error.phpt | 66 +++++ ext/ldap/tests/ldap_set_option_variation.phpt | 77 ++++++ .../tests/ldap_set_rebind_proc_basic.phpt | 34 +++ .../tests/ldap_set_rebind_proc_error.phpt | 40 +++ ext/ldap/tests/ldap_sort_basic.phpt | 200 +++++++++++++++ ext/ldap/tests/ldap_sort_error.phpt | 35 +++ ext/ldap/tests/ldap_sort_variation.phpt | 200 +++++++++++++++ ext/ldap/tests/ldap_start_tls_basic.phpt | 19 ++ ext/ldap/tests/ldap_start_tls_error.phpt | 27 ++ ext/ldap/tests/ldap_unbind_basic.phpt | 20 ++ ext/ldap/tests/ldap_unbind_error.phpt | 42 ++++ ext/ldap/tests/ldap_unbind_variation.phpt | 34 +++ 88 files changed, 4636 insertions(+) create mode 100644 ext/ldap/tests/README create mode 100644 ext/ldap/tests/ldap_add_basic.phpt create mode 100644 ext/ldap/tests/ldap_add_error.phpt create mode 100644 ext/ldap/tests/ldap_bind_basic.phpt create mode 100644 ext/ldap/tests/ldap_bind_error.phpt create mode 100644 ext/ldap/tests/ldap_bind_variation.phpt create mode 100644 ext/ldap/tests/ldap_compare_basic.phpt create mode 100644 ext/ldap/tests/ldap_compare_error.phpt create mode 100644 ext/ldap/tests/ldap_connect_basic.phpt create mode 100644 ext/ldap/tests/ldap_connect_error.phpt create mode 100644 ext/ldap/tests/ldap_connect_variation.phpt create mode 100644 ext/ldap/tests/ldap_count_entries_basic.phpt create mode 100644 ext/ldap/tests/ldap_count_entries_error.phpt create mode 100644 ext/ldap/tests/ldap_delete_basic.phpt create mode 100644 ext/ldap/tests/ldap_delete_error.phpt create mode 100644 ext/ldap/tests/ldap_err2str_basic.phpt create mode 100644 ext/ldap/tests/ldap_err2str_error.phpt create mode 100644 ext/ldap/tests/ldap_errno_basic.phpt create mode 100644 ext/ldap/tests/ldap_errno_error.phpt create mode 100644 ext/ldap/tests/ldap_error_basic.phpt create mode 100644 ext/ldap/tests/ldap_error_error.phpt create mode 100644 ext/ldap/tests/ldap_first_attribute_basic.phpt create mode 100644 ext/ldap/tests/ldap_first_attribute_error.phpt create mode 100644 ext/ldap/tests/ldap_first_entry_basic.phpt create mode 100644 ext/ldap/tests/ldap_first_entry_error.phpt create mode 100644 ext/ldap/tests/ldap_first_reference_basic.phpt create mode 100644 ext/ldap/tests/ldap_first_reference_error.phpt create mode 100644 ext/ldap/tests/ldap_free_result_basic.phpt create mode 100644 ext/ldap/tests/ldap_free_result_error.phpt create mode 100644 ext/ldap/tests/ldap_get_attributes_basic.phpt create mode 100644 ext/ldap/tests/ldap_get_attributes_error.phpt create mode 100644 ext/ldap/tests/ldap_get_dn_basic.phpt create mode 100644 ext/ldap/tests/ldap_get_dn_error.phpt create mode 100644 ext/ldap/tests/ldap_get_entries_basic.phpt create mode 100644 ext/ldap/tests/ldap_get_entries_error.phpt create mode 100644 ext/ldap/tests/ldap_get_entries_variation.phpt create mode 100644 ext/ldap/tests/ldap_get_option_basic.phpt create mode 100644 ext/ldap/tests/ldap_get_option_error.phpt create mode 100644 ext/ldap/tests/ldap_get_option_variation.phpt create mode 100644 ext/ldap/tests/ldap_get_values_len_basic.phpt create mode 100644 ext/ldap/tests/ldap_get_values_len_error.phpt create mode 100644 ext/ldap/tests/ldap_list_basic.phpt create mode 100644 ext/ldap/tests/ldap_list_error.phpt create mode 100644 ext/ldap/tests/ldap_mod_add_basic.phpt create mode 100644 ext/ldap/tests/ldap_mod_add_error.phpt create mode 100644 ext/ldap/tests/ldap_mod_del_basic.phpt create mode 100644 ext/ldap/tests/ldap_mod_del_error.phpt create mode 100644 ext/ldap/tests/ldap_mod_replace_basic.phpt create mode 100644 ext/ldap/tests/ldap_mod_replace_error.phpt create mode 100644 ext/ldap/tests/ldap_modify_basic.phpt create mode 100644 ext/ldap/tests/ldap_modify_error.phpt create mode 100644 ext/ldap/tests/ldap_next_attribute_basic.phpt create mode 100644 ext/ldap/tests/ldap_next_attribute_error.phpt create mode 100644 ext/ldap/tests/ldap_next_entry_basic.phpt create mode 100644 ext/ldap/tests/ldap_next_entry_error.phpt create mode 100644 ext/ldap/tests/ldap_next_reference_basic.phpt create mode 100644 ext/ldap/tests/ldap_next_reference_error.phpt create mode 100644 ext/ldap/tests/ldap_parse_reference_basic.phpt create mode 100644 ext/ldap/tests/ldap_parse_reference_error.phpt create mode 100644 ext/ldap/tests/ldap_parse_result_basic.phpt create mode 100644 ext/ldap/tests/ldap_parse_result_error.phpt create mode 100644 ext/ldap/tests/ldap_read_basic.phpt create mode 100644 ext/ldap/tests/ldap_read_error.phpt create mode 100644 ext/ldap/tests/ldap_rename_basic.phpt create mode 100644 ext/ldap/tests/ldap_rename_error.phpt create mode 100644 ext/ldap/tests/ldap_sasl_bind_basic.phpt create mode 100644 ext/ldap/tests/ldap_sasl_bind_error.phpt create mode 100644 ext/ldap/tests/ldap_search_basic.phpt create mode 100644 ext/ldap/tests/ldap_search_error.phpt create mode 100644 ext/ldap/tests/ldap_search_variation1.phpt create mode 100644 ext/ldap/tests/ldap_search_variation2.phpt create mode 100644 ext/ldap/tests/ldap_search_variation3.phpt create mode 100644 ext/ldap/tests/ldap_search_variation4.phpt create mode 100644 ext/ldap/tests/ldap_search_variation5.phpt create mode 100644 ext/ldap/tests/ldap_search_variation6.phpt create mode 100644 ext/ldap/tests/ldap_set_option_basic.phpt create mode 100644 ext/ldap/tests/ldap_set_option_error.phpt create mode 100644 ext/ldap/tests/ldap_set_option_variation.phpt create mode 100644 ext/ldap/tests/ldap_set_rebind_proc_basic.phpt create mode 100644 ext/ldap/tests/ldap_set_rebind_proc_error.phpt create mode 100644 ext/ldap/tests/ldap_sort_basic.phpt create mode 100644 ext/ldap/tests/ldap_sort_error.phpt create mode 100644 ext/ldap/tests/ldap_sort_variation.phpt create mode 100644 ext/ldap/tests/ldap_start_tls_basic.phpt create mode 100644 ext/ldap/tests/ldap_start_tls_error.phpt create mode 100644 ext/ldap/tests/ldap_unbind_basic.phpt create mode 100644 ext/ldap/tests/ldap_unbind_error.phpt create mode 100644 ext/ldap/tests/ldap_unbind_variation.phpt diff --git a/ext/ldap/tests/README b/ext/ldap/tests/README new file mode 100644 index 0000000000..7dccd270f3 --- /dev/null +++ b/ext/ldap/tests/README @@ -0,0 +1,53 @@ +Most tests here relies on the availability of an LDAP server configured with TLS. + +Client/Server configuration: +=========================================================== +OpenLDAP 2.3.43 has been used with the configuration below. + +Notes: +1. A self signed certificate can be generated using: + $ openssl req -newkey rsa:1024 -x509 -nodes -out server.pem -keyout server.pem -days 3650 + It is used for testing ldap_start_tls(), which also requires "TLS_REQCERT never" in client configuration +2. An empty LDAP structure is required for the tests to be PASSed + +(/etc/openldap/)slapd.conf: +----------------------------------------------------------- +TLSCACertificateFile /etc/openldap/ssl/server.pem +TLSCertificateFile /etc/openldap/ssl/server.pem +TLSCertificateKeyFile /etc/openldap/ssl/server.pem +TLSVerifyClient never + +# hdb is used instead of bdb as it enables the usage of referrals & aliases +database hdb +suffix "dc=my-domain,dc=com" +checkpoint 32 30 +rootdn "cn=Manager,dc=my-domain,dc=com" +rootpw secret +directory /var/lib/openldap-data +index objectClass eq + +authz-regexp + uid=Manager,cn=digest-md5,cn=auth + cn=Manager,dc=my-domain,dc=com + + +(/etc/openldap/)ldap.conf: +----------------------------------------------------------- +TLS_REQCERT never + +Tests configuration: +=========================================================== +The following environment variables may be defined: +LDAP_TEST_HOST (default: localhost) Host to connect to +LDAP_TEST_PORT (default: 389) Port to connect to +LDAP_TEST_USER (default: cn=Manager,dc=my-domain,dc=com) DN used for binding +LDAP_TEST_SASL_USER (default: Manager) SASL user used for SASL binding +LDAP_TEST_PASSWD (default: secret) Password used for plain and SASL binding +LDAP_TEST_OPT_PROTOCOL_VERSION (default: 3) Version of LDAP protocol to use +LDAP_TEST_SKIP_BIND_FAILURE (default: true) Whether to fail the test or not in case binding fails + +Credits: +=========================================================== +Davide Mendolia +Patrick Allaert + diff --git a/ext/ldap/tests/ldap_add_basic.phpt b/ext/ldap/tests/ldap_add_basic.phpt new file mode 100644 index 0000000000..ca65e4986d --- /dev/null +++ b/ext/ldap/tests/ldap_add_basic.phpt @@ -0,0 +1,83 @@ +--TEST-- +ldap_add() - Basic add operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + )), + ldap_get_entries( + $link, + ldap_search($link, "dc=my-domain,dc=com", "(o=my-domain)") + ) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(2) { + ["count"]=> + int(1) + [0]=> + array(8) { + ["objectclass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectclass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["count"]=> + int(3) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_add_error.phpt b/ext/ldap/tests/ldap_add_error.phpt new file mode 100644 index 0000000000..943c1a506d --- /dev/null +++ b/ext/ldap/tests/ldap_add_error.phpt @@ -0,0 +1,136 @@ +--TEST-- +ldap_add() - Add operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "val", + )), + ldap_error($link), + ldap_errno($link) +); + +// Duplicate entry +for ($i = 0; $i < 2; $i++) + var_dump( + ldap_add($link, "dc=my-domain,dc=com", array( + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + )) + ); +var_dump(ldap_error($link), ldap_errno($link)); + +// Wrong array indexes +var_dump( + ldap_add($link, "dc=my-domain2,dc=com", array( + "objectClass" => array( + 0 => "top", + 2 => "dcObject", + 5 => "organization"), + "dc" => "my-domain", + "o" => "my-domain", + )) + /* Is this correct behaviour to still have "Already exists" as error/errno? + , + ldap_error($link), + ldap_errno($link) + */ +); + +// Invalid attribute +var_dump( + ldap_add($link, "dc=my-domain,dc=com", array( + "objectClass" => array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + "weirdAttr" => "weirdVal", + )), + ldap_error($link), + ldap_errno($link) +); + +var_dump( + ldap_add($link, "dc=my-domain,dc=com", array(array( "Oops" + ))) + /* Is this correct behaviour to still have "Undefined attribute type" as error/errno? + , + ldap_error($link), + ldap_errno($link) + */ +); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_add() in %s on line %d +NULL + +Warning: ldap_add(): Add: Protocol error in %s on line %d +bool(false) + +Warning: ldap_add(): Add: Invalid DN syntax in %s on line %d +bool(false) +string(17) "Invalid DN syntax" +int(34) +bool(true) + +Warning: ldap_add(): Add: Already exists in %s on line %d +bool(false) +string(14) "Already exists" +int(68) + +Warning: ldap_add(): Value array must have consecutive indices 0, 1, ... in %s on line %d +bool(false) + +Warning: ldap_add(): Add: Undefined attribute type in %s on line %d +bool(false) +string(24) "Undefined attribute type" +int(17) + +Warning: ldap_add(): Unknown attribute in the data in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_bind_basic.phpt b/ext/ldap/tests/ldap_bind_basic.phpt new file mode 100644 index 0000000000..bac8d0d112 --- /dev/null +++ b/ext/ldap/tests/ldap_bind_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +ldap_bind() - Basic anonymous binding +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_bind_error.phpt b/ext/ldap/tests/ldap_bind_error.phpt new file mode 100644 index 0000000000..a569ce6922 --- /dev/null +++ b/ext/ldap/tests/ldap_bind_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +ldap_bind() - Binding that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_bind() expects at most 3 parameters, 4 given in %s on line %d +bool(false) + +Warning: ldap_bind(): Unable to bind to server: Invalid credentials in %s on line %d +bool(false) + +Warning: ldap_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_bind_variation.phpt b/ext/ldap/tests/ldap_bind_variation.phpt new file mode 100644 index 0000000000..64abf6cbb7 --- /dev/null +++ b/ext/ldap/tests/ldap_bind_variation.phpt @@ -0,0 +1,19 @@ +--TEST-- +ldap_bind() - Advanced binding +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_compare_basic.phpt b/ext/ldap/tests/ldap_compare_basic.phpt new file mode 100644 index 0000000000..b0c5e97fb6 --- /dev/null +++ b/ext/ldap/tests/ldap_compare_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +ldap_compare() - Basic ldap_compare test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_compare_error.phpt b/ext/ldap/tests/ldap_compare_error.phpt new file mode 100644 index 0000000000..15505eddb4 --- /dev/null +++ b/ext/ldap/tests/ldap_compare_error.phpt @@ -0,0 +1,55 @@ +--TEST-- +ldap_compare() - Testing ldap_compare() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_compare() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_compare() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_compare() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_compare() in %s on line %d +NULL + +Warning: ldap_compare(): Compare: No such object in %s on line %d +int(-1) +string(14) "No such object" +int(32) +===DONE=== diff --git a/ext/ldap/tests/ldap_connect_basic.phpt b/ext/ldap/tests/ldap_connect_basic.phpt new file mode 100644 index 0000000000..26133a6b2e --- /dev/null +++ b/ext/ldap/tests/ldap_connect_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +ldap_connect() - Basic connection +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +resource(%d) of type (ldap link) +===DONE=== diff --git a/ext/ldap/tests/ldap_connect_error.phpt b/ext/ldap/tests/ldap_connect_error.phpt new file mode 100644 index 0000000000..fa28fcf077 --- /dev/null +++ b/ext/ldap/tests/ldap_connect_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +ldap_connect() - Connection errors +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--INI-- +ldap.max_links=1 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_connect() expects at most 2 parameters, 3 given in %s on line %d +bool(false) + +Warning: ldap_connect(): Could not create session handle: %s in %s on line %d +bool(false) + +Warning: ldap_connect(): Too many open links (1) in %s on line %d +===DONE=== diff --git a/ext/ldap/tests/ldap_connect_variation.phpt b/ext/ldap/tests/ldap_connect_variation.phpt new file mode 100644 index 0000000000..09b07e7786 --- /dev/null +++ b/ext/ldap/tests/ldap_connect_variation.phpt @@ -0,0 +1,39 @@ +--TEST-- +ldap_connect() - Variation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +resource(%d) of type (ldap link) +resource(%d) of type (ldap link) +resource(%d) of type (ldap link) +resource(%d) of type (ldap link) +resource(%d) of type (ldap link) +===DONE=== diff --git a/ext/ldap/tests/ldap_count_entries_basic.phpt b/ext/ldap/tests/ldap_count_entries_basic.phpt new file mode 100644 index 0000000000..a03f0596e9 --- /dev/null +++ b/ext/ldap/tests/ldap_count_entries_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +ldap_count_entries() - Basic counting LDAP entries +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +int(3) +===DONE=== diff --git a/ext/ldap/tests/ldap_count_entries_error.phpt b/ext/ldap/tests/ldap_count_entries_error.phpt new file mode 100644 index 0000000000..c81be7bb13 --- /dev/null +++ b/ext/ldap/tests/ldap_count_entries_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_count_entries() - Testing counting LDAP entries that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_count_entries() in %s on line %d +NULL + +Warning: ldap_count_entries(): supplied resource is not a valid ldap result resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_delete_basic.phpt b/ext/ldap/tests/ldap_delete_basic.phpt new file mode 100644 index 0000000000..1457384784 --- /dev/null +++ b/ext/ldap/tests/ldap_delete_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_delete() - Basic delete operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", +)); + +var_dump( + ldap_delete($link, "dc=my-domain,dc=com"), + @ldap_search($link, "dc=my-domain,dc=com", "(o=my-domain)") +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_delete_error.phpt b/ext/ldap/tests/ldap_delete_error.phpt new file mode 100644 index 0000000000..34aa03dbf3 --- /dev/null +++ b/ext/ldap/tests/ldap_delete_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +ldap_delete() - Delete operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_delete() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_delete() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_delete() in %s on line %d +NULL + +Warning: ldap_delete(): Delete: Invalid DN syntax in %s on line %d +bool(false) +string(17) "Invalid DN syntax" +int(34) + +Warning: ldap_delete(): Delete: No such object in %s on line %d +bool(false) +string(14) "No such object" +int(32) +===DONE=== diff --git a/ext/ldap/tests/ldap_err2str_basic.phpt b/ext/ldap/tests/ldap_err2str_basic.phpt new file mode 100644 index 0000000000..0ecad03402 --- /dev/null +++ b/ext/ldap/tests/ldap_err2str_basic.phpt @@ -0,0 +1,15 @@ +--TEST-- +ldap_err2str() - Basic error number to string conversion +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +string(14) "Protocol error" +===DONE=== diff --git a/ext/ldap/tests/ldap_err2str_error.phpt b/ext/ldap/tests/ldap_err2str_error.phpt new file mode 100644 index 0000000000..103df75d94 --- /dev/null +++ b/ext/ldap/tests/ldap_err2str_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_err2str() - Incorrect usage of number to string conversion +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_err2str() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_err2str() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_errno_basic.phpt b/ext/ldap/tests/ldap_errno_basic.phpt new file mode 100644 index 0000000000..4b02ac6d65 --- /dev/null +++ b/ext/ldap/tests/ldap_errno_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +ldap_errno() - Basic ldap_errno() operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", +)); + +var_dump( + ldap_errno($link) +); +?> +===DONE=== +--EXPECT-- +int(34) +===DONE=== diff --git a/ext/ldap/tests/ldap_errno_error.phpt b/ext/ldap/tests/ldap_errno_error.phpt new file mode 100644 index 0000000000..686cd84606 --- /dev/null +++ b/ext/ldap/tests/ldap_errno_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_errno() - ldap_errno() operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_errno() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_errno() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_error_basic.phpt b/ext/ldap/tests/ldap_error_basic.phpt new file mode 100644 index 0000000000..64e4ef6170 --- /dev/null +++ b/ext/ldap/tests/ldap_error_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +ldap_error() - Basic ldap_error() operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", +)); + +var_dump( + ldap_error($link) +); +?> +===DONE=== +--EXPECT-- +string(17) "Invalid DN syntax" +===DONE=== diff --git a/ext/ldap/tests/ldap_error_error.phpt b/ext/ldap/tests/ldap_error_error.phpt new file mode 100644 index 0000000000..8f0bf2d654 --- /dev/null +++ b/ext/ldap/tests/ldap_error_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_error() - ldap_error() operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_error() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_error() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_first_attribute_basic.phpt b/ext/ldap/tests/ldap_first_attribute_basic.phpt new file mode 100644 index 0000000000..8e506fae8f --- /dev/null +++ b/ext/ldap/tests/ldap_first_attribute_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +ldap_first_attribute() - Basic ldap_first_attribute test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +string(11) "objectClass" +===DONE=== diff --git a/ext/ldap/tests/ldap_first_attribute_error.phpt b/ext/ldap/tests/ldap_first_attribute_error.phpt new file mode 100644 index 0000000000..e6df3fd6fc --- /dev/null +++ b/ext/ldap/tests/ldap_first_attribute_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_first_attribute() - Testing ldap_first_attribute() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_first_attribute() in %s on line %d +NULL + +Warning: ldap_first_attribute(): supplied resource is not a valid ldap result entry resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_first_entry_basic.phpt b/ext/ldap/tests/ldap_first_entry_basic.phpt new file mode 100644 index 0000000000..9b658227e7 --- /dev/null +++ b/ext/ldap/tests/ldap_first_entry_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +ldap_first_entry() - Basic ldap_first_entry test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result entry) +array(2) { + [0]=> + string(7) "testSN%d" + ["count"]=> + int(1) +} +===DONE=== diff --git a/ext/ldap/tests/ldap_first_entry_error.phpt b/ext/ldap/tests/ldap_first_entry_error.phpt new file mode 100644 index 0000000000..f4d91c45db --- /dev/null +++ b/ext/ldap/tests/ldap_first_entry_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +ldap_first_entry() - Testing ldap_first_entry() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_first_entry() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_first_entry() in %s on line %d +NULL + +Warning: ldap_first_entry(): supplied resource is not a valid ldap result resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_first_reference_basic.phpt b/ext/ldap/tests/ldap_first_reference_basic.phpt new file mode 100644 index 0000000000..d7834896a2 --- /dev/null +++ b/ext/ldap/tests/ldap_first_reference_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +ldap_first_reference() - Basic ldap_first_reference test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array("extensibleObject", "referral"), + "cn" => "userref", + "ref" => "cn=userA,dc=my-domain,dc=com", +)); +ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER); +$result = ldap_search($link, "dc=my-domain,dc=com", "(cn=*)"); +var_dump($ref = ldap_first_reference($link, $result)); +$refs = null; +ldap_parse_reference($link, $ref, $refs); +var_dump($refs); +?> +===DONE=== +--CLEAN-- + "2.16.840.1.113730.3.4.2"))); +ldap_delete($link, "cn=userref,dc=my-domain,dc=com"); +remove_dummy_data($link); +?> +--EXPECTF-- +resource(%d) of type (ldap result entry) +array(1) { + [0]=> + string(28) "cn=userA,dc=my-domain,dc=com" +} +===DONE=== diff --git a/ext/ldap/tests/ldap_first_reference_error.phpt b/ext/ldap/tests/ldap_first_reference_error.phpt new file mode 100644 index 0000000000..fc36dd92e6 --- /dev/null +++ b/ext/ldap/tests/ldap_first_reference_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +ldap_first_reference() - Testing ldap_first_reference() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_first_reference() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_first_reference() in %s on line %d +NULL + +Warning: ldap_first_reference(): supplied resource is not a valid ldap result resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_free_result_basic.phpt b/ext/ldap/tests/ldap_free_result_basic.phpt new file mode 100644 index 0000000000..33e47d6eae --- /dev/null +++ b/ext/ldap/tests/ldap_free_result_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +ldap_free_result() - Basic ldap_free_result tests +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_free_result_error.phpt b/ext/ldap/tests/ldap_free_result_error.phpt new file mode 100644 index 0000000000..e2a14443eb --- /dev/null +++ b/ext/ldap/tests/ldap_free_result_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_free_result() - Testing ldap_free_result() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_free_result(): supplied resource is not a valid ldap result resource in %s on line %d +bool(false) + +Warning: Wrong parameter count for ldap_free_result() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_get_attributes_basic.phpt b/ext/ldap/tests/ldap_get_attributes_basic.phpt new file mode 100644 index 0000000000..82074c592a --- /dev/null +++ b/ext/ldap/tests/ldap_get_attributes_basic.phpt @@ -0,0 +1,65 @@ +--TEST-- +ldap_get_attributes() - Basic ldap_get_attributes test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +array(7) { + ["objectClass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectClass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["count"]=> + int(3) +} +===DONE=== diff --git a/ext/ldap/tests/ldap_get_attributes_error.phpt b/ext/ldap/tests/ldap_get_attributes_error.phpt new file mode 100644 index 0000000000..2c7f3ce601 --- /dev/null +++ b/ext/ldap/tests/ldap_get_attributes_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_get_attributes() - Testing ldap_get_attributes() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_get_attributes() in %s on line %d +NULL + +Warning: ldap_get_attributes(): supplied resource is not a valid ldap result entry resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_get_dn_basic.phpt b/ext/ldap/tests/ldap_get_dn_basic.phpt new file mode 100644 index 0000000000..e70e7bf6c5 --- /dev/null +++ b/ext/ldap/tests/ldap_get_dn_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +ldap_get_dn() - Basic ldap_get_dn test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +string(19) "dc=my-domain,dc=com" +===DONE=== diff --git a/ext/ldap/tests/ldap_get_dn_error.phpt b/ext/ldap/tests/ldap_get_dn_error.phpt new file mode 100644 index 0000000000..59460c2b60 --- /dev/null +++ b/ext/ldap/tests/ldap_get_dn_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_get_dn() - Testing ldap_get_dn() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_get_dn() in %s on line %d +NULL + +Warning: ldap_get_dn(): supplied resource is not a valid ldap result entry resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_get_entries_basic.phpt b/ext/ldap/tests/ldap_get_entries_basic.phpt new file mode 100644 index 0000000000..90dbb26146 --- /dev/null +++ b/ext/ldap/tests/ldap_get_entries_basic.phpt @@ -0,0 +1,74 @@ +--TEST-- +ldap_get_entries() - Basic modify operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +array(2) { + ["count"]=> + int(1) + [0]=> + array(8) { + ["objectclass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectclass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["count"]=> + int(3) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_get_entries_error.phpt b/ext/ldap/tests/ldap_get_entries_error.phpt new file mode 100644 index 0000000000..e51850e5cc --- /dev/null +++ b/ext/ldap/tests/ldap_get_entries_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +ldap_get_entries() - ldap_get_entries() operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_get_entries() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_entries() in %s on line %d +NULL + +Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_get_entries_variation.phpt b/ext/ldap/tests/ldap_get_entries_variation.phpt new file mode 100644 index 0000000000..92c49740c5 --- /dev/null +++ b/ext/ldap/tests/ldap_get_entries_variation.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test ldap_get_entries() function - variation: used on empty search +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_get_option_basic.phpt b/ext/ldap/tests/ldap_get_option_basic.phpt new file mode 100644 index 0000000000..3136a5acb8 --- /dev/null +++ b/ext/ldap/tests/ldap_get_option_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +ldap_get_option() - Basic ldap_get_option() operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +int(3) +===DONE=== diff --git a/ext/ldap/tests/ldap_get_option_error.phpt b/ext/ldap/tests/ldap_get_option_error.phpt new file mode 100644 index 0000000000..4208a48024 --- /dev/null +++ b/ext/ldap/tests/ldap_get_option_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_get_option() - ldap_get_option() operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_get_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_option() in %s on line %d +NULL +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_get_option_variation.phpt b/ext/ldap/tests/ldap_get_option_variation.phpt new file mode 100644 index 0000000000..9e5a993f51 --- /dev/null +++ b/ext/ldap/tests/ldap_get_option_variation.phpt @@ -0,0 +1,61 @@ +--TEST-- +ldap_get_option() - More ldap_get_option() operations +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), +); + +ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER); +ldap_set_option($link, LDAP_OPT_SIZELIMIT, 123); +ldap_set_option($link, LDAP_OPT_TIMELIMIT, 33); +ldap_set_option($link, LDAP_OPT_REFERRALS, false); +ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls); +ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls); +ldap_set_option($link, LDAP_OPT_RESTART, false); + +var_dump( + ldap_get_option($link, LDAP_OPT_DEREF, $option), + $option, + ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option), + $option, + ldap_get_option($link, LDAP_OPT_REFERRALS, $option), + $option, + ldap_get_option($link, LDAP_OPT_RESTART, $option), + $option, + ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $option), + $option, + ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $option), + $option +); +?> +===DONE=== +--EXPECT-- +bool(true) +int(0) +bool(true) +int(123) +bool(true) +int(33) +bool(true) +int(0) +bool(true) +int(0) +bool(false) +int(0) +bool(false) +int(0) +===DONE=== diff --git a/ext/ldap/tests/ldap_get_values_len_basic.phpt b/ext/ldap/tests/ldap_get_values_len_basic.phpt new file mode 100644 index 0000000000..ed8461427b --- /dev/null +++ b/ext/ldap/tests/ldap_get_values_len_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +ldap_get_values_len() - Basic ldap_get_values_len test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +array(2) { + [0]=> + string(9) "my-domain" + ["count"]=> + int(1) +} +===DONE=== diff --git a/ext/ldap/tests/ldap_get_values_len_error.phpt b/ext/ldap/tests/ldap_get_values_len_error.phpt new file mode 100644 index 0000000000..c163cc27a3 --- /dev/null +++ b/ext/ldap/tests/ldap_get_values_len_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_get_values_len() - Testing ldap_get_values_len() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_get_values_len() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_values_len() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_get_values_len() in %s on line %d +NULL + +Warning: ldap_get_values_len(): Cannot get the value(s) of attribute %s in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_list_basic.phpt b/ext/ldap/tests/ldap_list_basic.phpt new file mode 100644 index 0000000000..1993f30f1f --- /dev/null +++ b/ext/ldap/tests/ldap_list_basic.phpt @@ -0,0 +1,150 @@ +--TEST-- +ldap_list() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(3) { + ["count"]=> + int(2) + [0]=> + array(14) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userA" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN1" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(4) "oops" + } + [3]=> + string(12) "userpassword" + ["telephonenumber"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(14) "xx-xx-xx-xx-xx" + } + [4]=> + string(15) "telephonenumber" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user A" + } + [5]=> + string(11) "description" + ["count"]=> + int(6) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } + [1]=> + array(12) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userB" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN2" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(15) "oopsIDitItAgain" + } + [3]=> + string(12) "userpassword" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user B" + } + [4]=> + string(11) "description" + ["count"]=> + int(5) + ["dn"]=> + string(28) "cn=userB,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_list_error.phpt b/ext/ldap/tests/ldap_list_error.phpt new file mode 100644 index 0000000000..f1e56809a3 --- /dev/null +++ b/ext/ldap/tests/ldap_list_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +ldap_list() - operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_list() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_list() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_list() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_list() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_add_basic.phpt b/ext/ldap/tests/ldap_mod_add_basic.phpt new file mode 100644 index 0000000000..8c8164cfa1 --- /dev/null +++ b/ext/ldap/tests/ldap_mod_add_basic.phpt @@ -0,0 +1,90 @@ +--TEST-- +ldap_mod_add() - Basic modify operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "Domain description", +); + +var_dump( + ldap_mod_add($link, "dc=my-domain,dc=com", $entry), + ldap_get_entries( + $link, + ldap_search($link, "dc=my-domain,dc=com", "(Description=Domain description)") + ) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(2) { + ["count"]=> + int(1) + [0]=> + array(10) { + ["objectclass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectclass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(18) "Domain description" + } + [3]=> + string(11) "description" + ["count"]=> + int(4) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_add_error.phpt b/ext/ldap/tests/ldap_mod_add_error.phpt new file mode 100644 index 0000000000..560d4ca62d --- /dev/null +++ b/ext/ldap/tests/ldap_mod_add_error.phpt @@ -0,0 +1,83 @@ +--TEST-- +ldap_mod_add() - ldap_mod_add() operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", +); + +ldap_add($link, "dc=my-domain,dc=com", $entry); + +$entry2 = $entry; +$entry2["dc"] = "Wrong Domain"; + +var_dump(ldap_mod_add($link, "dc=my-domain,dc=com", $entry2)); + +$entry2 = $entry; +$entry2["weirdAttribute"] = "weirdVal"; + +var_dump(ldap_mod_add($link, "dc=my-domain,dc=com", $entry2)); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_mod_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_add() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_add() in %s on line %d +NULL + +Warning: ldap_mod_add(): Modify: No such object in %s on line %d +bool(false) + +Warning: ldap_mod_add(): Modify: Invalid DN syntax in %s on line %d +bool(false) + +Warning: ldap_mod_add(): Modify: Type or value exists in %s on line %d +bool(false) + +Warning: ldap_mod_add(): Modify: Undefined attribute type in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_del_basic.phpt b/ext/ldap/tests/ldap_mod_del_basic.phpt new file mode 100644 index 0000000000..0d002bd156 --- /dev/null +++ b/ext/ldap/tests/ldap_mod_del_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_mod_del() - Basic modify operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "user A" +); + +var_dump( + ldap_mod_del($link, "cn=userA,dc=my-domain,dc=com", $entry), + ldap_get_entries( + $link, + ldap_search($link, "dc=my-domain,dc=com", "(description=user A)") + ) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_del_error.phpt b/ext/ldap/tests/ldap_mod_del_error.phpt new file mode 100644 index 0000000000..29efeeba0c --- /dev/null +++ b/ext/ldap/tests/ldap_mod_del_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +ldap_mod_del() - ldap_mod_del() operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_mod_del() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_del() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_del() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_del() in %s on line %d +NULL + +Warning: ldap_mod_del(): Modify: No such object in %s on line %d +bool(false) + +Warning: ldap_mod_del(): Modify: Invalid DN syntax in %s on line %d +bool(false) + +Warning: ldap_mod_del(): Unknown attribute in the data in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_replace_basic.phpt b/ext/ldap/tests/ldap_mod_replace_basic.phpt new file mode 100644 index 0000000000..d1670ec02b --- /dev/null +++ b/ext/ldap/tests/ldap_mod_replace_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +ldap_mod_replace() - Basic modify operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "user X" +); + +var_dump( + ldap_mod_replace($link, "cn=userA,dc=my-domain,dc=com", $entry), + ldap_get_entries( + $link, + ldap_search($link, "dc=my-domain,dc=com", "(description=user X)", array("description")) + ) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user X" + } + [0]=> + string(11) "description" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_mod_replace_error.phpt b/ext/ldap/tests/ldap_mod_replace_error.phpt new file mode 100644 index 0000000000..20fee861d6 --- /dev/null +++ b/ext/ldap/tests/ldap_mod_replace_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +ldap_mod_replace() - ldap_mod_replace() operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_mod_replace() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_replace() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_replace() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_mod_replace() in %s on line %d +NULL + +Warning: ldap_mod_replace(): Modify: No such object in %s on line %d +bool(false) + +Warning: ldap_mod_replace(): Modify: Invalid DN syntax in %s on line %d +bool(false) + +Warning: ldap_mod_replace(): Unknown attribute in the data in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_modify_basic.phpt b/ext/ldap/tests/ldap_modify_basic.phpt new file mode 100644 index 0000000000..74bd831291 --- /dev/null +++ b/ext/ldap/tests/ldap_modify_basic.phpt @@ -0,0 +1,96 @@ +--TEST-- +ldap_modify() - Basic modify operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", + "description" => "Domain description", +); + +var_dump( + ldap_modify($link, "dc=my-domain,dc=com", $entry), + ldap_get_entries( + $link, + ldap_search($link, "dc=my-domain,dc=com", "(Description=Domain description)") + ) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(2) { + ["count"]=> + int(1) + [0]=> + array(10) { + ["objectclass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectclass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(18) "Domain description" + } + [3]=> + string(11) "description" + ["count"]=> + int(4) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_modify_error.phpt b/ext/ldap/tests/ldap_modify_error.phpt new file mode 100644 index 0000000000..ca417b5926 --- /dev/null +++ b/ext/ldap/tests/ldap_modify_error.phpt @@ -0,0 +1,83 @@ +--TEST-- +ldap_modify() - Modify operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array( + "top", + "dcObject", + "organization"), + "dc" => "my-domain", + "o" => "my-domain", +); + +ldap_add($link, "dc=my-domain,dc=com", $entry); + +$entry2 = $entry; +$entry2["dc"] = "Wrong Domain"; + +var_dump(ldap_modify($link, "dc=my-domain,dc=com", $entry2)); + +$entry2 = $entry; +$entry2["weirdAttribute"] = "weirdVal"; + +var_dump(ldap_modify($link, "dc=my-domain,dc=com", $entry2)); +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_modify() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_modify() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_modify() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_modify() in %s on line %d +NULL + +Warning: ldap_modify(): Modify: No such object in %s on line %d +bool(false) + +Warning: ldap_modify(): Modify: Invalid DN syntax in %s on line %d +bool(false) + +Warning: ldap_modify(): Modify: Naming violation in %s on line %d +bool(false) + +Warning: ldap_modify(): Modify: Undefined attribute type in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_next_attribute_basic.phpt b/ext/ldap/tests/ldap_next_attribute_basic.phpt new file mode 100644 index 0000000000..0fab78a70c --- /dev/null +++ b/ext/ldap/tests/ldap_next_attribute_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +ldap_next_attribute() - Basic ldap_next_attribute test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(%d) "%s" +string(%d) "%s" +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_next_attribute_error.phpt b/ext/ldap/tests/ldap_next_attribute_error.phpt new file mode 100644 index 0000000000..2c23224b33 --- /dev/null +++ b/ext/ldap/tests/ldap_next_attribute_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_next_attribute() - Testing ldap_next_attribute() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Wrong parameter count for ldap_next_attribute() %s on line %d + +Warning: ldap_next_attribute(): supplied resource is not a valid ldap result entry resource in %s on line %d + +Warning: ldap_next_attribute(): called before calling ldap_first_attribute() or no attributes found in result entry in %s on line %d +NULL +bool(false) +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_next_entry_basic.phpt b/ext/ldap/tests/ldap_next_entry_basic.phpt new file mode 100644 index 0000000000..3209df6a01 --- /dev/null +++ b/ext/ldap/tests/ldap_next_entry_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_next_entry() - Basic ldap_first_entry test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result entry) +array(2) { + [0]=> + string(7) "testSN%d" + ["count"]=> + int(1) +} +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_next_entry_error.phpt b/ext/ldap/tests/ldap_next_entry_error.phpt new file mode 100644 index 0000000000..89bf1f090b --- /dev/null +++ b/ext/ldap/tests/ldap_next_entry_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +ldap_next_entry() - Testing ldap_next_entry() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_next_entry() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_next_entry() in %s on line %d +NULL + +Warning: ldap_next_entry(): supplied resource is not a valid ldap result entry resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_next_reference_basic.phpt b/ext/ldap/tests/ldap_next_reference_basic.phpt new file mode 100644 index 0000000000..d0fa31d9cb --- /dev/null +++ b/ext/ldap/tests/ldap_next_reference_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +ldap_next_reference() - Basic ldap_next_reference test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array("extensibleObject", "referral"), + "cn" => "userref", + "ref" => "cn=userA,dc=my-domain,dc=com", +)); +ldap_add($link, "cn=userref2,dc=my-domain,dc=com", array( + "objectClass" => array("extensibleObject", "referral"), + "cn" => "userref2", + "ref" => "cn=userB,dc=my-domain,dc=com", +)); +ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER); +$result = ldap_search($link, "dc=my-domain,dc=com", "(cn=*)"); +$ref = ldap_first_reference($link, $result); +var_dump($ref2 = ldap_next_reference($link, $ref)); +ldap_parse_reference($link, $ref2, $refs); +var_dump($refs); +?> +===DONE=== +--CLEAN-- + "2.16.840.1.113730.3.4.2"))); +ldap_delete($link, "cn=userref,dc=my-domain,dc=com"); +ldap_delete($link, "cn=userref2,dc=my-domain,dc=com"); +remove_dummy_data($link); +?> +--EXPECTF-- +resource(%d) of type (ldap result entry) +array(1) { + [0]=> + string(28) "cn=userB,dc=my-domain,dc=com" +} +===DONE=== diff --git a/ext/ldap/tests/ldap_next_reference_error.phpt b/ext/ldap/tests/ldap_next_reference_error.phpt new file mode 100644 index 0000000000..5cde899d20 --- /dev/null +++ b/ext/ldap/tests/ldap_next_reference_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +ldap_next_reference() - Testing ldap_next_reference() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_next_reference() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_next_reference() in %s on line %d +NULL + +Warning: ldap_next_reference(): supplied resource is not a valid ldap result entry resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_parse_reference_basic.phpt b/ext/ldap/tests/ldap_parse_reference_basic.phpt new file mode 100644 index 0000000000..2bacd428a2 --- /dev/null +++ b/ext/ldap/tests/ldap_parse_reference_basic.phpt @@ -0,0 +1,45 @@ +--TEST-- +ldap_parse_reference() - Basic ldap_parse_reference test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array("extensibleObject", "referral"), + "cn" => "userref", + "ref" => "cn=userA,dc=my-domain,dc=com", +)); +ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_NEVER); +$result = ldap_search($link, "dc=my-domain,dc=com", "(cn=*)"); +$ref = ldap_first_reference($link, $result); +$refs = null; +var_dump( + ldap_parse_reference($link, $ref, $refs), + $refs +); +?> +===DONE=== +--CLEAN-- + "2.16.840.1.113730.3.4.2"))); +ldap_delete($link, "cn=userref,dc=my-domain,dc=com"); +remove_dummy_data($link); +?> +--EXPECTF-- +bool(true) +array(1) { + [0]=> + string(28) "cn=userA,dc=my-domain,dc=com" +} +===DONE=== diff --git a/ext/ldap/tests/ldap_parse_reference_error.phpt b/ext/ldap/tests/ldap_parse_reference_error.phpt new file mode 100644 index 0000000000..104d5d39d9 --- /dev/null +++ b/ext/ldap/tests/ldap_parse_reference_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +ldap_parse_reference() - ldap_parse_reference() operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_parse_reference() in %s on line %d + +Warning: ldap_parse_reference(): supplied resource is not a valid ldap result entry resource in %s on line %d + +Warning: Wrong parameter count for ldap_parse_reference() in %s on line %d +NULL +bool(false) +NULL +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_parse_result_basic.phpt b/ext/ldap/tests/ldap_parse_result_basic.phpt new file mode 100644 index 0000000000..1646d59c91 --- /dev/null +++ b/ext/ldap/tests/ldap_parse_result_basic.phpt @@ -0,0 +1,47 @@ +--TEST-- +ldap_parse_result() - Basic ldap_parse_result test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + array("extensibleObject", "referral"), + "cn" => "userref", + "ref" => "cn=userA,dc=my-domain,dc=com", +)); +$result = ldap_search($link, "cn=userref,dc=my-domain,dc=com", "(cn=user*)"); +$errcode = $dn = $errmsg = $refs = null; +var_dump( + ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs), + $errcode, $dn, $errmsg, $refs +); +?> +===DONE=== +--CLEAN-- + "2.16.840.1.113730.3.4.2"))); +ldap_delete($link, "cn=userref,dc=my-domain,dc=com"); +remove_dummy_data($link); +?> +--EXPECT-- +bool(true) +int(10) +string(30) "cn=userref,dc=my-domain,dc=com" +string(0) "" +array(1) { + [0]=> + string(28) "cn=userA,dc=my-domain,dc=com" +} +===DONE=== diff --git a/ext/ldap/tests/ldap_parse_result_error.phpt b/ext/ldap/tests/ldap_parse_result_error.phpt new file mode 100644 index 0000000000..8811783d30 --- /dev/null +++ b/ext/ldap/tests/ldap_parse_result_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +ldap_parse_result() - Testing ldap_parse_result() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_parse_result() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_read_basic.phpt b/ext/ldap/tests/ldap_read_basic.phpt new file mode 100644 index 0000000000..04d03d9860 --- /dev/null +++ b/ext/ldap/tests/ldap_read_basic.phpt @@ -0,0 +1,75 @@ +--TEST-- +ldap_read() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(8) { + ["objectclass"]=> + array(4) { + ["count"]=> + int(3) + [0]=> + string(3) "top" + [1]=> + string(8) "dcObject" + [2]=> + string(12) "organization" + } + [0]=> + string(11) "objectclass" + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [1]=> + string(2) "dc" + ["o"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [2]=> + string(1) "o" + ["count"]=> + int(3) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_read_error.phpt b/ext/ldap/tests/ldap_read_error.phpt new file mode 100644 index 0000000000..10c0e29f50 --- /dev/null +++ b/ext/ldap/tests/ldap_read_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +ldap_read() - operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_read() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_read() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_read() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_read() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_rename_basic.phpt b/ext/ldap/tests/ldap_rename_basic.phpt new file mode 100644 index 0000000000..135769d1d4 --- /dev/null +++ b/ext/ldap/tests/ldap_rename_basic.phpt @@ -0,0 +1,62 @@ +--TEST-- +ldap_rename() - Basic ldap_rename test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(2) { + ["count"]=> + int(1) + [0]=> + array(6) { + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN1" + } + [0]=> + string(2) "sn" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userZ" + } + [1]=> + string(2) "cn" + ["count"]=> + int(2) + ["dn"]=> + string(28) "cn=userZ,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_rename_error.phpt b/ext/ldap/tests/ldap_rename_error.phpt new file mode 100644 index 0000000000..ac088de7b9 --- /dev/null +++ b/ext/ldap/tests/ldap_rename_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +ldap_rename() - Testing ldap_rename() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_rename() in %s on line %d +NULL +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_sasl_bind_basic.phpt b/ext/ldap/tests/ldap_sasl_bind_basic.phpt new file mode 100644 index 0000000000..6ed14a5b19 --- /dev/null +++ b/ext/ldap/tests/ldap_sasl_bind_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +ldap_sasl_bind() - Basic anonymous binding +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_sasl_bind_error.phpt b/ext/ldap/tests/ldap_sasl_bind_error.phpt new file mode 100644 index 0000000000..180066bb2c --- /dev/null +++ b/ext/ldap/tests/ldap_sasl_bind_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +ldap_sasl_bind() - Binding that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_sasl_bind() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d +bool(false) + +Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d +bool(false) + +Warning: ldap_sasl_bind(): Unable to bind to server: Invalid credentials in %s on line %d +bool(false) + +Warning: ldap_sasl_bind(): Unable to bind to server: Insufficient access in %s on line %d +bool(false) + +Warning: ldap_sasl_bind(): Unable to bind to server: Invalid DN syntax in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_search_basic.phpt b/ext/ldap/tests/ldap_search_basic.phpt new file mode 100644 index 0000000000..e6cebf2c57 --- /dev/null +++ b/ext/ldap/tests/ldap_search_basic.phpt @@ -0,0 +1,194 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(4) { + ["count"]=> + int(3) + [0]=> + array(14) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userA" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN1" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(4) "oops" + } + [3]=> + string(12) "userpassword" + ["telephonenumber"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(14) "xx-xx-xx-xx-xx" + } + [4]=> + string(15) "telephonenumber" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user A" + } + [5]=> + string(11) "description" + ["count"]=> + int(6) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } + [1]=> + array(12) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userB" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN2" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(15) "oopsIDitItAgain" + } + [3]=> + string(12) "userpassword" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user B" + } + [4]=> + string(11) "description" + ["count"]=> + int(5) + ["dn"]=> + string(28) "cn=userB,dc=my-domain,dc=com" + } + [2]=> + array(10) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userC" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN3" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(17) "0r1g1na1 passw0rd" + } + [3]=> + string(12) "userpassword" + ["count"]=> + int(4) + ["dn"]=> + string(37) "cn=userC,cn=userB,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_error.phpt b/ext/ldap/tests/ldap_search_error.phpt new file mode 100644 index 0000000000..6a68e9d5d3 --- /dev/null +++ b/ext/ldap/tests/ldap_search_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +ldap_search() - operation that should fail +--CREDITS-- +Davide Mendolia +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + 'top')); +var_dump($result); + +$result = ldap_search(array(), $dn, $filter, array('top')); +var_dump($result); + +$result = ldap_search(array($link, $link), array($dn), $filter, array('top')); +var_dump($result); + +$result = ldap_search(array($link, $link), $dn, array($filter), array('top')); +var_dump($result); +?> +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_search() in %s on line %d +NULL + +Warning: ldap_search(): Search: No such object in %s on line %d +bool(false) + +Warning: ldap_search(): Expected Array as last element in %s on line %d +bool(false) + +Warning: ldap_search(): Array initialization wrong in %s on line %d +bool(false) + +Warning: ldap_search(): No links in link array in %s on line %d +bool(false) + +Warning: ldap_search(): Base must either be a string, or an array with the same number of elements as the links array in %s on line %d +bool(false) + +Warning: ldap_search(): Filter must either be a string, or an array with the same number of elements as the links array in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation1.phpt b/ext/ldap/tests/ldap_search_variation1.phpt new file mode 100644 index 0000000000..d56f5bdc93 --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation1.phpt @@ -0,0 +1,56 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["dc"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(9) "my-domain" + } + [0]=> + string(2) "dc" + ["count"]=> + int(1) + ["dn"]=> + string(19) "dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation2.phpt b/ext/ldap/tests/ldap_search_variation2.phpt new file mode 100644 index 0000000000..791c5e9bcf --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation2.phpt @@ -0,0 +1,80 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(4) { + ["count"]=> + int(3) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } + [1]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userB,dc=my-domain,dc=com" + } + [2]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(37) "cn=userC,cn=userB,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation3.phpt b/ext/ldap/tests/ldap_search_variation3.phpt new file mode 100644 index 0000000000..ab7b222825 --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation3.phpt @@ -0,0 +1,108 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +resource(%d) of type (ldap result) +array(4) { + ["count"]=> + int(3) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } + [1]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userB,dc=my-domain,dc=com" + } + [2]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(37) "cn=userC,cn=userB,dc=my-domain,dc=com" + } +} + +Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation4.phpt b/ext/ldap/tests/ldap_search_variation4.phpt new file mode 100644 index 0000000000..787468e0f5 --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation4.phpt @@ -0,0 +1,55 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation5.phpt b/ext/ldap/tests/ldap_search_variation5.phpt new file mode 100644 index 0000000000..d50854c658 --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation5.phpt @@ -0,0 +1,105 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} + +Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} + +Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d +resource(%d) of type (ldap result) +array(2) { + ["count"]=> + int(1) + [0]=> + array(4) { + ["sn"]=> + array(1) { + ["count"]=> + int(0) + } + [0]=> + string(2) "sn" + ["count"]=> + int(1) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_search_variation6.phpt b/ext/ldap/tests/ldap_search_variation6.phpt new file mode 100644 index 0000000000..a29e4524df --- /dev/null +++ b/ext/ldap/tests/ldap_search_variation6.phpt @@ -0,0 +1,230 @@ +--TEST-- +ldap_search() test +--CREDITS-- +Davide Mendolia +Patrick Allaert +Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +array(2) { + [0]=> + resource(%d) of type (ldap result) + [1]=> + resource(%d) of type (ldap result) +} +array(4) { + ["count"]=> + int(3) + [0]=> + array(14) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userA" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN1" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(4) "oops" + } + [3]=> + string(12) "userpassword" + ["telephonenumber"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(14) "xx-xx-xx-xx-xx" + } + [4]=> + string(15) "telephonenumber" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user A" + } + [5]=> + string(11) "description" + ["count"]=> + int(6) + ["dn"]=> + string(28) "cn=userA,dc=my-domain,dc=com" + } + [1]=> + array(12) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userB" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN2" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(15) "oopsIDitItAgain" + } + [3]=> + string(12) "userpassword" + ["description"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "user B" + } + [4]=> + string(11) "description" + ["count"]=> + int(5) + ["dn"]=> + string(28) "cn=userB,dc=my-domain,dc=com" + } + [2]=> + array(10) { + ["objectclass"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(6) "person" + } + [0]=> + string(11) "objectclass" + ["cn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(5) "userC" + } + [1]=> + string(2) "cn" + ["sn"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(7) "testSN3" + } + [2]=> + string(2) "sn" + ["userpassword"]=> + array(2) { + ["count"]=> + int(1) + [0]=> + string(17) "0r1g1na1 passw0rd" + } + [3]=> + string(12) "userpassword" + ["count"]=> + int(4) + ["dn"]=> + string(37) "cn=userC,cn=userB,dc=my-domain,dc=com" + } +} +bool(true) +array(2) { + [0]=> + resource(%d) of type (ldap result) + [1]=> + resource(%d) of type (ldap result) +} +NULL +NULL +array(2) { + [0]=> + resource(%d) of type (ldap result) + [1]=> + resource(%d) of type (ldap result) +} +NULL +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_set_option_basic.phpt b/ext/ldap/tests/ldap_set_option_basic.phpt new file mode 100644 index 0000000000..de25e59c21 --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +ldap_set_option() - Basic ldap_set_option() operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +int(3) +===DONE=== diff --git a/ext/ldap/tests/ldap_set_option_error.phpt b/ext/ldap/tests/ldap_set_option_error.phpt new file mode 100644 index 0000000000..e9ff5ab24d --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_error.phpt @@ -0,0 +1,66 @@ +--TEST-- +ldap_set_option() - ldap_set_option() operation that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + "1.2.752.58.10.1", "iscritical" => true), + array("xid" => "1.2.752.58.1.10", "value" => "magic"), + ), + array( + array("oid" => "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), + "weird" + ), + array( + ), +); + +// Too few parameters +var_dump(ldap_set_option()); +var_dump(ldap_set_option($link)); +var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION)); + +// Too many parameters +var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 3, "Additional data")); + +var_dump(ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 10)); + +foreach ($controls as $control) + var_dump(ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $control)); + +var_dump(ldap_set_option($link, 999999, 999999)); +?> +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_set_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_set_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_set_option() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_set_option() in %s on line %d +NULL +bool(false) + +Warning: ldap_set_option(): Control must have an oid key in %s on line %d +bool(false) + +Warning: ldap_set_option(): The array value must contain only arrays, where each array is a control in %s on line %d +bool(false) + +Warning: ldap_set_option(): Expected non-empty array value for this option in %s on line %d +bool(false) +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_set_option_variation.phpt b/ext/ldap/tests/ldap_set_option_variation.phpt new file mode 100644 index 0000000000..1bbfe1fcc8 --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_variation.phpt @@ -0,0 +1,77 @@ +--TEST-- +ldap_set_option() - More ldap_set_option() operations +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + "1.2.752.58.10.1", "iscritical" => true), + array("oid" => "1.2.752.58.1.10", "value" => "magic"), +); + +var_dump(ldap_set_option($link, LDAP_OPT_DEREF, LDAP_DEREF_ALWAYS)); +ldap_get_option($link, LDAP_OPT_DEREF, $option); +var_dump( + $option === LDAP_DEREF_ALWAYS, + ldap_set_option($link, LDAP_OPT_SIZELIMIT, 123) +); +ldap_get_option($link, LDAP_OPT_SIZELIMIT, $option); +var_dump( + $option, + ldap_set_option($link, LDAP_OPT_TIMELIMIT, 33) +); +ldap_get_option($link, LDAP_OPT_TIMELIMIT, $option); +var_dump( + $option, + ldap_set_option($link, LDAP_OPT_REFERRALS, true) +); +ldap_get_option($link, LDAP_OPT_REFERRALS, $option); +var_dump( + (bool) $option, + ldap_set_option($link, LDAP_OPT_RESTART, false) +); +ldap_get_option($link, LDAP_OPT_RESTART, $option); +var_dump( + (bool) $option, + ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, $controls) +); +ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $option); +var_dump( + $option, + ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls) +); +ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $option); +var_dump( + $option, + ldap_set_option($link, LDAP_OPT_MATCHED_DN, "dc=test,dc=com") +); +ldap_get_option($link, LDAP_OPT_MATCHED_DN, $option); +var_dump($option); +?> +===DONE=== +--EXPECT-- +bool(true) +bool(true) +bool(true) +int(123) +bool(true) +int(33) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +string(14) "dc=test,dc=com" +===DONE=== diff --git a/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt b/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt new file mode 100644 index 0000000000..428b8d8f02 --- /dev/null +++ b/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +ldap_set_rebind_proc() - Basic ldap_set_rebind_proc test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_set_rebind_proc_error.phpt b/ext/ldap/tests/ldap_set_rebind_proc_error.phpt new file mode 100644 index 0000000000..3b4cd69cfc --- /dev/null +++ b/ext/ldap/tests/ldap_set_rebind_proc_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +ldap_set_rebind_proc() - Testing ldap_set_rebind_proc() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_set_rebind_proc() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +Warning: ldap_set_rebind_proc() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +Warning: ldap_set_rebind_proc(): Two arguments expected for 'rebind_proc_inexistant' to be a valid callback in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_sort_basic.phpt b/ext/ldap/tests/ldap_sort_basic.phpt new file mode 100644 index 0000000000..f6ee5d198f --- /dev/null +++ b/ext/ldap/tests/ldap_sort_basic.phpt @@ -0,0 +1,200 @@ +--TEST-- +ldap_sort() - Basic ldap_sort test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "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-- + +--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=== diff --git a/ext/ldap/tests/ldap_sort_error.phpt b/ext/ldap/tests/ldap_sort_error.phpt new file mode 100644 index 0000000000..6eb409073e --- /dev/null +++ b/ext/ldap/tests/ldap_sort_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +ldap_sort() - Testing ldap_sort() that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_sort() expects exactly 3 parameters, 1 given in %s on line %d +bool(false) + +Warning: ldap_sort() expects exactly 3 parameters, 2 given in %s on line %d +bool(false) + +Warning: ldap_sort() expects exactly 3 parameters, 4 given in %s on line %d +bool(false) + +Warning: ldap_sort() expects parameter 3 to be %binary_string_optional%, resource given in %s on line %d +bool(false) + +Warning: ldap_sort(): Supplied resource is not a valid ldap result resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_sort_variation.phpt b/ext/ldap/tests/ldap_sort_variation.phpt new file mode 100644 index 0000000000..e1affe82fe --- /dev/null +++ b/ext/ldap/tests/ldap_sort_variation.phpt @@ -0,0 +1,200 @@ +--TEST-- +ldap_sort() - Basic ldap_sort test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + "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, "description"), + ldap_get_entries($link, $result) +); +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +bool(true) +array(7) { + ["count"]=> + int(6) + [0]=> + 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" + } + [1]=> + 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" + } + [2]=> + 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" + } + [3]=> + 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" + } + [4]=> + 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" + } + [5]=> + 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" + } +} +===DONE=== diff --git a/ext/ldap/tests/ldap_start_tls_basic.phpt b/ext/ldap/tests/ldap_start_tls_basic.phpt new file mode 100644 index 0000000000..3ae50bef54 --- /dev/null +++ b/ext/ldap/tests/ldap_start_tls_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +ldap_start_tls() - Basic ldap_start_tls test +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_start_tls_error.phpt b/ext/ldap/tests/ldap_start_tls_error.phpt new file mode 100644 index 0000000000..a09b7f1e1e --- /dev/null +++ b/ext/ldap/tests/ldap_start_tls_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +ldap_start_tls() - Binding that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: Wrong parameter count for ldap_start_tls() in %s on line %d +NULL + +Warning: Wrong parameter count for ldap_start_tls() in %s on line %d +NULL +===DONE=== diff --git a/ext/ldap/tests/ldap_unbind_basic.phpt b/ext/ldap/tests/ldap_unbind_basic.phpt new file mode 100644 index 0000000000..addfac5597 --- /dev/null +++ b/ext/ldap/tests/ldap_unbind_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +ldap_unbind() - Basic ldap_unbind() operation +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== diff --git a/ext/ldap/tests/ldap_unbind_error.phpt b/ext/ldap/tests/ldap_unbind_error.phpt new file mode 100644 index 0000000000..19b4ad5948 --- /dev/null +++ b/ext/ldap/tests/ldap_unbind_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +ldap_unbind() - ldap_unbind() operations that should fail +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: ldap_unbind() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: ldap_unbind() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +Warning: ldap_unbind() expects parameter 1 to be resource, %unicode_string_optional% given in %s on line %d +bool(false) +bool(true) + +Warning: ldap_unbind(): %d is not a valid ldap link resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/ldap/tests/ldap_unbind_variation.phpt b/ext/ldap/tests/ldap_unbind_variation.phpt new file mode 100644 index 0000000000..377018c583 --- /dev/null +++ b/ext/ldap/tests/ldap_unbind_variation.phpt @@ -0,0 +1,34 @@ +--TEST-- +ldap_unbind() - Variation of ldap_unbind() function using ldap_set_rebind_proc() +--CREDITS-- +Patrick Allaert +# Belgian PHP Testfest 2009 +--SKIPIF-- + + +--FILE-- + +===DONE=== +--EXPECT-- +bool(true) +===DONE=== -- 2.40.0