31 array(
'Tx_Myext_Domain_Model_Foo'),
32 array(
'TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser')
41 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
42 $columnConfiguration = array(
44 'foreign_table' =>
'tx_myextension_bar',
45 'foreign_field' =>
'parentid' 47 $propertyMetaData = array(
51 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'setOneToOneRelation',
'setOneToManyRelation',
'setManyToManyRelation'), array(),
'', FALSE);
52 $mockDataMapFactory->expects($this->once())->method(
'setOneToOneRelation')->will($this->returnValue($mockColumnMap));
53 $mockDataMapFactory->expects($this->never())->method(
'setOneToManyRelation');
54 $mockDataMapFactory->expects($this->never())->method(
'setManyToManyRelation');
55 $mockDataMapFactory->_callRef(
'setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
62 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
64 'fieldname' =>
'foo_model' 66 $columnConfiguration = array(
68 'foreign_table' =>
'tx_myextension_bar',
69 'foreign_field' =>
'parentid',
70 'foreign_match_fields' => $matchFields
73 $mockColumnMap->expects($this->once())
74 ->method(
'setRelationTableMatchFields')
76 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'), array(),
'', FALSE);
77 $mockDataMapFactory->_call(
'setOneToOneRelation', $mockColumnMap, $columnConfiguration);
84 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
86 'fieldname' =>
'foo_model' 88 $columnConfiguration = array(
90 'foreign_table' =>
'tx_myextension_bar',
91 'foreign_field' =>
'parentid',
92 'foreign_match_fields' => $matchFields
95 $mockColumnMap->expects($this->once())
96 ->method(
'setRelationTableMatchFields')
98 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'), array(),
'', FALSE);
99 $mockDataMapFactory->_call(
'setOneToManyRelation', $mockColumnMap, $columnConfiguration);
106 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
107 $columnConfiguration = array(
109 'foreign_table' =>
'tx_myextension_bar',
110 'MM' =>
'tx_myextension_mm' 112 $propertyMetaData = array(
113 'type' =>
'Tx_Myext_Domain_Model_Foo',
114 'elementType' => NULL
116 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'setOneToOneRelation',
'setOneToManyRelation',
'setManyToManyRelation'), array(),
'', FALSE);
117 $mockDataMapFactory->expects($this->never())->method(
'setOneToOneRelation');
118 $mockDataMapFactory->expects($this->never())->method(
'setOneToManyRelation');
119 $mockDataMapFactory->expects($this->once())->method(
'setManyToManyRelation')->will($this->returnValue($mockColumnMap));
120 $mockDataMapFactory->_callRef(
'setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
127 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
128 $columnConfiguration = array(
130 'foreign_table' =>
'tx_myextension_bar',
131 'foreign_field' =>
'parentid',
132 'foreign_table_field' =>
'parenttable' 134 $propertyMetaData = array(
135 'type' =>
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
136 'elementType' =>
'Tx_Myext_Domain_Model_Foo' 138 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'setOneToOneRelation',
'setOneToManyRelation',
'setManyToManyRelation'), array(),
'', FALSE);
139 $mockDataMapFactory->expects($this->never())->method(
'setOneToOneRelation');
140 $mockDataMapFactory->expects($this->once())->method(
'setOneToManyRelation')->will($this->returnValue($mockColumnMap));
141 $mockDataMapFactory->expects($this->never())->method(
'setManyToManyRelation');
142 $mockDataMapFactory->_callRef(
'setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
149 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
150 $columnConfiguration = array(
152 'foreign_table' =>
'tx_myextension_bar',
153 'MM' =>
'tx_myextension_mm' 155 $propertyMetaData = array(
156 'type' =>
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
157 'elementType' =>
'Tx_Myext_Domain_Model_Foo' 159 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'setOneToOneRelation',
'setOneToManyRelation',
'setManyToManyRelation'), array(),
'', FALSE);
160 $mockDataMapFactory->expects($this->never())->method(
'setOneToOneRelation');
161 $mockDataMapFactory->expects($this->never())->method(
'setOneToManyRelation');
162 $mockDataMapFactory->expects($this->once())->method(
'setManyToManyRelation')->will($this->returnValue($mockColumnMap));
163 $mockDataMapFactory->_callRef(
'setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
170 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
171 $columnConfiguration = array(
173 'foreign_table' =>
'tx_myextension_righttable',
174 'MM' =>
'tx_myextension_mm' 176 $propertyMetaData = array(
177 'type' =>
'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage',
178 'elementType' =>
'Tx_Myext_Domain_Model_Foo' 180 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'setOneToOneRelation',
'setOneToManyRelation',
'setManyToManyRelation'), array(),
'', FALSE);
181 $mockDataMapFactory->expects($this->never())->method(
'setOneToOneRelation');
182 $mockDataMapFactory->expects($this->never())->method(
'setOneToManyRelation');
183 $mockDataMapFactory->expects($this->once())->method(
'setManyToManyRelation')->will($this->returnValue($mockColumnMap));
184 $mockDataMapFactory->_callRef(
'setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
191 $leftColumnsDefinition = array(
194 'foreign_table' =>
'tx_myextension_righttable',
195 'foreign_table_where' =>
'WHERE 1=1',
196 'MM' =>
'tx_myextension_mm',
197 'MM_table_where' =>
'WHERE 2=2' 200 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
202 $mockColumnMap->expects($this->once())->method(
'setRelationTableName')->with($this->equalTo(
'tx_myextension_mm'));
203 $mockColumnMap->expects($this->once())->method(
'setChildTableName')->with($this->equalTo(
'tx_myextension_righttable'));
204 $mockColumnMap->expects($this->once())->method(
'setChildTableWhereStatement')->with($this->equalTo(
'WHERE 1=1'));
205 $mockColumnMap->expects($this->once())->method(
'setChildSortByFieldName')->with($this->equalTo(
'sorting'));
206 $mockColumnMap->expects($this->once())->method(
'setParentKeyFieldName')->with($this->equalTo(
'uid_local'));
207 $mockColumnMap->expects($this->never())->method(
'setParentTableFieldName');
208 $mockColumnMap->expects($this->never())->method(
'setRelationTableMatchFields');
209 $mockColumnMap->expects($this->never())->method(
'setRelationTableInsertFields');
210 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'), array(),
'', FALSE);
211 $mockDataMapFactory->_callRef(
'setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition[
'rights']);
218 $rightColumnsDefinition = array(
221 'foreign_table' =>
'tx_myextension_lefttable',
222 'MM' =>
'tx_myextension_mm',
223 'MM_opposite_field' =>
'rights' 226 $leftColumnsDefinition[
'rights'][
'MM_opposite_field'] =
'opposite_field';
227 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
229 $mockColumnMap->expects($this->once())->method(
'setRelationTableName')->with($this->equalTo(
'tx_myextension_mm'));
230 $mockColumnMap->expects($this->once())->method(
'setChildTableName')->with($this->equalTo(
'tx_myextension_lefttable'));
231 $mockColumnMap->expects($this->once())->method(
'setChildTableWhereStatement')->with(NULL);
232 $mockColumnMap->expects($this->once())->method(
'setChildSortByFieldName')->with($this->equalTo(
'sorting_foreign'));
233 $mockColumnMap->expects($this->once())->method(
'setParentKeyFieldName')->with($this->equalTo(
'uid_foreign'));
234 $mockColumnMap->expects($this->never())->method(
'setParentTableFieldName');
235 $mockColumnMap->expects($this->never())->method(
'setRelationTableMatchFields');
236 $mockColumnMap->expects($this->never())->method(
'setRelationTableInsertFields');
237 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'), array(),
'', FALSE);
238 $mockDataMapFactory->_callRef(
'setManyToManyRelation', $mockColumnMap, $rightColumnsDefinition[
'lefts']);
245 $leftColumnsDefinition = array(
248 'foreign_table' =>
'tx_myextension_righttable',
249 'MM' =>
'tx_myextension_mm',
250 'foreign_sortby' =>
'sorting' 253 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
255 $mockColumnMap->expects($this->once())->method(
'setRelationTableName')->with($this->equalTo(
'tx_myextension_mm'));
256 $mockColumnMap->expects($this->once())->method(
'setChildTableName')->with($this->equalTo(
'tx_myextension_righttable'));
257 $mockColumnMap->expects($this->once())->method(
'setChildTableWhereStatement');
258 $mockColumnMap->expects($this->once())->method(
'setChildSortByFieldName')->with($this->equalTo(
'sorting'));
259 $mockColumnMap->expects($this->once())->method(
'setParentKeyFieldName')->with($this->equalTo(
'uid_local'));
260 $mockColumnMap->expects($this->never())->method(
'setParentTableFieldName');
261 $mockColumnMap->expects($this->never())->method(
'setRelationTableMatchFields');
262 $mockColumnMap->expects($this->never())->method(
'setRelationTableInsertFields');
263 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'getColumnsDefinition'), array(),
'', FALSE);
264 $mockDataMapFactory->expects($this->never())->method(
'getColumnsDefinition');
265 $mockDataMapFactory->_callRef(
'setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition[
'rights']);
272 $leftColumnsDefinition = array(
275 'foreign_table' =>
'tx_myextension_righttable',
276 'foreign_table_where' =>
'WHERE 1=1',
277 'MM' =>
'tx_myextension_mm' 280 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
281 $mockColumnMap->expects($this->once())->method(
'setRelationTableName')->with($this->equalTo(
'tx_myextension_mm'));
282 $mockColumnMap->expects($this->once())->method(
'getRelationTableName')->will($this->returnValue(
'tx_myextension_mm'));
283 $mockColumnMap->expects($this->never())->method(
'setrelationTablePageIdColumnName');
284 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'getControlSection'), array(),
'', FALSE);
285 $mockDataMapFactory->expects($this->once())->method(
'getControlSection')->with($this->equalTo(
'tx_myextension_mm'))->will($this->returnValue(NULL));
286 $mockDataMapFactory->_callRef(
'setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition[
'rights']);
293 $leftColumnsDefinition = array(
296 'foreign_table' =>
'tx_myextension_righttable',
297 'foreign_table_where' =>
'WHERE 1=1',
298 'MM' =>
'tx_myextension_mm' 301 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
302 $mockColumnMap->expects($this->once())->method(
'setRelationTableName')->with($this->equalTo(
'tx_myextension_mm'));
303 $mockColumnMap->expects($this->once())->method(
'getRelationTableName')->will($this->returnValue(
'tx_myextension_mm'));
304 $mockColumnMap->expects($this->once())->method(
'setrelationTablePageIdColumnName')->with($this->equalTo(
'pid'));
305 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'getControlSection'), array(),
'', FALSE);
306 $mockDataMapFactory->expects($this->once())->method(
'getControlSection')->with($this->equalTo(
'tx_myextension_mm'))->will($this->returnValue(array(
'ctrl' => array(
'foo' =>
'bar'))));
307 $mockDataMapFactory->_callRef(
'setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition[
'rights']);
315 'date field' => array(
'date',
'date'),
316 'datetime field' => array(
'datetime',
'datetime'),
317 'no date/datetime field' => array(
'', NULL),
328 $columnDefinition = array(
334 $mockColumnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(
'setDateTimeStorageFormat'), array(),
'', FALSE);
336 if ($expectedValue !== NULL) {
337 $mockColumnMap->expects($this->once())->method(
'setDateTimeStorageFormat')->with($this->equalTo($type));
339 $mockColumnMap->expects($this->never())->method(
'setDateTimeStorageFormat');
342 $accessibleClassName = $this->
buildAccessibleProxy(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory');
343 $accessibleDataMapFactory =
new $accessibleClassName();
344 $accessibleDataMapFactory->_callRef(
'setFieldEvaluations', $mockColumnMap, $columnDefinition);
352 $mockDataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'getControlSection'), array(),
'', FALSE);
353 $cacheMock = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', array(
'get'), array(),
'', FALSE);
354 $cacheMock->expects($this->any())->method(
'get')->will($this->returnValue(FALSE));
355 $mockDataMapFactory->_set(
'dataMapCache', $cacheMock);
356 $mockDataMapFactory->buildDataMap(
'UnknownObject');
362 public function buildDataMapFetchesSubclassesRecursively() {
363 $this->markTestSkipped(
'Incomplete mocking in a complex scenario. This should be a functional test');
364 $configuration = array(
365 'persistence' => array(
367 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser' => array(
368 'subclasses' => array(
369 'Tx_SampleExt_Domain_Model_LevelOne1' =>
'Tx_SampleExt_Domain_Model_LevelOne1',
370 'Tx_SampleExt_Domain_Model_LevelOne2' =>
'Tx_SampleExt_Domain_Model_LevelOne2' 373 'Tx_SampleExt_Domain_Model_LevelOne1' => array(
374 'subclasses' => array(
375 'Tx_SampleExt_Domain_Model_LevelTwo1' =>
'Tx_SampleExt_Domain_Model_LevelTwo1',
376 'Tx_SampleExt_Domain_Model_LevelTwo2' =>
'Tx_SampleExt_Domain_Model_LevelTwo2' 379 'Tx_SampleExt_Domain_Model_LevelOne2' => array(
380 'subclasses' => array()
385 $expectedSubclasses = array(
386 'Tx_SampleExt_Domain_Model_LevelOne1',
387 'Tx_SampleExt_Domain_Model_LevelTwo1',
388 'Tx_SampleExt_Domain_Model_LevelTwo2',
389 'Tx_SampleExt_Domain_Model_LevelOne2' 393 $objectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array(
'dummy'), array(),
'', FALSE);
396 $configurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
397 $configurationManager->expects($this->once())->method(
'getConfiguration')->with(
'Framework')->will($this->returnValue($configuration));
399 $dataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'test'));
400 $dataMapFactory->_set(
'reflectionService',
new \
TYPO3\CMS\Extbase\Reflection\ReflectionService());
401 $dataMapFactory->_set(
'objectManager', $objectManager);
402 $dataMapFactory->_set(
'configurationManager', $configurationManager);
403 $cacheMock = $this->getMock(
'TYPO3\\CMS\\Core\\Cache\\Frontend\\VariableFrontend', array(), array(),
'', FALSE);
404 $cacheMock->expects($this->any())->method(
'get')->will($this->returnValue(FALSE));
405 $dataMapFactory->_set(
'dataMapCache', $cacheMock);
406 $dataMap = $dataMapFactory->buildDataMap(
'TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUser');
407 $this->assertSame($expectedSubclasses, $dataMap->getSubclasses());
415 'Core classes' => array(
'TYPO3\\CMS\\Belog\\Domain\\Model\\LogEntry',
'tx_belog_domain_model_logentry'),
416 'Core classes with namespaces and leading backslash' => array(
'\\TYPO3\\CMS\\Belog\\Domain\\Model\\LogEntry',
'tx_belog_domain_model_logentry'),
417 'Extension classes' => array(
'ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog',
'tx_blogexample_domain_model_blog'),
418 'Extension classes with namespaces and leading backslash' => array(
'\\ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog',
'tx_blogexample_domain_model_blog'),
419 'Extension classes without namespace' => array(
'Tx_News_Domain_Model_News',
'tx_news_domain_model_news'),
420 'Extension classes without namespace but leading slash' => array(
'\\Tx_News_Domain_Model_News',
'tx_news_domain_model_news'),
429 $dataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'));
430 $this->assertSame($expected, $dataMapFactory->_call(
'resolveTableName', $className));
436 public function createColumnMapReturnsAValidColumnMap() {
438 $dataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'));
441 $objectManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
442 $columnMap = $this->getMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(
'column',
'property'));
443 $objectManager->expects($this->once())->method(
'get')->will($this->returnValue($columnMap));
445 $dataMapFactory->_set(
'objectManager', $objectManager);
449 $dataMapFactory->_call(
'createColumnMap',
'column',
'property')
483 public function setTypeDetectsTypeAndInternalTypeProperly(array $columnConfiguration, $type, $internalType) {
485 $dataMapFactory = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapFactory', array(
'dummy'));
488 $columnMap = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap', array(
'dummy'), array(),
'', FALSE);
490 $dataMapFactory->_call(
'setType', $columnMap, $columnConfiguration);
492 $this->assertEquals($type, (
string) $columnMap->getType());
493 $this->assertEquals($internalType, (
string) $columnMap->getInternalType());
resolveTableNameReturnsExpectedTablenames($className, $expected)
classNameTableNameMappings()
const RELATION_HAS_AND_BELONGS_TO_MANY
tcaConfigurationsContainingTypeAndInternalType()
columnMapIsInitializedWithOppositeManyToManyRelationOfTypeSelect()
columnMapIsInitializedWithManyToManyRelationOfTypeInlineAndIntermediateTable()
columnMapIsInitializedWithFieldEvaluationsForDateTimeFieldsDataProvider()
setRelationsDetectsManyToManyRelationOfTypeInlineWithIntermediateTable()
setRelationsDetectsOneToManyRelation()
setRelationsDetectsManyToManyRelationOfTypeSelect()
columnMapIsInitializedWithFieldEvaluationsForDateTimeFields($type, $expectedValue)
setRelationsDetectsOneToOneRelation($className)
columnMapIsInitializedWithManyToManyRelationOfTypeSelect()
setRelationsDetectsOneToOneRelationWithIntermediateTable()
settingOneToOneRelationSetsRelationTableMatchFields()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
buildDataMapThrowsExceptionIfClassNameIsNotKnown()
settingOneToManyRelationSetsRelationTableMatchFields()
columnMapIsInitializedWithManyToManyRelationWithoutPidColumn()
columnMapIsInitializedWithManyToManyRelationWithPidColumn()
buildAccessibleProxy($className)