mirror of
https://github.com/Codappix/search_core.git
synced 2024-12-25 01:56:09 +01:00
BUGFIX: Do not resolve inputDateTime as relation
Add test which checks this behaviour. Exclude inputDateTime from relation resolving. Resolves #147
This commit is contained in:
parent
4234575c36
commit
c1d1e6ed68
2 changed files with 84 additions and 1 deletions
|
@ -82,7 +82,7 @@ class RelationResolver implements Singleton
|
|||
protected function isRelation(array &$config) : bool
|
||||
{
|
||||
return isset($config['foreign_table'])
|
||||
|| (isset($config['renderType']) && $config['renderType'] !== 'selectSingle')
|
||||
|| (isset($config['renderType']) && !in_array($config['renderType'], ['selectSingle', 'inputDateTime']))
|
||||
|| (isset($config['internal_type']) && strtolower($config['internal_type']) === 'db')
|
||||
;
|
||||
}
|
||||
|
|
83
Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php
Normal file
83
Tests/Unit/Domain/Index/TcaIndexer/RelationResolverTest.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
namespace Codappix\SearchCore\Tests\Unit\Domain\Index\TcaIndexer;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\RelationResolver;
|
||||
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface;
|
||||
use Codappix\SearchCore\Tests\Unit\AbstractUnitTestCase;
|
||||
|
||||
class RelationResolverTest extends AbstractUnitTestCase
|
||||
{
|
||||
/**
|
||||
* @var RelationResolver
|
||||
*/
|
||||
protected $subject;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->subject = new RelationResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function renderTypeInputDateTimeIsHandled()
|
||||
{
|
||||
$originalRecord = [
|
||||
'starttime' => 0,
|
||||
];
|
||||
$record = $originalRecord;
|
||||
$GLOBALS['TCA'] = [
|
||||
'tt_content' => [
|
||||
'columns' => [
|
||||
'starttime' => [
|
||||
'config' => [
|
||||
'default' => 0,
|
||||
'eval' => 'datetime',
|
||||
'renderType' => 'inputDateTime',
|
||||
],
|
||||
'type' => 'input',
|
||||
'exclude' => 1,
|
||||
'l10n_display' => 'defaultAsReadonly',
|
||||
'l10n_mode' => 'exclude',
|
||||
'label' => 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.starttime',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$tableServiceMock = $this->getMockBuilder(TcaTableServiceInterface::class)->getMock();
|
||||
$tableServiceMock->expects($this->any())
|
||||
->method('getTableName')
|
||||
->willReturn('tt_content');
|
||||
$tableServiceMock->expects($this->any())
|
||||
->method('getColumnConfig')
|
||||
->willReturn($GLOBALS['TCA']['tt_content']['columns']['starttime']['config']);
|
||||
|
||||
$this->subject->resolveRelationsForRecord($tableServiceMock, $record);
|
||||
|
||||
$this->assertSame(
|
||||
$originalRecord,
|
||||
$record,
|
||||
'TCA column configured with renderType inputDateTime was not kept as unix timestamp.'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue