2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* DboOracleTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2010-01-26 19:18:20 +00:00
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2010-01-26 19:18:20 +00:00
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.libs
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-11-21 20:13:33 +00:00
|
|
|
|
2011-04-17 10:35:21 +00:00
|
|
|
require_once CAKE . 'Model' . DS . 'Datasource' . DS . 'DboSource.php';
|
|
|
|
require_once CAKE . 'Model' . DS . 'Datasource' . DS . 'Database' . DS . 'Oracle.php';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* DboOracleTest class
|
2008-06-24 20:30:51 +00:00
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs.model.datasources.dbo
|
2008-06-02 19:22:55 +00:00
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
class DboOracleTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-12-10 01:30:36 +00:00
|
|
|
/**
|
|
|
|
* fixtures property
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $fixtures = array('core.oracle_user');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-24 20:30:51 +00:00
|
|
|
/**
|
|
|
|
* setup method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function setUp() {
|
2011-05-24 16:45:10 +00:00
|
|
|
$this->Dbo = ConnectionManager::getDataSource('test');
|
|
|
|
if (!($this->Dbo instanceof Oracle)) {
|
|
|
|
$this->markTestSkipped('The Oracle extension is not available.');
|
|
|
|
}
|
2008-06-24 20:30:51 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testLastErrorStatement method
|
2008-06-24 20:30:51 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testLastErrorStatement() {
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->expectError();
|
|
|
|
$this->db->execute("SELECT ' FROM dual");
|
|
|
|
$e = $this->db->lastError();
|
|
|
|
$r = 'ORA-01756: quoted string not properly terminated';
|
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-05 15:20:45 +00:00
|
|
|
/**
|
|
|
|
* testLastErrorConnect method
|
2008-06-24 20:30:51 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testLastErrorConnect() {
|
2008-05-30 11:40:08 +00:00
|
|
|
$config = $this->db->config;
|
2008-12-10 01:30:36 +00:00
|
|
|
$old_pw = $this->db->config['password'];
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->db->config['password'] = 'keepmeout';
|
|
|
|
$this->db->connect();
|
|
|
|
$e = $this->db->lastError();
|
|
|
|
$r = 'ORA-01017: invalid username/password; logon denied';
|
|
|
|
$this->assertEqual($e, $r);
|
2008-12-10 01:30:36 +00:00
|
|
|
$this->db->config['password'] = $old_pw;
|
|
|
|
$this->db->connect();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-24 20:30:51 +00:00
|
|
|
/**
|
|
|
|
* testName method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testName() {
|
2008-06-24 21:11:23 +00:00
|
|
|
$Db = $this->db;
|
2010-11-13 04:05:44 +00:00
|
|
|
#$Db = new DboOracle($config = null, $autoConnect = false);
|
2008-06-24 20:30:51 +00:00
|
|
|
|
|
|
|
$r = $Db->name($Db->name($Db->name('foo.last_update_date')));
|
2008-06-24 21:11:23 +00:00
|
|
|
$e = 'foo.last_update_date';
|
2008-06-24 20:30:51 +00:00
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
|
|
|
|
$r = $Db->name($Db->name($Db->name('foo._update')));
|
|
|
|
$e = 'foo."_update"';
|
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
|
|
|
|
$r = $Db->name($Db->name($Db->name('foo.last_update_date')));
|
2008-06-24 21:11:23 +00:00
|
|
|
$e = 'foo.last_update_date';
|
2008-06-24 20:30:51 +00:00
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
|
|
|
|
$r = $Db->name($Db->name($Db->name('last_update_date')));
|
|
|
|
$e = 'last_update_date';
|
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
|
|
|
|
$r = $Db->name($Db->name($Db->name('_update')));
|
2008-06-24 21:11:23 +00:00
|
|
|
$e = '"_update"';
|
2008-06-24 20:30:51 +00:00
|
|
|
$this->assertEqual($e, $r);
|
|
|
|
|
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|