Procházet zdrojové kódy

added some tests for empty search result iteration trying to replicate an issue wheren an exception is thrown in these cases.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18884 44c647ce-9c0f-0410-b52a-842ac1e357ba
sgehrig před 16 roky
rodič
revize
f9b3b983bd
1 změnil soubory, kde provedl 26 přidání a 0 odebrání
  1. 26 0
      tests/Zend/Ldap/SearchTest.php

+ 26 - 0
tests/Zend/Ldap/SearchTest.php

@@ -114,6 +114,7 @@ class Zend_Ldap_SearchTest extends Zend_Ldap_OnlineTestCase
         $items=$this->_getLdap()->search('(objectClass=organizationalUnit)',
             TESTS_ZEND_LDAP_WRITEABLE_SUBTREE, Zend_Ldap::SEARCH_SCOPE_SUB);
         $this->assertEquals(9, $items->count());
+        $this->assertEquals(9, count($items));
 
         $i=0;
         foreach ($items as $key => $item)
@@ -385,6 +386,31 @@ class Zend_Ldap_SearchTest extends Zend_Ldap_OnlineTestCase
             $this->assertEquals($lSorted[$key], $item['l'][0]);
         }
     }
+
+    public function testSearchNothingIteration()
+    {
+        $entries = $this->_getLdap()->search('(objectClass=account)',
+            TESTS_ZEND_LDAP_WRITEABLE_SUBTREE, Zend_Ldap::SEARCH_SCOPE_SUB);
+        $this->assertEquals(0, $entries->count());
+        $i = 0;
+        foreach ($entries as $key => $item) {
+            $i++;
+        }
+        $this->assertEquals(0, $i);
+    }
+
+    public function testSearchNothingToArray()
+    {
+        $entries = $this->_getLdap()->search('(objectClass=account)',
+            TESTS_ZEND_LDAP_WRITEABLE_SUBTREE, Zend_Ldap::SEARCH_SCOPE_SUB);
+        $entries = $entries->toArray();
+        $this->assertEquals(0, count($entries));
+        $i = 0;
+        foreach ($entries as $key => $item) {
+            $i++;
+        }
+        $this->assertEquals(0, $i);
+    }
 }
 
 class Zend_Ldap_SearchTest_CollectionClassNotSubclassingZendLdapCollection