‪TYPO3CMS  9.5
DataMapFactoryTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪DataMapFactoryTest extends UnitTestCase
28 {
32  public function ‪oneToOneRelation()
33  {
34  return [
35  ['Tx_Myext_Domain_Model_Foo'],
36  [\TYPO3\CMS\Extbase\Domain\Model\FrontendUser::class]
37  ];
38  }
39 
44  public function ‪setRelationsDetectsOneToOneRelation($className)
45  {
46  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
47  $columnConfiguration = [
48  'type' => 'select',
49  'foreign_table' => 'tx_myextension_bar',
50  'foreign_field' => 'parentid'
51  ];
52  $propertyMetaData = [
53  'type' => $className,
54  'elementType' => null
55  ];
56  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
57  $mockDataMapFactory->expects($this->once())->method('setOneToOneRelation')->will($this->returnValue($mockColumnMap));
58  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
59  $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
60  $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
61  }
62 
67  {
68  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
69  $matchFields = [
70  'fieldname' => 'foo_model'
71  ];
72  $columnConfiguration = [
73  'type' => 'select',
74  'foreign_table' => 'tx_myextension_bar',
75  'foreign_field' => 'parentid',
76  'foreign_match_fields' => $matchFields
77  ];
78 
79  $mockColumnMap->expects($this->once())
80  ->method('setRelationTableMatchFields')
81  ->with($matchFields);
82  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false);
83  $mockDataMapFactory->_call('setOneToOneRelation', $mockColumnMap, $columnConfiguration);
84  }
85 
90  {
91  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
92  $matchFields = [
93  'fieldname' => 'foo_model'
94  ];
95  $columnConfiguration = [
96  'type' => 'select',
97  'foreign_table' => 'tx_myextension_bar',
98  'foreign_field' => 'parentid',
99  'foreign_match_fields' => $matchFields
100  ];
101 
102  $mockColumnMap->expects($this->once())
103  ->method('setRelationTableMatchFields')
104  ->with($matchFields);
105  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false);
106  $mockDataMapFactory->_call('setOneToManyRelation', $mockColumnMap, $columnConfiguration);
107  }
108 
113  {
114  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
115  $columnConfiguration = [
116  'type' => 'select',
117  'foreign_table' => 'tx_myextension_bar',
118  'MM' => 'tx_myextension_mm'
119  ];
120  $propertyMetaData = [
121  'type' => 'Tx_Myext_Domain_Model_Foo',
122  'elementType' => null
123  ];
124  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
125  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
126  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
127  $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
128  $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
129  }
130 
135  {
136  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
137  $columnConfiguration = [
138  'type' => 'select',
139  'foreign_table' => 'tx_myextension_bar',
140  'foreign_field' => 'parentid',
141  'foreign_table_field' => 'parenttable'
142  ];
143  $propertyMetaData = [
144  'type' => \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class,
145  'elementType' => 'Tx_Myext_Domain_Model_Foo'
146  ];
147  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
148  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
149  $mockDataMapFactory->expects($this->once())->method('setOneToManyRelation')->will($this->returnValue($mockColumnMap));
150  $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
151  $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
152  }
153 
158  {
159  $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('foo', 'foo');
160  $columnConfiguration = [
161  'type' => 'select',
162  'renderType' => 'selectSingle',
163  'items' => [
164  ['One', 1],
165  ['Two', 2],
166  ['Three', 3],
167  ],
168  ];
169  $propertyMetaData = [];
170  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
171  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
172  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
173  $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
174  $actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $propertyMetaData);
175  $this->assertSame($columnMap::RELATION_NONE, $actualColumnMap->getTypeOfRelation());
176  }
177 
182  {
183  return [
184  'maxitems not set' => ['', 'RELATION_HAS_MANY'],
185  'maxitems equals 1' => ['1', 'RELATION_NONE'],
186  'maxitems higher than 1' => ['10', 'RELATION_HAS_MANY']
187  ];
188  }
189 
195  public function ‪setRelationsDetectsTypeGroupAndRelationManyToMany($maxitems, $relation)
196  {
197  $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('foo', 'foo');
198  if (empty($maxitems)) {
199  $columnConfiguration = [
200  'type' => 'group',
201  ];
202  } else {
203  $columnConfiguration = [
204  'type' => 'group',
205  'maxitems' => $maxitems
206  ];
207  }
208  $propertyMetaData = [];
209  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
210  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
211  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
212  $mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
213  $actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $propertyMetaData);
214  $this->assertSame($relation, $actualColumnMap->getTypeOfRelation());
215  }
216 
221  {
222  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
223  $columnConfiguration = [
224  'type' => 'select',
225  'foreign_table' => 'tx_myextension_bar',
226  'MM' => 'tx_myextension_mm'
227  ];
228  $propertyMetaData = [
229  'type' => \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class,
230  'elementType' => 'Tx_Myext_Domain_Model_Foo'
231  ];
232  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
233  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
234  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
235  $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
236  $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
237  }
238 
243  {
244  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
245  $columnConfiguration = [
246  'type' => 'inline',
247  'foreign_table' => 'tx_myextension_righttable',
248  'MM' => 'tx_myextension_mm'
249  ];
250  $propertyMetaData = [
251  'type' => \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class,
252  'elementType' => 'Tx_Myext_Domain_Model_Foo'
253  ];
254  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
255  $mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
256  $mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
257  $mockDataMapFactory->expects($this->once())->method('setManyToManyRelation')->will($this->returnValue($mockColumnMap));
258  $mockDataMapFactory->_callRef('setRelations', $mockColumnMap, $columnConfiguration, $propertyMetaData);
259  }
260 
265  {
266  $leftColumnsDefinition = [
267  'rights' => [
268  'type' => 'select',
269  'foreign_table' => 'tx_myextension_righttable',
270  'foreign_table_where' => 'WHERE 1=1',
271  'MM' => 'tx_myextension_mm',
272  'MM_table_where' => 'WHERE 2=2'
273  ]
274  ];
275  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
276  $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(‪ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
277  $mockColumnMap->expects($this->once())->method('setRelationTableName')->with($this->equalTo('tx_myextension_mm'));
278  $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_righttable'));
279  $mockColumnMap->expects($this->once())->method('setChildTableWhereStatement')->with($this->equalTo('WHERE 1=1'));
280  $mockColumnMap->expects($this->once())->method('setChildSortByFieldName')->with($this->equalTo('sorting'));
281  $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_local'));
282  $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
283  $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
284  $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
285  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false);
286  $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
287  }
288 
293  {
294  $rightColumnsDefinition = [
295  'lefts' => [
296  'type' => 'select',
297  'foreign_table' => 'tx_myextension_lefttable',
298  'MM' => 'tx_myextension_mm',
299  'MM_opposite_field' => 'rights'
300  ]
301  ];
302  $leftColumnsDefinition['rights']['MM_opposite_field'] = 'opposite_field';
303  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
304  $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(‪ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
305  $mockColumnMap->expects($this->once())->method('setRelationTableName')->with($this->equalTo('tx_myextension_mm'));
306  $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_lefttable'));
307  $mockColumnMap->expects($this->once())->method('setChildTableWhereStatement')->with(null);
308  $mockColumnMap->expects($this->once())->method('setChildSortByFieldName')->with($this->equalTo('sorting_foreign'));
309  $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_foreign'));
310  $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
311  $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
312  $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
313  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy'], [], '', false);
314  $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $rightColumnsDefinition['lefts']);
315  }
316 
321  {
322  $leftColumnsDefinition = [
323  'rights' => [
324  'type' => 'inline',
325  'foreign_table' => 'tx_myextension_righttable',
326  'MM' => 'tx_myextension_mm',
327  'foreign_sortby' => 'sorting'
328  ]
329  ];
330  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
331  $mockColumnMap->expects($this->once())->method('setTypeOfRelation')->with($this->equalTo(‪ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY));
332  $mockColumnMap->expects($this->once())->method('setRelationTableName')->with($this->equalTo('tx_myextension_mm'));
333  $mockColumnMap->expects($this->once())->method('setChildTableName')->with($this->equalTo('tx_myextension_righttable'));
334  $mockColumnMap->expects($this->once())->method('setChildTableWhereStatement');
335  $mockColumnMap->expects($this->once())->method('setChildSortByFieldName')->with($this->equalTo('sorting'));
336  $mockColumnMap->expects($this->once())->method('setParentKeyFieldName')->with($this->equalTo('uid_local'));
337  $mockColumnMap->expects($this->never())->method('setParentTableFieldName');
338  $mockColumnMap->expects($this->never())->method('setRelationTableMatchFields');
339  $mockColumnMap->expects($this->never())->method('setRelationTableInsertFields');
340  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getColumnsDefinition'], [], '', false);
341  $mockDataMapFactory->expects($this->never())->method('getColumnsDefinition');
342  $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
343  }
344 
349  {
350  $leftColumnsDefinition = [
351  'rights' => [
352  'type' => 'select',
353  'foreign_table' => 'tx_myextension_righttable',
354  'foreign_table_where' => 'WHERE 1=1',
355  'MM' => 'tx_myextension_mm'
356  ]
357  ];
358  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
359  $mockColumnMap->expects($this->once())->method('setRelationTableName')->with($this->equalTo('tx_myextension_mm'));
360  $mockColumnMap->expects($this->once())->method('getRelationTableName')->will($this->returnValue('tx_myextension_mm'));
361  $mockColumnMap->expects($this->never())->method('setrelationTablePageIdColumnName');
362  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getControlSection'], [], '', false);
363  $mockDataMapFactory->expects($this->once())->method('getControlSection')->with($this->equalTo('tx_myextension_mm'))->will($this->returnValue(null));
364  $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
365  }
366 
371  {
372  $leftColumnsDefinition = [
373  'rights' => [
374  'type' => 'select',
375  'foreign_table' => 'tx_myextension_righttable',
376  'foreign_table_where' => 'WHERE 1=1',
377  'MM' => 'tx_myextension_mm'
378  ]
379  ];
380  $mockColumnMap = $this->createMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class);
381  $mockColumnMap->expects($this->once())->method('setRelationTableName')->with($this->equalTo('tx_myextension_mm'));
382  $mockColumnMap->expects($this->once())->method('getRelationTableName')->will($this->returnValue('tx_myextension_mm'));
383  $mockColumnMap->expects($this->once())->method('setrelationTablePageIdColumnName')->with($this->equalTo('pid'));
384  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getControlSection'], [], '', false);
385  $mockDataMapFactory->expects($this->once())->method('getControlSection')->with($this->equalTo('tx_myextension_mm'))->will($this->returnValue(['ctrl' => ['foo' => 'bar']]));
386  $mockDataMapFactory->_callRef('setManyToManyRelation', $mockColumnMap, $leftColumnsDefinition['rights']);
387  }
388 
393  {
394  return [
395  'date field' => ['date', 'date'],
396  'datetime field' => ['datetime', 'datetime'],
397  'time field' => ['time', 'time'],
398  'no date/datetime/time field' => ['', null],
399  ];
400  }
401 
409  {
410  $columnDefinition = [
411  'type' => 'input',
412  'dbType' => $type,
413  'eval' => $type,
414  ];
415 
416  $mockColumnMap = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class)
417  ->setMethods(['setDateTimeStorageFormat'])
418  ->disableOriginalConstructor()
419  ->getMock();
420 
421  if ($expectedValue !== null) {
422  $mockColumnMap->expects($this->once())->method('setDateTimeStorageFormat')->with($this->equalTo($type));
423  } else {
424  $mockColumnMap->expects($this->never())->method('setDateTimeStorageFormat');
425  }
426 
427  $accessibleClassName = $this->buildAccessibleProxy(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class);
428  $accessibleDataMapFactory = new $accessibleClassName();
429  $accessibleDataMapFactory->_callRef('setFieldEvaluations', $mockColumnMap, $columnDefinition);
430  }
431 
436  {
437  $this->expectException(InvalidClassException::class);
438  // @TODO expectExceptionCode is 0
439  $mockDataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['getControlSection'], [], '', false);
440  $cacheMock = $this->getMockBuilder(\‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class)
441  ->setMethods(['get'])
442  ->disableOriginalConstructor()
443  ->getMock();
444  $cacheMock->expects($this->any())->method('get')->will($this->returnValue(false));
445  $mockDataMapFactory->_set('dataMapCache', $cacheMock);
446  $mockDataMapFactory->buildDataMap('UnknownObject');
447  }
448 
453  {
454  $this->markTestSkipped('Incomplete mocking in a complex scenario. This should be a functional test');
455  $configuration = [
456  'persistence' => [
457  'classes' => [
458  \TYPO3\CMS\Extbase\Domain\Model\FrontendUser::class => [
459  'subclasses' => [
460  'Tx_SampleExt_Domain_Model_LevelOne1' => 'Tx_SampleExt_Domain_Model_LevelOne1',
461  'Tx_SampleExt_Domain_Model_LevelOne2' => 'Tx_SampleExt_Domain_Model_LevelOne2'
462  ]
463  ],
464  'Tx_SampleExt_Domain_Model_LevelOne1' => [
465  'subclasses' => [
466  'Tx_SampleExt_Domain_Model_LevelTwo1' => 'Tx_SampleExt_Domain_Model_LevelTwo1',
467  'Tx_SampleExt_Domain_Model_LevelTwo2' => 'Tx_SampleExt_Domain_Model_LevelTwo2'
468  ]
469  ],
470  'Tx_SampleExt_Domain_Model_LevelOne2' => [
471  'subclasses' => []
472  ]
473  ]
474  ]
475  ];
476  $expectedSubclasses = [
477  'Tx_SampleExt_Domain_Model_LevelOne1',
478  'Tx_SampleExt_Domain_Model_LevelTwo1',
479  'Tx_SampleExt_Domain_Model_LevelTwo2',
480  'Tx_SampleExt_Domain_Model_LevelOne2'
481  ];
482 
484  $objectManager = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Object\ObjectManager::class)
485  ->setMethods(['dummy'])
486  ->disableOriginalConstructor()
487  ->getMock();
488 
490  $configurationManager = $this->createMock(\‪TYPO3\CMS\‪Extbase\Configuration\ConfigurationManager::class);
491  $configurationManager->expects($this->once())->method('getConfiguration')->with('Framework')->will($this->returnValue($configuration));
493  $dataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['test']);
494  $dataMapFactory->_set('reflectionService', new \‪TYPO3\CMS\‪Extbase\Reflection\ReflectionService());
495  $dataMapFactory->_set('objectManager', $objectManager);
496  $dataMapFactory->_set('configurationManager', $configurationManager);
497  $cacheMock = $this->createMock(\‪TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class);
498  $cacheMock->expects($this->any())->method('get')->will($this->returnValue(false));
499  $dataMapFactory->_set('dataMapCache', $cacheMock);
500  $dataMap = $dataMapFactory->buildDataMap(\‪TYPO3\CMS\‪Extbase\Domain\Model\FrontendUser::class);
501  $this->assertSame($expectedSubclasses, $dataMap->getSubclasses());
502  }
503 
508  {
509  return [
510  'Core classes' => [\TYPO3\CMS\Belog\Domain\Model\LogEntry::class, 'tx_belog_domain_model_logentry'],
511  'Core classes with namespaces and leading backslash' => [\TYPO3\CMS\Belog\Domain\Model\LogEntry::class, 'tx_belog_domain_model_logentry'],
512  'Extension classes' => ['ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog', 'tx_blogexample_domain_model_blog'],
513  'Extension classes with namespaces and leading backslash' => ['\\ExtbaseTeam\\BlogExample\\Domain\\Model\\Blog', 'tx_blogexample_domain_model_blog'],
514  ];
515  }
516 
521  public function ‪resolveTableNameReturnsExpectedTablenames($className, $expected)
522  {
523  $dataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy']);
524  $this->assertSame($expected, $dataMapFactory->_call('resolveTableName', $className));
525  }
526 
531  {
533  $dataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy']);
534 
536  $objectManager = $this->createMock(\‪TYPO3\CMS\‪Extbase\Object\ObjectManager::class);
537  $columnMap = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class)
538  ->setConstructorArgs(['column', 'property'])
539  ->getMock();
540  $objectManager->expects($this->once())->method('get')->will($this->returnValue($columnMap));
541 
542  $dataMapFactory->_set('objectManager', $objectManager);
543 
544  $this->assertEquals(
545  $columnMap,
546  $dataMapFactory->_call('createColumnMap', 'column', 'property')
547  );
548  }
549 
554  {
555  return [
556  [['type' => 'input'], ‪TableColumnType::INPUT, null],
557  [['type' => 'text'], ‪TableColumnType::TEXT, null],
558  [['type' => 'check'], ‪TableColumnType::CHECK, null],
559  [['type' => 'radio'], ‪TableColumnType::RADIO, null],
560  [['type' => 'select'], ‪TableColumnType::SELECT, null],
561  [['type' => 'group', 'internal_type' => 'db'], ‪TableColumnType::GROUP, ‪TableColumnSubType::DB],
562  [['type' => 'group', 'internal_type' => 'file'], ‪TableColumnType::GROUP, ‪TableColumnSubType::FILE],
563  [['type' => 'group', 'internal_type' => 'file_reference'], ‪TableColumnType::GROUP, ‪TableColumnSubType::FILE_REFERENCE],
564  [['type' => 'group', 'internal_type' => 'folder'], ‪TableColumnType::GROUP, ‪TableColumnSubType::FOLDER],
565  [['type' => 'none'], ‪TableColumnType::NONE, null],
566  [['type' => 'passthrough'], ‪TableColumnType::PASSTHROUGH, null],
567  [['type' => 'user'], ‪TableColumnType::USER, null],
568  [['type' => 'flex'], ‪TableColumnType::FLEX, null],
569  [['type' => 'inline'], ‪TableColumnType::INLINE, null],
570  [['type' => 'slug'], ‪TableColumnType::SLUG, null],
571  ];
572  }
573 
582  public function ‪setTypeDetectsTypeAndInternalTypeProperly(array $columnConfiguration, $type, $internalType)
583  {
585  $dataMapFactory = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['dummy']);
586 
588  $columnMap = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Persistence\Generic\Mapper\ColumnMap::class, ['dummy'], [], '', false);
589 
590  $dataMapFactory->_call('setType', $columnMap, $columnConfiguration);
591 
592  $this->assertEquals($type, (string)$columnMap->getType());
593  $this->assertEquals($internalType, (string)$columnMap->getInternalType());
594  }
595 }
‪TYPO3\CMS\Core\DataHandling\TableColumnType\SELECT
‪const SELECT
Definition: TableColumnType.php:33
‪TYPO3\CMS\Core\DataHandling\TableColumnSubType\DB
‪const DB
Definition: TableColumnSubType.php:31
‪TYPO3\CMS\Core\DataHandling\TableColumnType\INLINE
‪const INLINE
Definition: TableColumnType.php:39
‪TYPO3\CMS\Core\DataHandling\TableColumnType\GROUP
‪const GROUP
Definition: TableColumnType.php:34
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\classNameTableNameMappings
‪array classNameTableNameMappings()
Definition: DataMapFactoryTest.php:507
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\settingOneToOneRelationSetsRelationTableMatchFields
‪settingOneToOneRelationSetsRelationTableMatchFields()
Definition: DataMapFactoryTest.php:66
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setTypeDetectsTypeAndInternalTypeProperly
‪setTypeDetectsTypeAndInternalTypeProperly(array $columnConfiguration, $type, $internalType)
Definition: DataMapFactoryTest.php:582
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest
Definition: DataMapFactoryTest.php:28
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithFieldEvaluationsForDateTimeFieldsDataProvider
‪array columnMapIsInitializedWithFieldEvaluationsForDateTimeFieldsDataProvider()
Definition: DataMapFactoryTest.php:392
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\createColumnMapReturnsAValidColumnMap
‪createColumnMapReturnsAValidColumnMap()
Definition: DataMapFactoryTest.php:530
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithOppositeManyToManyRelationOfTypeSelect
‪columnMapIsInitializedWithOppositeManyToManyRelationOfTypeSelect()
Definition: DataMapFactoryTest.php:292
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithFieldEvaluationsForDateTimeFields
‪columnMapIsInitializedWithFieldEvaluationsForDateTimeFields($type, $expectedValue)
Definition: DataMapFactoryTest.php:408
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithManyToManyRelationOfTypeSelect
‪columnMapIsInitializedWithManyToManyRelationOfTypeSelect()
Definition: DataMapFactoryTest.php:264
‪TYPO3
‪TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap
Definition: ColumnMap.php:22
‪TYPO3\CMS\Core\DataHandling\TableColumnType\USER
‪const USER
Definition: TableColumnType.php:37
‪TYPO3\CMS\Core\DataHandling\TableColumnType\PASSTHROUGH
‪const PASSTHROUGH
Definition: TableColumnType.php:36
‪TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap\RELATION_HAS_AND_BELONGS_TO_MANY
‪const RELATION_HAS_AND_BELONGS_TO_MANY
Definition: ColumnMap.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\buildDataMapFetchesSubclassesRecursively
‪buildDataMapFetchesSubclassesRecursively()
Definition: DataMapFactoryTest.php:452
‪TYPO3\CMS\Core\DataHandling\TableColumnType\RADIO
‪const RADIO
Definition: TableColumnType.php:32
‪TYPO3\CMS\Core\DataHandling\TableColumnSubType\FILE_REFERENCE
‪const FILE_REFERENCE
Definition: TableColumnSubType.php:41
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper
Definition: DataMapFactoryTest.php:2
‪TYPO3\CMS\Core\DataHandling\TableColumnType\TEXT
‪const TEXT
Definition: TableColumnType.php:30
‪TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidClassException
Definition: InvalidClassException.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsSelectRenderTypeSingleAsNonRelational
‪setRelationsDetectsSelectRenderTypeSingleAsNonRelational()
Definition: DataMapFactoryTest.php:157
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsTypeGroupAndRelationManyToMany
‪setRelationsDetectsTypeGroupAndRelationManyToMany($maxitems, $relation)
Definition: DataMapFactoryTest.php:195
‪TYPO3\CMS\Core\DataHandling\TableColumnType\SLUG
‪const SLUG
Definition: TableColumnType.php:41
‪TYPO3\CMS\Core\DataHandling\TableColumnType\CHECK
‪const CHECK
Definition: TableColumnType.php:31
‪TYPO3\CMS\Core\DataHandling\TableColumnSubType\FOLDER
‪const FOLDER
Definition: TableColumnSubType.php:42
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsOneToOneRelationWithIntermediateTable
‪setRelationsDetectsOneToOneRelationWithIntermediateTable()
Definition: DataMapFactoryTest.php:112
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\tcaConfigurationsContainingTypeAndInternalType
‪array tcaConfigurationsContainingTypeAndInternalType()
Definition: DataMapFactoryTest.php:553
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\resolveTableNameReturnsExpectedTablenames
‪resolveTableNameReturnsExpectedTablenames($className, $expected)
Definition: DataMapFactoryTest.php:521
‪TYPO3\CMS\Core\DataHandling\TableColumnSubType\FILE
‪const FILE
Definition: TableColumnSubType.php:36
‪TYPO3\CMS\Core\DataHandling\TableColumnType\NONE
‪const NONE
Definition: TableColumnType.php:35
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\buildDataMapThrowsExceptionIfClassNameIsNotKnown
‪buildDataMapThrowsExceptionIfClassNameIsNotKnown()
Definition: DataMapFactoryTest.php:435
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithManyToManyRelationWithPidColumn
‪columnMapIsInitializedWithManyToManyRelationWithPidColumn()
Definition: DataMapFactoryTest.php:370
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsManyToManyRelationOfTypeInlineWithIntermediateTable
‪setRelationsDetectsManyToManyRelationOfTypeInlineWithIntermediateTable()
Definition: DataMapFactoryTest.php:242
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsOneToManyRelation
‪setRelationsDetectsOneToManyRelation()
Definition: DataMapFactoryTest.php:134
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsManyToManyRelationOfTypeSelect
‪setRelationsDetectsManyToManyRelationOfTypeSelect()
Definition: DataMapFactoryTest.php:220
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithManyToManyRelationWithoutPidColumn
‪columnMapIsInitializedWithManyToManyRelationWithoutPidColumn()
Definition: DataMapFactoryTest.php:348
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\settingOneToManyRelationSetsRelationTableMatchFields
‪settingOneToManyRelationSetsRelationTableMatchFields()
Definition: DataMapFactoryTest.php:89
‪TYPO3\CMS\Core\DataHandling\TableColumnSubType
Definition: TableColumnSubType.php:23
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\oneToOneRelation
‪array oneToOneRelation()
Definition: DataMapFactoryTest.php:32
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnConfigurationIsInitializedWithMaxItemsEvaluationForTypeGroupDataProvider
‪array columnConfigurationIsInitializedWithMaxItemsEvaluationForTypeGroupDataProvider()
Definition: DataMapFactoryTest.php:181
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\columnMapIsInitializedWithManyToManyRelationOfTypeInlineAndIntermediateTable
‪columnMapIsInitializedWithManyToManyRelationOfTypeInlineAndIntermediateTable()
Definition: DataMapFactoryTest.php:320
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\DataMapFactoryTest\setRelationsDetectsOneToOneRelation
‪setRelationsDetectsOneToOneRelation($className)
Definition: DataMapFactoryTest.php:44
‪TYPO3\CMS\Core\DataHandling\TableColumnType\INPUT
‪const INPUT
Definition: TableColumnType.php:29
‪TYPO3\CMS\Core\DataHandling\TableColumnType
Definition: TableColumnType.php:23
‪TYPO3\CMS\Core\DataHandling\TableColumnType\FLEX
‪const FLEX
Definition: TableColumnType.php:38