OracleTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * DboOracleTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package Cake.Test.Case.Model.Datasource.Database
  16. * @since CakePHP(tm) v 1.2.0
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. require_once CAKE . 'Model' . DS . 'Datasource' . DS . 'DboSource.php';
  20. require_once CAKE . 'Model' . DS . 'Datasource' . DS . 'Database' . DS . 'Oracle.php';
  21. /**
  22. * DboOracleTest class
  23. *
  24. * @package Cake.Test.Case.Model.Datasource.Database
  25. */
  26. class DboOracleTest extends CakeTestCase {
  27. /**
  28. * fixtures property
  29. */
  30. public $fixtures = array('core.oracle_user');
  31. /**
  32. * setup method
  33. *
  34. * @return void
  35. */
  36. public function setUp() {
  37. $this->Dbo = ConnectionManager::getDataSource('test');
  38. if (!($this->Dbo instanceof Oracle)) {
  39. $this->markTestSkipped('The Oracle extension is not available.');
  40. }
  41. }
  42. /**
  43. * testLastErrorStatement method
  44. *
  45. * @return void
  46. */
  47. public function testLastErrorStatement() {
  48. $this->expectError();
  49. $this->db->execute("SELECT ' FROM dual");
  50. $e = $this->db->lastError();
  51. $r = 'ORA-01756: quoted string not properly terminated';
  52. $this->assertEqual($e, $r);
  53. }
  54. /**
  55. * testLastErrorConnect method
  56. *
  57. * @return void
  58. */
  59. public function testLastErrorConnect() {
  60. $config = $this->db->config;
  61. $old_pw = $this->db->config['password'];
  62. $this->db->config['password'] = 'keepmeout';
  63. $this->db->connect();
  64. $e = $this->db->lastError();
  65. $r = 'ORA-01017: invalid username/password; logon denied';
  66. $this->assertEqual($e, $r);
  67. $this->db->config['password'] = $old_pw;
  68. $this->db->connect();
  69. }
  70. /**
  71. * testName method
  72. *
  73. * @return void
  74. */
  75. public function testName() {
  76. $Db = $this->db;
  77. #$Db = new DboOracle($config = null, $autoConnect = false);
  78. $r = $Db->name($Db->name($Db->name('foo.last_update_date')));
  79. $e = 'foo.last_update_date';
  80. $this->assertEqual($e, $r);
  81. $r = $Db->name($Db->name($Db->name('foo._update')));
  82. $e = 'foo."_update"';
  83. $this->assertEqual($e, $r);
  84. $r = $Db->name($Db->name($Db->name('foo.last_update_date')));
  85. $e = 'foo.last_update_date';
  86. $this->assertEqual($e, $r);
  87. $r = $Db->name($Db->name($Db->name('last_update_date')));
  88. $e = 'last_update_date';
  89. $this->assertEqual($e, $r);
  90. $r = $Db->name($Db->name($Db->name('_update')));
  91. $e = '"_update"';
  92. $this->assertEqual($e, $r);
  93. }
  94. }