/**
  * @test
  */
 public function addDataCallsFlexFormSegmentGroupForDummyContainerAndAddsFlexParentDatabaseRow()
 {
     $input = ['tableName' => 'aTable', 'databaseRow' => ['aField' => ['data' => []], 'pointerField' => 'aFlex'], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'flex', 'ds_pointerField' => 'pointerField', 'ds' => ['sheets' => ['sDEF' => ['ROOT' => ['type' => 'array', 'el' => ['aFlexField' => ['label' => 'aFlexFieldLabel', 'config' => ['type' => 'input']]]]]]]]]]], 'pageTsConfig' => []];
     /** @var FlexFormSegment|ObjectProphecy $dummyGroupExisting */
     $dummyGroupExisting = $this->prophesize(FlexFormSegment::class);
     GeneralUtility::addInstance(FlexFormSegment::class, $dummyGroupExisting->reveal());
     // Check array given to flex group contains databaseRow as flexParentDatabaseRow and check compile is called
     $dummyGroupExisting->compile(Argument::that(function ($result) use($input) {
         if ($result['flexParentDatabaseRow'] === $input['databaseRow']) {
             return true;
         }
         return false;
     }))->shouldBeCalled()->willReturnArgument(0);
     $this->subject->addData($input);
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function addDataSetsValuesAndStructureForSectionContainerElements()
 {
     $input = ['tableName' => 'aTable', 'databaseRow' => ['aField' => ['data' => ['sDEF' => ['lDEF' => ['section_1' => ['el' => ['1' => ['container_1' => ['el' => []]], '2' => ['container_1' => ['el' => ['aFlexField' => ['vDEF' => 'dbValue']]]]]]], 'lEN' => ['section_1' => ['el' => ['1' => ['container_1' => []]]]]]], 'meta' => []]], 'processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'flex', 'ds' => ['sheets' => ['sDEF' => ['ROOT' => ['type' => 'array', 'el' => ['section_1' => ['section' => '1', 'type' => 'array', 'el' => ['container_1' => ['type' => 'array', 'el' => ['aFlexField' => ['label' => 'aFlexFieldLabel', 'config' => ['type' => 'input', 'default' => 'defaultValue']]]]]]]]]]]]]]], 'pageTsConfig' => []];
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['flexFormSegment'] = [\TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowDefaultValues::class => []];
     /** @var LanguageService|ObjectProphecy $languageService */
     $languageService = $this->prophesize(LanguageService::class);
     $GLOBALS['LANG'] = $languageService->reveal();
     $languageService->sL(Argument::cetera())->willReturnArgument(0);
     $this->backendUserProphecy->isAdmin()->willReturn(true);
     $this->backendUserProphecy->checkLanguageAccess(Argument::cetera())->willReturn(true);
     $expected = $input;
     // A default value for existing container field aFlexField should have been set
     $expected['databaseRow']['aField']['data']['sDEF']['lDEF']['section_1']['el']['1']['container_1']['el']['aFlexField']['vDEF'] = 'defaultValue';
     // Dummy row values for container_1 on lDEF sheet
     $expected['databaseRow']['aField']['data']['sDEF']['lDEF']['section_1']['templateRows']['container_1']['el']['aFlexField']['vDEF'] = 'defaultValue';
     $this->assertEquals($expected, $this->subject->addData($input));
 }