PageRenderTime 24ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php

https://github.com/hardsshah/bookmarks
PHP | 132 lines | 81 code | 1 blank | 50 comment | 3 complexity | 7ed672900ef472cb7bd5f2d76b82da19 MD5 | raw file
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * DboOracleTest file
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
  9. * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  10. *
  11. * Licensed under The MIT License
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @filesource
  15. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  16. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  17. * @package cake
  18. * @subpackage cake.cake.libs
  19. * @since CakePHP(tm) v 1.2.0
  20. * @version $Revision$
  21. * @modifiedby $LastChangedBy$
  22. * @lastmodified $Date$
  23. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  24. */
  25. if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
  26. define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
  27. }
  28. require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo_source.php';
  29. require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle.php';
  30. /**
  31. * DboOracleTest class
  32. *
  33. * @package cake
  34. * @subpackage cake.tests.cases.libs.model.datasources.dbo
  35. */
  36. class DboOracleTest extends CakeTestCase {
  37. /**
  38. * fixtures property
  39. */
  40. var $fixtures = array('core.oracle_user');
  41. /**
  42. * setup method
  43. *
  44. * @access public
  45. * @return void
  46. */
  47. function setUp() {
  48. $this->_initDb();
  49. }
  50. /**
  51. * skip method
  52. *
  53. * @access public
  54. * @return void
  55. */
  56. function skip() {
  57. $this->_initDb();
  58. $this->skipif(
  59. $this->db->config['driver'] != 'oracle', 'Oracle connection not available'
  60. );
  61. }
  62. /**
  63. * testLastErrorStatement method
  64. *
  65. * @access public
  66. * @return void
  67. */
  68. function testLastErrorStatement() {
  69. if ($this->skip('testLastErrorStatement')) {
  70. return;
  71. }
  72. $this->expectError();
  73. $this->db->execute("SELECT ' FROM dual");
  74. $e = $this->db->lastError();
  75. $r = 'ORA-01756: quoted string not properly terminated';
  76. $this->assertEqual($e, $r);
  77. }
  78. /**
  79. * testLastErrorConnect method
  80. *
  81. * @access public
  82. * @return void
  83. */
  84. function testLastErrorConnect() {
  85. if ($this->skip('testLastErrorConnect')) {
  86. return;
  87. }
  88. $config = $this->db->config;
  89. $old_pw = $this->db->config['password'];
  90. $this->db->config['password'] = 'keepmeout';
  91. $this->db->connect();
  92. $e = $this->db->lastError();
  93. $r = 'ORA-01017: invalid username/password; logon denied';
  94. $this->assertEqual($e, $r);
  95. $this->db->config['password'] = $old_pw;
  96. $this->db->connect();
  97. }
  98. /**
  99. * testName method
  100. *
  101. * @access public
  102. * @return void
  103. */
  104. function testName() {
  105. $Db = $this->db;
  106. #$Db =& new DboOracle($config = null, $autoConnect = false);
  107. $r = $Db->name($Db->name($Db->name('foo.last_update_date')));
  108. $e = 'foo.last_update_date';
  109. $this->assertEqual($e, $r);
  110. $r = $Db->name($Db->name($Db->name('foo._update')));
  111. $e = 'foo."_update"';
  112. $this->assertEqual($e, $r);
  113. $r = $Db->name($Db->name($Db->name('foo.last_update_date')));
  114. $e = 'foo.last_update_date';
  115. $this->assertEqual($e, $r);
  116. $r = $Db->name($Db->name($Db->name('last_update_date')));
  117. $e = 'last_update_date';
  118. $this->assertEqual($e, $r);
  119. $r = $Db->name($Db->name($Db->name('_update')));
  120. $e = '"_update"';
  121. $this->assertEqual($e, $r);
  122. }
  123. }
  124. ?>