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