| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Db
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id $
- */
- require_once 'Zend/Db/Statement/TestCommon.php';
- /**
- * @category Zend
- * @package Zend_Db
- * @subpackage UnitTests
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @group Zend_Db
- * @group Zend_Db_Statement
- */
- class Zend_Db_Statement_Db2Test extends Zend_Db_Statement_TestCommon
- {
- public function testStatementErrorCodeKeyViolation()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
- public function testStatementErrorInfoKeyViolation()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
- public function testStatementColumnCountForSelect()
- {
- $select = $this->_db->select()
- ->from('zfproducts');
- $stmt = $this->_db->prepare($select->__toString());
- $n = $stmt->columnCount();
- // DB2 returns the column count once the query has been prepared
- // while PDO returns it only after it has been executed
- $this->assertEquals(2, $n);
- $stmt->execute();
- $n = $stmt->columnCount();
- $stmt->closeCursor();
- $this->assertTrue(is_int($n));
- $this->assertEquals(2, $n);
- }
- public function testStatementBindParamByPosition()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
- public function testStatementBindParamByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
- $productIdValue = 4;
- $productNameValue = 'AmigaOS';
- try {
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)");
- // test with colon prefix
- $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true');
- // test with no colon prefix
- $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true');
- $this->fail('Expected to catch Zend_Db_Statement_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Exception,
- 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
- $this->assertEquals("Invalid bind-variable name ':id'", $e->getMessage());
- }
- }
- public function testStatementBindValueByPosition()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
- public function testStatementBindValueByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
- $productIdValue = 4;
- $productNameValue = 'AmigaOS';
- try {
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)");
- // test with colon prefix
- $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true');
- // test with no colon prefix
- $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true');
- $this->fail('Expected to catch Zend_Db_Statement_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Exception,
- 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
- $this->assertEquals("Invalid bind-variable name ':id'", $e->getMessage());
- }
- }
- public function testStatementGetColumnMeta()
- {
- $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]');
- }
- public function getDriver()
- {
- return 'Db2';
- }
- }
|