Commit d34522e5 authored by Łukasz Uznański's avatar Łukasz Uznański Committed by Christian Kuhn
Browse files

[BUGFIX] Fix using contains in query on property of group

Related: master, 8.7
Resolves: #80215
Change-Id: I6f5c88650d6167550a46ad2200c846ec9d11d34a
Reviewed-on: https://review.typo3.org/53993

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Kummer's avatarJoerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer's avatarJoerg Kummer <typo3@enobe.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 5768427f
......@@ -339,6 +339,11 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface
)
) {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
} elseif (
isset($columnConfiguration['type']) && $columnConfiguration['type'] === 'group'
&& (!isset($columnConfiguration['maxitems']) || $columnConfiguration['maxitems'] > 1)
) {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_MANY);
} else {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_NONE);
}
......
......@@ -66,8 +66,8 @@ class DataMapFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
$mockColumnMap = $this->createMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::class);
$matchFields = [
'fieldname' => 'foo_model'
];
'fieldname' => 'foo_model'
];
$columnConfiguration = [
'type' => 'select',
'foreign_table' => 'tx_myextension_bar',
......@@ -89,8 +89,8 @@ class DataMapFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
$mockColumnMap = $this->createMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::class);
$matchFields = [
'fieldname' => 'foo_model'
];
'fieldname' => 'foo_model'
];
$columnConfiguration = [
'type' => 'select',
'foreign_table' => 'tx_myextension_bar',
......@@ -174,6 +174,45 @@ class DataMapFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
$this->assertSame($columnMap::RELATION_NONE, $actualColumnMap->getTypeOfRelation());
}
/**
* @return array
*/
public function columnConfigurationIsInitializedWithMaxItemsEvaluationForTypeGroupDataProvider()
{
return [
'maxitems not set' => ['', 'RELATION_HAS_MANY'],
'maxitems equals 1' => ['1', 'RELATION_NONE'],
'maxitems higher than 1' => ['10', 'RELATION_HAS_MANY']
];
}
/**
* @test
*
* @dataProvider columnConfigurationIsInitializedWithMaxItemsEvaluationForTypeGroupDataProvider
*/
public function setRelationsDetectsTypeGroupAndRelationManyToMany($maxitems, $relation)
{
$columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('foo', 'foo');
if (empty($maxitems)) {
$columnConfiguration = [
'type' => 'group',
];
} else {
$columnConfiguration = [
'type' => 'group',
'maxitems' => $maxitems
];
}
$propertyMetaData = [];
$mockDataMapFactory = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory::class, ['setOneToOneRelation', 'setOneToManyRelation', 'setManyToManyRelation'], [], '', false);
$mockDataMapFactory->expects($this->never())->method('setOneToOneRelation');
$mockDataMapFactory->expects($this->never())->method('setOneToManyRelation');
$mockDataMapFactory->expects($this->never())->method('setManyToManyRelation');
$actualColumnMap = $mockDataMapFactory->_callRef('setRelations', $columnMap, $columnConfiguration, $propertyMetaData);
$this->assertSame($relation, $actualColumnMap->getTypeOfRelation());
}
/**
* @test
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment