2
0
Просмотр исходного кода

ZF-8399: test added but cannot reproduce: Zend_Db Query crashes on insert more than 358 characters

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19317 44c647ce-9c0f-0410-b52a-842ac1e357ba
mikaelkael 16 лет назад
Родитель
Сommit
ca6b5294ec

+ 8 - 0
tests/Zend/Db/Adapter/Db2Test.php

@@ -359,6 +359,14 @@ class Zend_Db_Adapter_Db2Test extends Zend_Db_Adapter_TestCommon
         $this->assertTrue(($tableCountNoSchema > $tableCountSchema), 'Table count with schema provided should be less than without.');
     }
 
+    /**
+     * @group ZF-8399
+     */
+    public function testLongQueryWithTextField()
+    {
+        $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
+    }
+
     public function getDriver()
     {
         return 'Db2';

+ 8 - 1
tests/Zend/Db/Adapter/OracleTest.php

@@ -519,9 +519,16 @@ class Zend_Db_Adapter_OracleTest extends Zend_Db_Adapter_TestCommon
         $this->_testAdapterAlternateStatement('Test_OracleStatement');
     }
 
+    /**
+     * @group ZF-8399
+     */
+    public function testLongQueryWithTextField()
+    {
+        $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
+    }
+
     public function getDriver()
     {
         return 'Oracle';
     }
-
 }

+ 8 - 0
tests/Zend/Db/Adapter/Pdo/OciTest.php

@@ -252,6 +252,14 @@ class Zend_Db_Adapter_Pdo_OciTest extends Zend_Db_Adapter_Pdo_TestCommon
         $this->assertEquals($expected, stream_get_contents($value));
     }
 
+    /**
+     * @group ZF-8399
+     */
+    public function testLongQueryWithTextField()
+    {
+        $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
+    }
+
     public function getDriver()
     {
         return 'Pdo_Oci';

+ 40 - 0
tests/Zend/Db/Adapter/TestCommon.php

@@ -2014,4 +2014,44 @@ abstract class Zend_Db_Adapter_TestCommon extends Zend_Db_TestSetup
         $quotedString = $this->_db->quoteInto('? = bar', 'foo', NULL, 1);
         $this->assertEquals("'foo' = bar", $quotedString);
     }
+
+    /**
+     * @group ZF-8399
+     */
+    public function testLongQueryWithTextField()
+    {
+        // create test table using no identifier quoting
+        $this->_util->createTable('zf_longquery', array(
+            'id'    => 'INTEGER NOT NULL',
+            'stuff' => 'TEXT NOT NULL'
+        ));
+        $tableName = $this->_util->getTableName('zf_longquery');
+
+        // insert into the table
+        $longValue = str_repeat('x', 4000);
+        $numRows = $this->_db->insert($tableName, array(
+            'id' => 1,
+            'stuff' => $longValue
+        ));
+
+        $quotedTableName = $this->_db->quoteIdentifier('zf_longquery');
+        $sql = "INSERT INTO $quotedTableName VALUES (2, '$longValue')";
+        $this->_db->query($sql);
+
+        // check if the row was inserted as expected
+        $select = $this->_db->select()->from($tableName, array('id', 'stuff'));
+
+        $stmt = $this->_db->query($select);
+        $fetched = $stmt->fetchAll(Zend_Db::FETCH_NUM);
+        $a = array(
+            0 => array(0 => 1, 1 => $longValue),
+            1 => array(0 => 2, 1 => $longValue)
+        );
+        $this->assertEquals($a, $fetched,
+            'result of query not as expected');
+
+        // clean up
+        unset($stmt);
+        $this->_util->dropTable($tableName);
+    }
 }