OracleTest.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id $
  21. */
  22. require_once 'Zend/Db/Statement/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. * @group Zend_Db
  30. * @group Zend_Db_Statement
  31. */
  32. class Zend_Db_Statement_OracleTest extends Zend_Db_Statement_TestCommon
  33. {
  34. public function testStatementBindParamByPosition()
  35. {
  36. $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
  37. }
  38. public function testStatementBindValueByPosition()
  39. {
  40. $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
  41. }
  42. public function testStatementErrorCodeKeyViolation()
  43. {
  44. $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
  45. }
  46. public function testStatementErrorInfoKeyViolation()
  47. {
  48. $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
  49. }
  50. public function testStatementExecuteWithParams()
  51. {
  52. $products = $this->_db->quoteIdentifier('zfproducts');
  53. $product_id = $this->_db->quoteIdentifier('product_id');
  54. $product_name = $this->_db->quoteIdentifier('product_name');
  55. $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
  56. $stmt->execute(array('product_id' => 4, 'product_name' => 'Solaris'));
  57. $select = $this->_db->select()
  58. ->from('zfproducts')
  59. ->where("$product_id = 4");
  60. $result = $this->_db->fetchAll($select);
  61. $stmt->closeCursor();
  62. $this->assertEquals(array(array('product_id'=>4, 'product_name'=>'Solaris')), $result);
  63. }
  64. public function testStatementFetchAllStyleBoth()
  65. {
  66. $this->markTestIncomplete($this->getDriver() . ' driver does not support fetchAll(FETCH_BOTH)');
  67. }
  68. public function testStatementGetColumnMeta()
  69. {
  70. $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]');
  71. }
  72. public function testStatementNextRowset()
  73. {
  74. $select = $this->_db->select()
  75. ->from('zfproducts');
  76. $stmt = $this->_db->prepare($select->__toString());
  77. try {
  78. $stmt->nextRowset();
  79. $this->fail('Expected to catch Zend_Db_Statement_Oracle_Exception');
  80. } catch (Zend_Exception $e) {
  81. $this->assertTrue($e instanceof Zend_Db_Statement_Oracle_Exception,
  82. 'Expecting object of type Zend_Db_Statement_Oracle_Exception, got '.get_class($e));
  83. $this->assertEquals('HYC00 Optional feature not implemented', $e->getMessage());
  84. }
  85. $stmt->closeCursor();
  86. }
  87. /**
  88. * @group ZF-5927
  89. */
  90. public function testStatementReturnNullWithEmptyField()
  91. {
  92. $products = $this->_db->quoteIdentifier('zfproducts');
  93. $product_id = $this->_db->quoteIdentifier('product_id');
  94. $product_name = $this->_db->quoteIdentifier('product_name');
  95. $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
  96. $stmt->execute(array('product_id' => 4, 'product_name' => null));
  97. $select = $this->_db->select()
  98. ->from('zfproducts')
  99. ->where("$product_id = 4");
  100. $result = $this->_db->fetchAll($select);
  101. $this->assertTrue(array_key_exists('product_name', $result[0]), 'fetchAll must return null for empty fields with Oracle');
  102. $result = $this->_db->fetchRow($select);
  103. $this->assertTrue(array_key_exists('product_name', $result), 'fetchRow must return null for empty fields with Oracle');
  104. }
  105. public function testStatementSetFetchModeBoth()
  106. {
  107. $this->markTestIncomplete($this->getDriver() . ' does not implement FETCH_BOTH correctly.');
  108. }
  109. public function getDriver()
  110. {
  111. return 'Oracle';
  112. }
  113. }