Raised DBAL version from 1.1.7 to 1.1.8
[Packages/TYPO3.CMS.git] / typo3 / sysext / dbal / tests / FakeDbConnection.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2010 Xavier Perseguers <typo3@perseguers.ch>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * Fake ADOdb connection factory.
28 *
29 * $Id: FakeDbConnection.php 27006 2009-11-25 22:08:07Z xperseguers $
30 *
31 * @author Xavier Perseguers <typo3@perseguers.ch>
32 *
33 * @package TYPO3
34 * @subpackage dbal
35 */
36 class FakeDbConnection {
37
38 /**
39 * Creates a fake database connection.
40 *
41 * @param ux_t3lib_db $db
42 * @param string $databaseType Type of the database (e.g., 'oracle')
43 * @param string $driver Driver to use (e.g., 'oci8')
44 * @return ADOConnection
45 */
46 public static function connect(ux_t3lib_db $db, $driver) {
47 // Make sure to have a clean configuration
48 $db->clearCachedFieldInfo();
49 $db->_call('initInternalVariables');
50
51 include_once(t3lib_extMgm::extPath('adodb') . 'adodb/drivers/adodb-' . $driver . '.inc.php');
52
53 $handlerKey = '_DEFAULT';
54 $db->lastHandlerKey = $handlerKey;
55 $db->handlerInstance[$handlerKey] = t3lib_div::makeInstance('ADODB_' . $driver);
56
57 // From method handler_init()
58 $db->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($db->handlerInstance[$handlerKey]);
59
60 // DataDictionary being set, a connectionID may be arbitrarily chosen
61 $db->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
62 }
63
64 }
65 ?>