Sfoglia il codice sorgente

#261: SQLite test fixed: testAdapterAlternateStatement

(cherry picked from commit 544f7013f3be9d407bae0d9afcd68736158ae556)
Martin Hujer 12 anni fa
parent
commit
5d09e62661
1 ha cambiato i file con 30 aggiunte e 0 eliminazioni
  1. 30 0
      tests/Zend/Db/Adapter/Pdo/SqliteTest.php

+ 30 - 0
tests/Zend/Db/Adapter/Pdo/SqliteTest.php

@@ -217,4 +217,34 @@ class Zend_Db_Adapter_Pdo_SqliteTest extends Zend_Db_Adapter_Pdo_TestCommon
         $row = $db->fetchRow($select);
         $this->assertTrue($row instanceof stdClass);
     }
+
+    protected function _testAdapterAlternateStatement($stmtClass)
+    {
+        $ip = get_include_path();
+        $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR .  '..' . DIRECTORY_SEPARATOR . '_files';
+        $newIp = $dir . PATH_SEPARATOR . $ip;
+        set_include_path($newIp);
+
+        $params = $this->_util->getParams();
+
+        $params['options'] = array(
+            Zend_Db::AUTO_QUOTE_IDENTIFIERS => false
+        );
+        $db = Zend_Db::factory($this->getDriver(), $params);
+        $db->getConnection();
+        $db->setStatementClass($stmtClass);
+
+        $currentStmtClass = $db->getStatementClass();
+        $this->assertEquals($stmtClass, $currentStmtClass);
+
+        //extra fix for SQLite
+        $db->query('CREATE TABLE zfbugs (id)');
+
+        $bugs = $this->_db->quoteIdentifier('zfbugs');
+
+        $stmt = $db->prepare("SELECT COUNT(*) FROM $bugs");
+
+        $this->assertTrue($stmt instanceof $stmtClass,
+            'Expecting object of type ' . $stmtClass . ', got ' . get_class($stmt));
+    }
 }