TYPO3 CMS  TYPO3_6-2
AbstractTestCase.php
Go to the documentation of this file.
1 <?php
3 
17 require_once __DIR__ . '/../../../../adodb/adodb/adodb.inc.php';
18 require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-mssql.inc.php';
19 require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-oci8.inc.php';
20 require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-postgres7.inc.php';
21 
26 
35  protected function prepareSubject($driver, array $configuration) {
37  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('getFieldInfoCache'), array(), '', FALSE);
38 
39  $subject->conf = $configuration;
40 
41  // Disable caching
42  $mockCacheFrontend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
43  $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
44 
45  // Inject SqlParser - Its logic is tested with the tests, too.
46  $sqlParser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'), array(), '', FALSE);
47  $sqlParser->_set('databaseConnection', $subject);
48  $subject->SQLparser = $sqlParser;
49 
50  // Mock away schema migration service from install tool
51  $installerSqlMock = $this->getMock('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService', array('getFieldDefinitions_fileContent'), array(), '', FALSE);
52  $installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array()));
53  $subject->_set('installerSql', $installerSqlMock);
54 
55  $subject->initialize();
56 
57  // Fake a working connection
58  $handlerKey = '_DEFAULT';
59  $subject->lastHandlerKey = $handlerKey;
60  $adodbDriverClass = '\ADODB_' . $driver;
61  $subject->handlerInstance[$handlerKey] = new $adodbDriverClass();
62  $subject->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($subject->handlerInstance[$handlerKey]);
63  $subject->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
64 
65  return $subject;
66  }
67 
68 
75  protected function cleanSql($sql) {
76  if (!is_string($sql)) {
77  return $sql;
78  }
79  $sql = str_replace("\n", ' ', $sql);
80  $sql = preg_replace('/\\s+/', ' ', $sql);
81  return trim($sql);
82  }
83 }
$driver
Definition: server.php:34
$sql
Definition: server.php:82
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)