OracleTest.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'Zend/Db/Table/TestCommon.php';
  22. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  23. class Zend_Db_Table_OracleTest extends Zend_Db_Table_TestCommon
  24. {
  25. public function testTableInsert()
  26. {
  27. $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
  28. }
  29. public function testIsIdentity()
  30. {
  31. $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
  32. }
  33. /**
  34. * ZF-4330: Oracle needs sequence
  35. */
  36. public function testTableInsertWithSchema()
  37. {
  38. $schemaName = $this->_util->getSchema();
  39. $tableName = 'zfbugs';
  40. $identifier = join('.', array_filter(array($schemaName, $tableName)));
  41. $table = $this->_getTable('Zend_Db_Table_TableSpecial',
  42. array('name' => $tableName, 'schema' => $schemaName, Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')
  43. );
  44. $row = array (
  45. 'bug_description' => 'New bug',
  46. 'bug_status' => 'NEW',
  47. 'created_on' => '2007-04-02',
  48. 'updated_on' => '2007-04-02',
  49. 'reported_by' => 'micky',
  50. 'assigned_to' => 'goofy',
  51. 'verified_by' => 'dduck'
  52. );
  53. $profilerEnabled = $this->_db->getProfiler()->getEnabled();
  54. $this->_db->getProfiler()->setEnabled(true);
  55. $insertResult = $table->insert($row);
  56. $this->_db->getProfiler()->setEnabled($profilerEnabled);
  57. $qp = $this->_db->getProfiler()->getLastQueryProfile();
  58. $tableSpec = $this->_db->quoteIdentifier($identifier, true);
  59. $this->assertContains("INSERT INTO $tableSpec ", $qp->getQuery());
  60. }
  61. public function testTableInsertSequence()
  62. {
  63. $table = $this->_getTable('Zend_Db_Table_TableBugs',
  64. array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
  65. $row = array (
  66. 'bug_description' => 'New bug',
  67. 'bug_status' => 'NEW',
  68. 'created_on' => new Zend_Db_Expr(
  69. $this->_db->quoteInto('DATE ?', '2007-04-02')),
  70. 'updated_on' => new Zend_Db_Expr(
  71. $this->_db->quoteInto('DATE ?', '2007-04-02')),
  72. 'reported_by' => 'micky',
  73. 'assigned_to' => 'goofy'
  74. );
  75. $insertResult = $table->insert($row);
  76. $lastInsertId = $this->_db->lastInsertId('zfbugs');
  77. $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq');
  78. $this->assertEquals($insertResult, $lastInsertId);
  79. $this->assertEquals($insertResult, $lastSequenceId);
  80. $this->assertEquals(5, $insertResult);
  81. }
  82. public function getDriver()
  83. {
  84. return 'Oracle';
  85. }
  86. }