TYPO3 CMS  TYPO3_6-2
Typo3DbBackendTest.php
Go to the documentation of this file.
1 <?php
3 
21 
26  $mockValueObject = $this->getMock('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject', array('_getProperties'), array(), '', FALSE);
27  $mockValueObject->expects($this->once())->method('_getProperties')->will($this->returnValue(array('propertyName' => 'propertyValue')));
28  $mockColumnMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array('isPersistableProperty', 'getColumnName'), array(), '', FALSE);
29  $mockColumnMap->expects($this->any())->method('getColumnName')->will($this->returnValue('column_name'));
30  $tableName = 'tx_foo_table';
31  $mockDataMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array('isPersistableProperty', 'getColumnMap', 'getTableName'), array(), '', FALSE);
32  $mockDataMap->expects($this->any())->method('isPersistableProperty')->will($this->returnValue(TRUE));
33  $mockDataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($mockColumnMap));
34  $mockDataMap->expects($this->any())->method('getTableName')->will($this->returnValue($tableName));
35  $mockDataMapper = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper', array('getDataMap'), array(), '', FALSE);
36  $mockDataMapper->expects($this->once())->method('getDataMap')->will($this->returnValue($mockDataMap));
37  $expectedStatement = 'SELECT * FROM tx_foo_table WHERE column_name=?';
38  $expectedParameters = array('plainPropertyValue');
39  $expectedUid = 52;
40  $mockDataBaseHandle = $this->getMock('TYPO3\CMS\Core\Database\DatabaseConnection', array('sql_query', 'sql_fetch_assoc'), array(), '', FALSE);
41  $mockDataBaseHandle->expects($this->once())->method('sql_query')->will($this->returnValue('resource'));
42  $mockDataBaseHandle->expects($this->any())->method('sql_fetch_assoc')->with('resource')->will($this->returnValue(array('uid' => $expectedUid)));
43  $mockTypo3DbBackend = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend', array('getPlainValue', 'checkSqlErrors', 'replacePlaceholders', 'addVisibilityConstraintStatement'), array(), '', FALSE);
44  $mockTypo3DbBackend->expects($this->once())->method('getPlainValue')->will($this->returnValue('plainPropertyValue'));
45  $mockTypo3DbBackend->expects($this->once())->method('addVisibilityConstraintStatement')->with($this->isInstanceOf('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface'), $tableName, $this->isType('array'));
46  $mockTypo3DbBackend->expects($this->once())->method('replacePlaceholders')->with($expectedStatement, $expectedParameters);
47  $mockTypo3DbBackend->_set('dataMapper', $mockDataMapper);
48  $mockTypo3DbBackend->_set('databaseHandle', $mockDataBaseHandle);
49  $result = $mockTypo3DbBackend->_callRef('getUidOfAlreadyPersistedValueObject', $mockValueObject);
50  $this->assertSame($expectedUid, $result);
51  }
52 
56  public function doLanguageAndWorkspaceOverlayChangesUidIfInPreview() {
57  $comparisonRow = array(
58  'uid' => '42',
59  'pid' => '42',
60  '_ORIG_pid' => '-1',
61  '_ORIG_uid' => '43'
62  );
63  $row = array(
64  'uid' => '42',
65  'pid' => '42'
66  );
67  $workspaceVersion = array(
68  'uid' => '43',
69  'pid' => '-1'
70  );
72  $mockQuerySettings = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings', array('dummy'), array(), '', FALSE);
73 
74  $workspaceUid = 2;
75  $sourceMock = new \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Selector('tx_foo', 'Tx_Foo');
77  $pageRepositoryMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository', array('movePlhOL', 'getWorkspaceVersionOfRecord'));
78  $pageRepositoryMock->versioningPreview = TRUE;
79  $pageRepositoryMock->expects($this->once())->method('getWorkspaceVersionOfRecord')->with($workspaceUid, 'tx_foo', '42')->will($this->returnValue($workspaceVersion));
80  $mockTypo3DbBackend = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend', array('dummy'), array(), '', FALSE);
81  $mockTypo3DbBackend->_set('pageRepository', $pageRepositoryMock);
82  $this->assertSame(array($comparisonRow), $mockTypo3DbBackend->_call('doLanguageAndWorkspaceOverlay', $sourceMock, array($row), $mockQuerySettings, $workspaceUid));
83  }
84 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.