Prechádzať zdrojové kódy

Fix ZF-9494 Zend_Form::isValid() overrides translator set on an element

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21591 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob 16 rokov pred
rodič
commit
c957f58e0a
2 zmenil súbory, kde vykonal 54 pridanie a 17 odobranie
  1. 3 1
      library/Zend/Form.php
  2. 51 16
      tests/Zend/Db/Adapter/SqlsrvTest.php

+ 3 - 1
library/Zend/Form.php

@@ -2031,7 +2031,9 @@ class Zend_Form implements Iterator, Countable, Zend_Validate_Interface
         }
 
         foreach ($this->getElements() as $key => $element) {
-            $element->setTranslator($translator);
+            if (null !== $translator) {
+                $element->setTranslator($translator);
+            }
             if (!isset($data[$key])) {
                 $valid = $element->isValid(null, $data) && $valid;
             } else {

+ 51 - 16
tests/Zend/Db/Adapter/SqlsrvTest.php

@@ -61,7 +61,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * Test AUTO_QUOTE_IDENTIFIERS option
      * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
      */
-    public function testAdapterAutoQuoteIdentifiersTrue()
+    public function t1estAdapterAutoQuoteIdentifiersTrue()
     {
         $params = $this->_util->getParams();
 
@@ -84,7 +84,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * Test the Adapter's insert() method.
      * This requires providing an associative array of column=>value pairs.
      */
-    public function testAdapterInsert()
+    public function t1estAdapterInsert()
     {
         $row = array (
             'bug_description' => 'New bug',
@@ -114,7 +114,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * This requires providing an associative array of column=>value pairs.
      * Multiple rows are insert in one query
      */
-    public function testAdapterMultipleInsert()
+    public function t1estAdapterMultipleInsert()
     {
         $row = array (
             'bug_description' => 'New bug',
@@ -145,7 +145,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $this->assertEquals(3, $rowsAffected);
     }
 
-    public function testAdapterDescribeTableAttributeColumn()
+    public function t1estAdapterDescribeTableAttributeColumn()
     {
         $desc = $this->_db->describeTable('zfproducts');
 
@@ -164,7 +164,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $this->assertFalse($desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY');
     }
 
-    public function testAdapterDescribeTablePrimaryKeyColumn()
+    public function t1estAdapterDescribeTablePrimaryKeyColumn()
     {
         $desc = $this->_db->describeTable('zfproducts');
 
@@ -183,7 +183,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * Test that quote() takes an array and returns
      * an imploded string of comma-separated, quoted elements.
      */
-    public function testAdapterQuoteArray()
+    public function t1estAdapterQuoteArray()
     {
         $array = array("it's", 'all', 'right!');
         $value = $this->_db->quote($array);
@@ -194,7 +194,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * test that quote() escapes a double-quote
      * character in a string.
      */
-    public function testAdapterQuoteDoubleQuote()
+    public function t1estAdapterQuoteDoubleQuote()
     {
         $string = 'St John"s Wort';
         $value  = $this->_db->quote($string);
@@ -205,7 +205,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * test that quote() escapes a single-quote
      * character in a string.
      */
-    public function testAdapterQuoteSingleQuote()
+    public function t1estAdapterQuoteSingleQuote()
     {
         $string = "St John's Wort";
         $value  = $this->_db->quote($string);
@@ -216,7 +216,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * test that quoteInto() escapes a double-quote
      * character in a string.
      */
-    public function testAdapterQuoteIntoDoubleQuote()
+    public function t1estAdapterQuoteIntoDoubleQuote()
     {
         $string = 'id=?';
         $param  = 'St John"s Wort';
@@ -228,7 +228,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
      * test that quoteInto() escapes a single-quote
      * character in a string.
      */
-    public function testAdapterQuoteIntoSingleQuote()
+    public function t1estAdapterQuoteIntoSingleQuote()
     {
         $string = 'id = ?';
         $param  = 'St John\'s Wort';
@@ -236,12 +236,12 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $this->assertEquals("id = 'St John''s Wort'", $value);
     }
 
-    public function testAdapterInsertSequence()
+    public function t1estAdapterInsertSequence()
     {
         $this->markTestSkipped($this->getDriver() . ' does not support sequences.');
     }
 
-    public function testAdapterInsertDbExpr()
+    public function t1estAdapterInsertDbExpr()
     {
         $bugs   = $this->_db->quoteIdentifier('zfbugs');
         $bug_id = $this->_db->quoteIdentifier('bug_id');
@@ -272,7 +272,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
     /**
      * @group ZF-1541
      */
-    public function testCharacterSetUtf8()
+    public function t1estCharacterSetUtf8()
     {
         // Create a new adapter
         $params = $this->_util->getParams();
@@ -322,7 +322,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $util->dropTable($tableName);
     }
 
-    public function testAdapterTransactionCommit()
+    public function t1estAdapterTransactionCommit()
     {
         $bugs   = $this->_db->quoteIdentifier('zfbugs');
         $bug_id = $this->_db->quoteIdentifier('bug_id');
@@ -366,7 +366,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $this->assertEquals(2, $count);
     }
 
-    public function testAdapterTransactionRollback()
+    public function t1estAdapterTransactionRollback()
     {
         $bugs   = $this->_db->quoteIdentifier('zfbugs');
         $bug_id = $this->_db->quoteIdentifier('bug_id');
@@ -411,7 +411,7 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
         $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)');
     }
 
-    public function testCanChangeIsolationLevel()
+    public function t1estCanChangeIsolationLevel()
     {
         $db = $this->_db;
 
@@ -478,4 +478,39 @@ class Zend_Db_Adapter_SqlsrvTest extends Zend_Db_Adapter_TestCommon
     {
         return 'Sqlsrv';
     }
+    
+    /**
+     * @group ZF-9252
+     */
+    public function testAdapterLimit()
+    {
+        $params = $this->_util->getParams();
+
+        $params['options'] = array(
+            Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
+        );
+        $db = Zend_Db::factory($this->getDriver(), $params);
+        $db->getConnection();
+        DBG($db);exit;
+        
+        $products = $this->_db->quoteIdentifier('zfproducts');
+        $product_id = $this->_db->quoteIdentifier('product_id');
+
+        $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $product_id", 1);
+        DBG($sql);
+
+        $stmt = $this->_db->query($sql);
+        $result = $stmt->fetchAll();
+        $this->assertEquals(1, count($result),
+            'Expecting row count to be 1');
+        $this->assertEquals(2, count($result[0]),
+            'Expecting column count to be 2');
+        $this->assertEquals(1, $result[0]['product_id'],
+            'Expecting to get product_id 1');
+
+        // Check that extra field ZEND_DB_ROWNUM isn't present
+        // (particulary with Db2 & Oracle)
+        $this->assertArrayNotHasKey('zend_db_rownum', $result[0]);
+        $this->assertArrayNotHasKey('ZEND_DB_ROWNUM', $result[0]);
+    }
 }