[TASK] Rename ExtensionManager class
[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_TYPO3\CMS\Core\Database\DatabaseConnection $db
39 * @param string $driver Driver to use (e.g., 'oci8')
40 * @return \ADOConnection
41 */
42 static public function connect(\ux_TYPO3\CMS\Core\Database\DatabaseConnection $db, $driver) {
43 // Make sure to have a clean configuration
44 $db->clearCachedFieldInfo();
45 $db->_call('initInternalVariables');
46 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('adodb') . 'adodb/adodb.inc.php';
47 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('adodb') . 'adodb/drivers/adodb-' . $driver . '.inc.php';
48 $handlerKey = '_DEFAULT';
49 $db->lastHandlerKey = $handlerKey;
50 $db->handlerInstance[$handlerKey] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('ADODB_' . $driver);
51 // From method handler_init()
52 $db->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($db->handlerInstance[$handlerKey]);
53 // DataDictionary being set, a connectionID may be arbitrarily chosen
54 $db->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
55 }
56
57 }
58
59
60 ?>