[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pear-cvs
Subject:    [PEAR-CVS] cvs: pear /Net_LDAP2 LDAP2.php package2.xml  /Net_LDAP2/tests Net_LDAP2Test.php
From:       "Benedikt Hallinger" <beni () php ! net>
Date:       2008-05-29 13:14:12
Message-ID: cvsbeni1212066852 () cvsserver
[Download RAW message or body]

beni		Thu May 29 13:14:12 2008 UTC

  Modified files:              
    /pear/Net_LDAP2	LDAP2.php package2.xml 
    /pear/Net_LDAP2/tests	Net_LDAP2Test.php 
  Log:
  * dnExists() can handle entry objects now. Again improved tests
  
  
http://cvs.php.net/viewvc.cgi/pear/Net_LDAP2/LDAP2.php?r1=1.4&r2=1.5&diff_format=u
Index: pear/Net_LDAP2/LDAP2.php
diff -u pear/Net_LDAP2/LDAP2.php:1.4 pear/Net_LDAP2/LDAP2.php:1.5
--- pear/Net_LDAP2/LDAP2.php:1.4	Thu May 29 13:04:27 2008
+++ pear/Net_LDAP2/LDAP2.php	Thu May 29 13:14:12 2008
@@ -13,7 +13,7 @@
 * @author    Benedikt Hallinger <beni@php.net>
 * @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL
-* @version   CVS: $Id: LDAP2.php,v 1.4 2008/05/29 13:04:27 beni Exp $
+* @version   CVS: $Id: LDAP2.php,v 1.5 2008/05/29 13:14:12 beni Exp $
 * @link      http://pear.php.net/package/Net_LDAP22/
 */
 
@@ -50,7 +50,7 @@
 * @author    Benedikt Hallinger <beni@php.net>
 * @copyright 2003-2007 Tarjej Huse, Jan Wagner, Del Elson, Benedikt Hallinger
 * @license   http://www.gnu.org/copyleft/lesser.html LGPL
-* @version   CVS: $Id: LDAP2.php,v 1.4 2008/05/29 13:04:27 beni Exp $
+* @version   CVS: $Id: LDAP2.php,v 1.5 2008/05/29 13:14:12 beni Exp $
 * @link      http://pear.php.net/package/Net_LDAP22/
 */
 class Net_LDAP2 extends PEAR
@@ -877,16 +877,22 @@
 
 
     /**
-    * Tell if a DN does exist in the directory
+    * Tells if a DN does exist in the directory
     *
-    * @param string $dn The DN of the object to test
+    * @param string|Net_LDAP2_Entry $dn The DN of the object to test
     *
     * @return boolean|Net_LDAP2_Error
     */
     public function dnExists($dn)
     {
-        if (!is_string($dn)) {
-            return PEAR::raiseError('$dn is expected to be a string but is \
'.gettype($dn).' '.get_class($dn)); +        if (PEAR::isError($dn)) {
+            return $dn;
+        }
+        if ($dn instanceof Net_LDAP2_Entry) {
+             $dn = $dn->dn();
+        }
+        if (false === is_string($dn)) {
+            return PEAR::raiseError('Parameter $dn is not a string nor an entry \
object!');  }
 
         // make dn relative to parent
http://cvs.php.net/viewvc.cgi/pear/Net_LDAP2/package2.xml?r1=1.12&r2=1.13&diff_format=u
                
Index: pear/Net_LDAP2/package2.xml
diff -u pear/Net_LDAP2/package2.xml:1.12 pear/Net_LDAP2/package2.xml:1.13
--- pear/Net_LDAP2/package2.xml:1.12	Thu May 29 13:04:27 2008
+++ pear/Net_LDAP2/package2.xml	Thu May 29 13:14:12 2008
@@ -39,7 +39,7 @@
         * New constructor factory for Entry objects: createExisting()
 	* Some small bugfixes
 	* New method Entry->isNew()
-	* Net_LDAP2->search() can handle entry objects as $base now 
+	* Net_LDAP2->search() and Net_LDAP2->dnExists() can handle entry objects now 
     </notes>
 
     <contents>
http://cvs.php.net/viewvc.cgi/pear/Net_LDAP2/tests/Net_LDAP2Test.php?r1=1.4&r2=1.5&diff_format=u
                
Index: pear/Net_LDAP2/tests/Net_LDAP2Test.php
diff -u pear/Net_LDAP2/tests/Net_LDAP2Test.php:1.4 \
                pear/Net_LDAP2/tests/Net_LDAP2Test.php:1.5
--- pear/Net_LDAP2/tests/Net_LDAP2Test.php:1.4	Thu May 29 13:04:27 2008
+++ pear/Net_LDAP2/tests/Net_LDAP2Test.php	Thu May 29 13:14:12 2008
@@ -574,6 +574,23 @@
             // Testing existing and not existing DN; neither should produce an error
             $this->assertTrue($ldap->dnExists($dn));
             $this->assertFalse($ldap->dnExists('cn=not_existent,'.$dn));
+
+            // Passing an Entry object (should work)
+            // It should return false, because don't add the test entry
+            $base = $this->ldapcfg['global']['server_base_dn'];
+            $ou1  = Net_LDAP2_Entry::createFresh('ou=Net_LDAP2_Test_search1,'.$base,
+                array(
+                    'objectClass' => array('top','organizationalUnit'),
+                    'ou' => 'Net_LDAP2_Test_search1'
+                ));
+            $this->assertFalse($ldap->dnExists($ou1));
+
+            // Passing an float instead of a string
+            $this->assertType('Net_LDAP2_Error', $ldap->dnExists(1.234));
+
+            // Pasing an error object
+            $error = new Net_LDAP2_Error('Testerror');
+            $this->assertType('Net_LDAP2_Error', $ldap->dnExists($error));
         }
     }
 



-- 
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic