diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index a0a9182..c46b0e8 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -150,7 +150,14 @@ class TcaTableService try { foreach ($this->configuration->get('indexing.' . $this->tableName . '.dataProcessing') as $configuration) { - $dataProcessor = GeneralUtility::makeInstance($configuration['_typoScriptNodeValue']); + $className = ''; + if (is_string($configuration)) { + $className = $configuration; + $configuration = []; + } else { + $className = $configuration['_typoScriptNodeValue']; + } + $dataProcessor = GeneralUtility::makeInstance($className); if ($dataProcessor instanceof ProcessorInterface) { $record = $dataProcessor->processRecord($record, $configuration); } diff --git a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php index 3088db6..e12a4af 100644 --- a/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php +++ b/Tests/Unit/Domain/Index/TcaIndexer/TcaTableServiceTest.php @@ -104,7 +104,7 @@ class TcaTableServiceTest extends AbstractUnitTestCase /** * @test */ - public function executesConfiguredDataProcessing() + public function executesConfiguredDataProcessingWithConfiguration() { $this->configuration->expects($this->exactly(1)) ->method('get') @@ -141,4 +141,36 @@ class TcaTableServiceTest extends AbstractUnitTestCase 'Dataprocessing is not executed by TcaTableService as expected.' ); } + + /** + * @test + */ + public function executesConfiguredDataProcessingWithoutConfiguration() + { + $this->configuration->expects($this->exactly(1)) + ->method('get') + ->with('indexing.testTable.dataProcessing') + ->will($this->returnValue([CopyToProcessor::class])); + + $subject = $this->getMockBuilder(TcaTableService::class) + ->disableOriginalConstructor() + ->setMethodsExcept(['prepareRecord']) + ->getMock(); + $this->inject($subject, 'configuration', $this->configuration); + $this->inject($subject, 'tableName', 'testTable'); + $this->inject($subject, 'relationResolver', $this->getMockBuilder(RelationResolver::class)->getMock()); + + $record = ['field 1' => 'test']; + $expectedRecord = $record; + $expectedRecord[''] = 'test'; + $expectedRecord['search_title'] = 'test'; + + $subject->prepareRecord($record); + + $this->assertSame( + $expectedRecord, + $record, + 'Dataprocessing is not executed by TcaTableService as expected.' + ); + } }