mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 10:36:12 +01:00
BUGFIX: Also handle data processor without configuration
This commit is contained in:
parent
efeb5d1e07
commit
6c01abe5a5
2 changed files with 41 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue