ソースを参照

[TESTS] Fixed failing Zend_Validate_Db tests

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16940 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 年 前
コミット
0e49362b9e

+ 5 - 1
library/Zend/Validate/Db/Abstract.php

@@ -103,8 +103,12 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
         /**
          * Check for an adapter being defined. if not, fetch the default adapter.
          */ 
-        if($this->_adapter === null) {
+        if ($this->_adapter === null) {
             $this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
+            if (null === $this->_adapter) {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception('No database adapter present');
+            }
         }
 
         /**

+ 1 - 2
tests/Zend/Validate/AllTests.php

@@ -193,8 +193,7 @@ class Zend_Validate_AllTests
         $suite->addTestSuite('Zend_Validate_BetweenTest');
         $suite->addTestSuite('Zend_Validate_CcnumTest');
         $suite->addTestSuite('Zend_Validate_DateTest');
-// Commenting out temporarily; when run with entire test suite, we get fatal errors
-//        $suite->addTest(Zend_Validate_Db_AllTests::suite());
+        $suite->addTest(Zend_Validate_Db_AllTests::suite());
         $suite->addTestSuite('Zend_Validate_DigitsTest');
         $suite->addTestSuite('Zend_Validate_EmailAddressTest');
         $suite->addTest(Zend_Validate_File_AllTests::suite());

+ 2 - 2
tests/Zend/Validate/Db/NoRecordExistsTest.php

@@ -64,8 +64,8 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
         }
 
         $this->_db = new Zend_Db_Adapter_Pdo_Sqlite(
-            array('dbname' => 'test')
-            );
+            array('dbname' => ':memory:')
+        );
 
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_db);
 

+ 2 - 2
tests/Zend/Validate/Db/RecordExistsTest.php

@@ -64,8 +64,8 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
         }
 
         $this->_db = new Zend_Db_Adapter_Pdo_Sqlite(
-            array('dbname' => 'test')
-            );
+            array('dbname' => ':memory:')
+        );
 
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_db);