2
0

OciTest.php 3.7 KB

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