OracleTest.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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-2009 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. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  24. /**
  25. * @category Zend
  26. * @package Zend_Db
  27. * @subpackage UnitTests
  28. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. * @group Zend_Db
  31. * @group Zend_Db_Statement
  32. */
  33. class Zend_Db_Statement_OracleTest extends Zend_Db_Statement_TestCommon
  34. {
  35. public function testStatementBindParamByPosition()
  36. {
  37. $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
  38. }
  39. public function testStatementBindValueByPosition()
  40. {
  41. $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
  42. }
  43. public function testStatementErrorCodeKeyViolation()
  44. {
  45. $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
  46. }
  47. public function testStatementErrorInfoKeyViolation()
  48. {
  49. $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
  50. }
  51. public function testStatementExecuteWithParams()
  52. {
  53. $products = $this->_db->quoteIdentifier('zfproducts');
  54. $product_id = $this->_db->quoteIdentifier('product_id');
  55. $product_name = $this->_db->quoteIdentifier('product_name');
  56. $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
  57. $stmt->execute(array('product_id' => 4, 'product_name' => 'Solaris'));
  58. $select = $this->_db->select()
  59. ->from('zfproducts')
  60. ->where("$product_id = 4");
  61. $result = $this->_db->fetchAll($select);
  62. $stmt->closeCursor();
  63. $this->assertEquals(array(array('product_id'=>4, 'product_name'=>'Solaris')), $result);
  64. }
  65. public function testStatementFetchAllStyleBoth()
  66. {
  67. $this->markTestIncomplete($this->getDriver() . ' driver does not support fetchAll(FETCH_BOTH)');
  68. }
  69. public function testStatementGetColumnMeta()
  70. {
  71. $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]');
  72. }
  73. public function testStatementNextRowset()
  74. {
  75. $select = $this->_db->select()
  76. ->from('zfproducts');
  77. $stmt = $this->_db->prepare($select->__toString());
  78. try {
  79. $stmt->nextRowset();
  80. $this->fail('Expected to catch Zend_Db_Statement_Oracle_Exception');
  81. } catch (Zend_Exception $e) {
  82. $this->assertType('Zend_Db_Statement_Oracle_Exception', $e,
  83. 'Expecting object of type Zend_Db_Statement_Oracle_Exception, got '.get_class($e));
  84. $this->assertEquals('HYC00 Optional feature not implemented', $e->getMessage());
  85. }
  86. $stmt->closeCursor();
  87. }
  88. /**
  89. * @group ZF-5927
  90. */
  91. public function testStatementReturnNullWithEmptyField()
  92. {
  93. $products = $this->_db->quoteIdentifier('zfproducts');
  94. $product_id = $this->_db->quoteIdentifier('product_id');
  95. $product_name = $this->_db->quoteIdentifier('product_name');
  96. $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
  97. $stmt->execute(array('product_id' => 4, 'product_name' => null));
  98. $select = $this->_db->select()
  99. ->from('zfproducts')
  100. ->where("$product_id = 4");
  101. $result = $this->_db->fetchAll($select);
  102. $this->assertTrue(array_key_exists('product_name', $result[0]), 'fetchAll must return null for empty fields with Oracle');
  103. $result = $this->_db->fetchRow($select);
  104. $this->assertTrue(array_key_exists('product_name', $result), 'fetchRow must return null for empty fields with Oracle');
  105. }
  106. public function testStatementSetFetchModeBoth()
  107. {
  108. $this->markTestIncomplete($this->getDriver() . ' does not implement FETCH_BOTH correctly.');
  109. }
  110. public function getDriver()
  111. {
  112. return 'Oracle';
  113. }
  114. }