Skip to content
Snippets Groups Projects
Commit 9c8a45ae authored by Mathias Brodala's avatar Mathias Brodala Committed by Susanne Moog
Browse files

[BUGFIX] EXT:form - fix error on single database insert

Resolves: #81805
Releases: master, 8.7
Change-Id: I8ee3582170db9812d7be2b9710cb4d46335ec86a
Reviewed-on: https://review.typo3.org/53969


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarCarlos Meyer <cm@davitec.de>
Tested-by: default avatarCarlos Meyer <cm@davitec.de>
Reviewed-by: default avatarDaniel Lorenz <daniel.lorenz@extco.de>
Reviewed-by: default avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: default avatarSusanne Moog <susanne.moog@typo3.org>
parent 8116c134
Branches
Tags
No related merge requests found
......@@ -196,7 +196,7 @@ class SaveToDatabaseFinisher extends AbstractFinisher
*/
protected function executeInternal()
{
if (!is_array($this->options)) {
if (isset($this->options['table'])) {
$options[] = $this->options;
} else {
$options = $this->options;
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Form\Tests\Unit\Domain\Finishers;
*/
use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException;
use TYPO3\CMS\Form\Domain\Finishers\FinisherContext;
use TYPO3\CMS\Form\Domain\Finishers\SaveToDatabaseFinisher;
use TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface;
......@@ -27,7 +28,7 @@ class SaveToDatabaseFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitT
/**
* @test
*/
public function throwExceptionOnInconsistentConfigurationThrowExceptionOnInconsistentConfiguration()
public function throwExceptionOnInconsistentConfigurationThrowsExceptionOnInconsistentConfiguration()
{
$this->expectException(FinisherException::class);
$this->expectExceptionCode(1480469086);
......@@ -67,4 +68,52 @@ class SaveToDatabaseFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitT
self::assertSame('one,two', $databaseData['bar']);
}
/**
* @test
*/
public function executeInternalProcessesSingleTable()
{
$saveToDatabaseFinisher = $this->getMockBuilder(SaveToDatabaseFinisher::class)
->setMethods(['process'])
->getMock();
$this->inject($saveToDatabaseFinisher, 'options', [
'table' => 'tx_foo',
'databaseColumnMappings' => [
'foo' => 1,
],
]);
$saveToDatabaseFinisher->expects($this->once())->method('process')->with(0);
$saveToDatabaseFinisher->execute($this->prophesize(FinisherContext::class)->reveal());
}
/**
* @test
*/
public function executeInternalProcessesMultipleTables()
{
$saveToDatabaseFinisher = $this->getMockBuilder(SaveToDatabaseFinisher::class)
->setMethods(['process'])
->getMock();
$this->inject($saveToDatabaseFinisher, 'options', [
[
'table' => 'tx_foo',
'databaseColumnMappings' => [
'foo' => 1,
],
],
[
'table' => 'tx_bar',
'databaseColumnMappings' => [
'bar' => 1,
],
],
]);
$saveToDatabaseFinisher->expects($this->exactly(2))->method('process')->withConsecutive([0], [1]);
$saveToDatabaseFinisher->execute($this->prophesize(FinisherContext::class)->reveal());
}
}
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