OracleTest.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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-2015 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/Table/TestCommon.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Db
  26. * @subpackage UnitTests
  27. * @copyright Copyright (c) 2005-2015 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_Table
  31. */
  32. class Zend_Db_Table_OracleTest extends Zend_Db_Table_TestCommon
  33. {
  34. public function testTableInsert()
  35. {
  36. $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
  37. }
  38. public function testIsIdentity()
  39. {
  40. $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
  41. }
  42. /**
  43. * ZF-4330: Oracle needs sequence
  44. */
  45. public function testTableInsertWithSchema()
  46. {
  47. $schemaName = $this->_util->getSchema();
  48. $tableName = 'zfbugs';
  49. $identifier = join('.', array_filter(array($schemaName, $tableName)));
  50. $table = $this->_getTable('My_ZendDbTable_TableSpecial',
  51. array('name' => $tableName, 'schema' => $schemaName, Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')
  52. );
  53. $row = array (
  54. 'bug_description' => 'New bug',
  55. 'bug_status' => 'NEW',
  56. 'created_on' => '2007-04-02',
  57. 'updated_on' => '2007-04-02',
  58. 'reported_by' => 'micky',
  59. 'assigned_to' => 'goofy',
  60. 'verified_by' => 'dduck'
  61. );
  62. $profilerEnabled = $this->_db->getProfiler()->getEnabled();
  63. $this->_db->getProfiler()->setEnabled(true);
  64. $insertResult = $table->insert($row);
  65. $this->_db->getProfiler()->setEnabled($profilerEnabled);
  66. $qp = $this->_db->getProfiler()->getLastQueryProfile();
  67. $tableSpec = $this->_db->quoteIdentifier($identifier, true);
  68. $this->assertContains("INSERT INTO $tableSpec ", $qp->getQuery());
  69. }
  70. public function testTableInsertSequence()
  71. {
  72. $table = $this->_getTable('My_ZendDbTable_TableBugs',
  73. array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
  74. $row = array (
  75. 'bug_description' => 'New bug',
  76. 'bug_status' => 'NEW',
  77. 'created_on' => new Zend_Db_Expr(
  78. $this->_db->quoteInto('DATE ?', '2007-04-02')),
  79. 'updated_on' => new Zend_Db_Expr(
  80. $this->_db->quoteInto('DATE ?', '2007-04-02')),
  81. 'reported_by' => 'micky',
  82. 'assigned_to' => 'goofy'
  83. );
  84. $insertResult = $table->insert($row);
  85. $lastInsertId = $this->_db->lastInsertId('zfbugs');
  86. $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq');
  87. $this->assertEquals($insertResult, $lastInsertId);
  88. $this->assertEquals($insertResult, $lastSequenceId);
  89. $this->assertEquals(5, $insertResult);
  90. }
  91. protected function _getRowForTableAndIdentityWithVeryLongName()
  92. {
  93. return array('thisisalongtablenameidentity' => 1, 'stuff' => 'information');
  94. }
  95. public function getDriver()
  96. {
  97. return 'Oracle';
  98. }
  99. }