TASK: Keep language information for all TYPO3 Versions

Keep code consistent. Fetch language field for both TYPO3 versions.
To make sure we do not mess up, add test case.
This commit is contained in:
Daniel Siepmann 2018-03-15 13:59:47 +01:00
parent 403fd47df0
commit f3e8dacd4e
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 36 additions and 1 deletions

View file

@ -257,7 +257,6 @@ class TcaTableService76 implements TcaTableServiceInterface
$this->tca['ctrl']['cruser_id'],
$this->tca['ctrl']['fe_cruser_id'],
$this->tca['ctrl']['fe_crgroup_id'],
$this->tca['ctrl']['languageField'],
$this->tca['ctrl']['origUid'],
];

View file

@ -77,4 +77,40 @@ class TcaIndexerTest extends AbstractFunctionalTestCase
$objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments();
}
/**
* @test
*/
public function sysLanguageIsKept()
{
$this->importDataSet('Tests/Functional/Fixtures/Indexing/TcaIndexer/KeepSysLanguageUid.xml');
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class);
$tableName = 'tt_content';
$tableService = $objectManager->get(
TcaTableServiceInterface::class,
$tableName,
$objectManager->get(RelationResolver::class),
$objectManager->get(ConfigurationContainerInterface::class)
);
$connection = $this->getMockBuilder(Elasticsearch::class)
->setMethods(['addDocuments'])
->disableOriginalConstructor()
->getMock();
$connection->expects($this->once())
->method('addDocuments')
->with(
$this->stringContains('tt_content'),
$this->callback(function ($documents) {
if ($this->isLegacyVersion()) {
return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === '2';
} else {
return isset($documents[0]['sys_language_uid']) && $documents[0]['sys_language_uid'] === 2;
}
})
);
$objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments();
}
}