Kaynağa Gözat

ZF-8350 - Allow to set quote identifier for Zend_Test_DbAdapter

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19082 44c647ce-9c0f-0410-b52a-842ac1e357ba
beberlei 16 yıl önce
ebeveyn
işleme
874b3d081f

+ 3 - 1
documentation/manual/en/module_specs/Zend_Test-PHPUnit-Db-Adapter.xml

@@ -85,6 +85,8 @@ echo $qp->getQuerY(); // SELECT * FROM bugs
     <para>
         The Test adapter also specifies methods to simulate the use of the methods
         <methodname>listTables()</methodname>, <methodname>describeTables()</methodname> and
-        <methodname>lastInsertId()</methodname>.
+        <methodname>lastInsertId()</methodname>. Additionally using the
+        <methodname>setQuoteIdentifierSymbol()</methodname> you can specify which
+        symbol should be used for quoting, by default none is used.
     </para>
 </sect2>

+ 14 - 1
library/Zend/Test/DbAdapter.php

@@ -72,6 +72,11 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
     protected $_describeTables = array();
 
     /**
+     * @var string
+     */ 
+    protected $_quoteIdentifierSymbol = '';
+
+    /**
      * Empty constructor to make it parameterless.
      */
     public function __construct()
@@ -106,13 +111,21 @@ class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
     }
 
     /**
+     * @var string
+     */ 
+    public function setQuoteIdentifierSymbol($symbol)
+    {
+        $this->_quoteIdentifierSymbol = $symbol;
+    }
+
+    /**
      * Returns the symbol the adapter uses for delimited identifiers.
      *
      * @return string
      */
     public function getQuoteIdentifierSymbol()
     {
-        return '';
+        return $this->_quoteIdentifierSymbol;
     }
 
     /**

+ 7 - 0
tests/Zend/Test/DbAdapterTest.php

@@ -163,4 +163,11 @@ class Zend_Test_DbAdapterTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(array(1 => 1234), $qp->getQueryParams());
         $this->assertEquals("SELECT * FROM foo WHERE bar = ?", $qp->getQuery());
     }
+
+    public function testGetSetQuoteIdentifierSymbol()
+    {
+        $this->assertEquals('', $this->_adapter->getQuoteIdentifierSymbol());
+        $this->_adapter->setQuoteIdentifierSymbol('`');
+        $this->assertEquals('`', $this->_adapter->getQuoteIdentifierSymbol());
+    }
 }