create() public static method

public static create ( array $settings = [] ) : FormInterface
$settings array
return FormInterface
Esempio n. 1
0
 /**
  * @test
  */
 public function canSetDefaultValueFromCsvfAlreadyCorrectStrings()
 {
     $instance = Form::create(array())->createField('File', 'file');
     $defaultValue = 'testfile1.jpg|testfile1.jpg,testfile2.jpg|testfile2.jpg';
     $instance->setDefault($defaultValue);
     $this->assertSame($defaultValue, $instance->getDefault());
 }
Esempio n. 2
0
 /**
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  * @return void
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     $viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
     $templateVariableContainer = $renderingContext->getTemplateVariableContainer();
     $extensionName = static::getExtensionNameFromRenderingContextOrArguments($renderingContext, $arguments);
     $form = Form::create();
     $container = $form->last();
     // configure Form instance
     $form->setId($arguments['id']);
     $form->setName($arguments['id']);
     $form->setLabel($arguments['label']);
     $form->setDescription($arguments['description']);
     $form->setEnabled($arguments['enabled']);
     $form->setCompact($arguments['compact']);
     $form->setExtensionName($extensionName);
     $form->setLocalLanguageFileRelativePath($arguments['localLanguageFileRelativePath']);
     $form->setVariables((array) $arguments['variables']);
     $form->setOptions((array) $arguments['options']);
     if (FALSE === $form->hasOption(Form::OPTION_ICON)) {
         $form->setOption(Form::OPTION_ICON, $arguments['icon']);
     }
     if (FALSE === $form->hasOption(Form::OPTION_GROUP)) {
         $form->setOption(Form::OPTION_GROUP, $arguments['wizardTab']);
     }
     // rendering child nodes with Form's last sheet as active container
     $viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_FORM, $form);
     $viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME, $extensionName);
     $templateVariableContainer->add(static::SCOPE_VARIABLE_FORM, $form);
     static::setContainerInRenderingContext($renderingContext, $container);
     $renderChildrenClosure();
     $viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME);
     $viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_CONTAINER);
     $templateVariableContainer->remove(static::SCOPE_VARIABLE_CONTAINER);
 }
Esempio n. 3
0
 /**
  * Render method
  * @return void
  */
 public function render()
 {
     $extensionName = $this->getExtensionName();
     $form = Form::create();
     $container = $form->last();
     // configure Form instance
     $form->setId($this->arguments['id']);
     $form->setName($this->arguments['id']);
     $form->setLabel($this->arguments['label']);
     $form->setDescription($this->arguments['description']);
     $form->setEnabled($this->arguments['enabled']);
     $form->setCompact($this->arguments['compact']);
     $form->setExtensionName($extensionName);
     $form->setLocalLanguageFileRelativePath($this->arguments['localLanguageFileRelativePath']);
     $form->setVariables((array) $this->arguments['variables']);
     $form->setOptions((array) $this->arguments['options']);
     if (FALSE === $form->hasOption(Form::OPTION_ICON)) {
         $form->setOption(Form::OPTION_ICON, $this->arguments['icon']);
     }
     if (FALSE === $form->hasOption(Form::OPTION_GROUP)) {
         $form->setOption(Form::OPTION_GROUP, $this->arguments['wizardTab']);
     }
     // rendering child nodes with Form's last sheet as active container
     $this->viewHelperVariableContainer->addOrUpdate(self::SCOPE, self::SCOPE_VARIABLE_FORM, $form);
     $this->viewHelperVariableContainer->addOrUpdate(self::SCOPE, self::SCOPE_VARIABLE_EXTENSIONNAME, $extensionName);
     $this->templateVariableContainer->add(self::SCOPE_VARIABLE_FORM, $form);
     $this->setContainer($container);
     $this->renderChildren();
     $this->viewHelperVariableContainer->remove(self::SCOPE, self::SCOPE_VARIABLE_EXTENSIONNAME);
     $this->viewHelperVariableContainer->remove(self::SCOPE, self::SCOPE_VARIABLE_CONTAINER);
     $this->templateVariableContainer->remove(self::SCOPE_VARIABLE_CONTAINER);
 }
 /**
  * @return array
  */
 public function getPostProcessBackendLayoutTestValues()
 {
     $form = Form::create(array('id' => 'formId'));
     /** @var Provider|\PHPUnit_Framework_MockObject_MockObject $standardProvider */
     $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord', 'getForm'));
     $standardProvider->setTemplatePaths(array());
     $standardProvider->expects($this->any())->method('getForm')->willReturn($form);
     $actionLessProvider = clone $standardProvider;
     $exceptionProvider = clone $standardProvider;
     $emptyGridProvider = clone $standardProvider;
     $gridProvider = clone $standardProvider;
     $actionLessProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn(null);
     $exceptionProvider->expects($this->any())->method('getControllerActionFromRecord')->willThrowException(new \RuntimeException());
     /** @var Grid $grid */
     $grid = Grid::create();
     $grid->setParent($form);
     $emptyGridProvider->setGrid($grid);
     $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     /** @var Grid $grid */
     $grid = Grid::create(array());
     $grid->setParent($form);
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColSpan(3)->setRowSpan(3)->setColumnPosition(2);
     $gridProvider->setGrid($grid);
     $gridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
     $gridArray = array('__config' => array('backend_layout.' => array('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3)))))), '__colPosList' => array(2), '__items' => array(array('LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 2, null)));
     return array(array($standardProvider, null, 'message', 0, array()), array($standardProvider, array(), 'message', 1, array()), array($actionLessProvider, array(), 'message', 1, array()), array($emptyGridProvider, array(), 'message', 1, array()), array($exceptionProvider, array(), 'debug', 1, array()), array($gridProvider, array(), 'message', 0, $gridArray));
 }
 /**
  * @test
  * @dataProvider getValuesAndTransformations
  * @param mixed $value
  * @param string $transformation
  * @param mixed $expected
  */
 public function testTransformation($value, $transformation, $expected)
 {
     $instance = $this->createInstance();
     $form = Form::create();
     $form->createField('Input', 'field')->setTransform($transformation);
     $transformed = $instance->transformAccordingToConfiguration(array('field' => $value), $form);
     $this->assertTrue($transformed !== $expected, 'Transformation type ' . $transformation . ' failed; values are still identical');
 }
 /**
  * @dataProvider getFormTestValues
  * @param array $record
  */
 public function testGetForm(array $record)
 {
     $instance = $this->getMock('FluidTYPO3\\FluidcontentCore\\Provider\\CoreContentProvider', array('resolveFormClassName', 'setDefaultValuesInFieldsWithInheritedValues'));
     $form = Form::create();
     $instance->setForm($form);
     $result = $instance->getForm($record);
     $this->assertInstanceOf('FluidTYPO3\\Flux\\Form', $result);
 }
Esempio n. 7
0
 /**
  * @test
  */
 public function modifyModifiesFields()
 {
     $form = Form::create();
     $sheet = $form->createContainer('Sheet', 'testsheet');
     $field = $sheet->createField('Input', 'testfield', 'Testfield');
     $sheet->modify(array('fields' => array('testfield' => array('label' => 'Test'))));
     $fields = $sheet->getFields();
     $this->assertEquals('Test', reset($fields)->getLabel());
 }
 /**
  * @test
  */
 public function triggersDomainModelAnalysisWhenFormsAreRegistered()
 {
     $class = 'FluidTYPO3\\Flux\\Domain\\Model\\Dummy';
     $form = Form::create();
     Core::registerAutoFormForModelObjectClassName($class);
     $object = GeneralUtility::getUserObj('FluidTYPO3\\Flux\\Backend\\TableConfigurationPostProcessor');
     $object->processData();
     Core::registerFormForModelObjectClassName($class, $form);
     $object->processData();
 }
 /**
  * @return void
  */
 public function testDetectAndRegisterAllFluidBackendModules()
 {
     $form = Form::create();
     $instance = $this->getMock('FluidTYPO3\\Fluidbackend\\Service\\ConfigurationService', array('getBackendModuleTemplatePaths', 'getFormFromTemplateFile', 'registerModuleBasedOnFluxForm'));
     $paths = new TemplatePaths('FluidTYPO3.Fluidbackend');
     $instance->expects($this->once())->method('getBackendModuleTemplatePaths')->willReturn(array('FluidTYPO3.Fluidbackend' => $paths->toArray()));
     $instance->expects($this->atLeastOnce())->method('registerModuleBasedOnFluxForm');
     $instance->expects($this->atLeastOnce())->method('getFormFromTemplateFile')->willReturn($form);
     $instance->detectAndRegisterAllFluidBackendModules();
 }
Esempio n. 10
0
 /**
  * @test
  * @dataProvider getValuesAndTransformations
  * @param mixed $value
  * @param string $transformation
  * @param mixed $expected
  */
 public function testTransformation($value, $transformation, $expected)
 {
     $instance = $this->getMock('FluidTYPO3\\Flux\\Transformation\\FormDataTransformer', array('loadObjectsFromRepository'));
     $instance->expects($this->any())->method('loadObjectsFromRepository')->willReturn(array());
     $instance->injectObjectManager($this->objectManager);
     $form = Form::create();
     $form->createField('Input', 'field')->setTransform($transformation);
     $transformed = $instance->transformAccordingToConfiguration(array('field' => $value), $form);
     $this->assertTrue($transformed !== $expected, 'Transformation type ' . $transformation . ' failed; values are still identical');
 }
Esempio n. 11
0
 /**
  * @test
  */
 public function testRender()
 {
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'] = array();
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeResolver'] = array();
     $form = Form::create();
     $nodeFactory = $this->getMock(NodeFactory::class, array('create'));
     $nodeFactory->expects($this->once())->method('create')->willReturn($this->getMock(NodeInterface::class));
     $instance = $this->getMock($this->createInstanceClassName(), array('getNodeFactory'));
     $instance->expects($this->once())->method('getNodeFactory')->willReturn($nodeFactory);
     $instance->render($form);
 }
 public function testRenderWizardTabItem()
 {
     $form = Form::create();
     $form->setLabel('bazlabel');
     $form->setDescription('foobar');
     $service = $this->getMock('FluidTYPO3\\Fluidcontent\\Service\\ConfigurationService', array(), array(), '', FALSE);
     $result = $this->callInaccessibleMethod($service, 'buildWizardTabItem', 'tabid', 'id', $form, '');
     $this->assertContains('tabid.elements.id', $result);
     $this->assertContains('title = bazlabel', $result);
     $this->assertContains('description = foobar', $result);
 }
Esempio n. 13
0
 /**
  * @test
  */
 public function testRender()
 {
     $form = Form::create();
     $engine = $this->getMock('TYPO3\\CMS\\Backend\\Form\\FormEngine', array('printNeededJSFunctions_top', 'getSoloField', 'printNeededJSFunctions'), array(), '', FALSE);
     $engine->expects($this->once())->method('printNeededJSFunctions_top')->willReturn('1');
     $engine->expects($this->once())->method('getSoloField')->willReturn('2');
     $engine->expects($this->once())->method('printNeededJSFunctions')->willReturn('3');
     $instance = $this->getMock($this->createInstanceClassName(), array('getFormEngine'));
     $instance->expects($this->once())->method('getFormEngine')->willReturn($engine);
     $result = $instance->render($form);
     $this->assertEquals('123', $result);
 }
Esempio n. 14
0
 /**
  * @return Form
  */
 protected function getForm()
 {
     if (TRUE === $this->viewHelperVariableContainer->exists(self::SCOPE, self::SCOPE_VARIABLE_FORM)) {
         $form = $this->viewHelperVariableContainer->get(self::SCOPE, self::SCOPE_VARIABLE_FORM);
     } elseif (TRUE === $this->templateVariableContainer->exists(self::SCOPE_VARIABLE_FORM)) {
         $form = $this->templateVariableContainer->get(self::SCOPE_VARIABLE_FORM);
     } else {
         $form = Form::create();
         $this->viewHelperVariableContainer->add(self::SCOPE, self::SCOPE_VARIABLE_FORM, $form);
     }
     return $form;
 }
 /**
  * @test
  */
 public function triggersDomainModelAnalysisWhenFormsAreRegistered()
 {
     $class = 'FluidTYPO3\\Flux\\Tests\\Fixtures\\Classes\\Domain\\Model\\Dummy';
     $form = Form::create();
     $form->setExtensionName('FluidTYPO3.Flux');
     Core::registerAutoFormForModelObjectClassName($class);
     $object = GeneralUtility::getUserObj('FluidTYPO3\\Flux\\Backend\\TableConfigurationPostProcessor');
     $object->processData();
     Core::registerFormForModelObjectClassName($class, $form);
     $result = $object->processData();
     $this->assertEmpty($result);
 }
Esempio n. 16
0
 /**
  * @test
  */
 public function triggersContentManipulatorOnDatabaseOperationNew()
 {
     $row = Records::$contentRecordWithoutParentAndWithoutChildren;
     $form = Form::create();
     $provider = $this->getMock('FluidTYPO3\\Flux\\Provider\\ContentProvider', array('loadRecordFromDatabase', 'getForm'));
     $provider->expects($this->once())->method('loadRecordFromDatabase')->willReturn(array('foo' => 'bar'));
     $provider->expects($this->once())->method('getForm')->willReturn($form);
     /** @var DataHandler $tceMain */
     $tceMain = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
     $result = $provider->postProcessDatabaseOperation('new', $row['uid'], $row, $tceMain);
     $this->assertEmpty($result);
 }
 /**
  * @return array
  */
 public function getAddSubIconTestValues()
 {
     $formWithoutIcon = Form::create();
     $formWithIcon = Form::create(array('options' => array('icon' => 'icon')));
     $providerWithoutForm = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getForm'));
     $providerWithoutForm->expects($this->any())->method('getForm')->willReturn(NULL);
     $providerWithFormWithoutIcon = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getForm'));
     $providerWithFormWithoutIcon->expects($this->any())->method('getForm')->willReturn($formWithoutIcon);
     $providerWithFormWithIcon = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getForm'));
     $providerWithFormWithIcon->expects($this->any())->method('getForm')->willReturn($formWithIcon);
     return array(array(array('pages', 1, array()), NULL, NULL), array(array('tt_content', 1, array()), NULL, NULL), array(array('tt_content', 1, array()), $providerWithoutForm, NULL), array(array('tt_content', 1, array('field' => 'test')), $providerWithoutForm, NULL), array(array('tt_content', 1, array('field' => 'test')), $providerWithFormWithoutIcon, NULL), array(array('tt_content', 1, array('field' => 'test')), $providerWithFormWithIcon, 'icon'));
 }
 /**
  * @test
  */
 public function testGetCurrentOutlet()
 {
     $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTquery', 'sql_fetch_assoc', 'exec_INSERTquery'));
     $form = Form::create();
     $request = new Request();
     $provider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getForm'));
     $provider->expects($this->once())->method('getForm')->willReturn($form);
     $instance = $this->getMockForAbstractClass('FluidTYPO3\\Fluidbackend\\Controller\\AbstractBackendController');
     $this->inject($instance, 'provider', $provider);
     $this->inject($instance, 'request', $request);
     $result = $this->callInaccessibleMethod($instance, 'getCurrentOutlet');
     $this->assertInstanceOf('FluidTYPO3\\Flux\\Outlet\\OutletInterface', $result);
 }
Esempio n. 19
0
 /**
  * @return void
  */
 public function testRenderFieldCreatesExpectedOptions()
 {
     $configurationService = $this->getMock('FluidTYPO3\\Fluidcontent\\Service\\ConfigurationService', array('getContentElementFormInstances'));
     $forms = array('myextension' => array(Form::create(array('id' => 'test1', 'label' => 'Test1', 'options' => array('contentElementId' => 'test1'))), Form::create(array('id' => 'test2', 'label' => 'Test2', 'options' => array('contentElementId' => 'test2')))));
     $parameters = array('itemFormElName' => 'foobar', 'itemFormElValue' => 'test2');
     $parent = 'unused';
     $configurationService->expects($this->once())->method('getContentElementFormInstances')->willReturn($forms);
     $instance = $this->getMock('FluidTYPO3\\Fluidcontent\\Backend\\ContentSelector', array('getConfigurationService'));
     $instance->expects($this->once())->method('getConfigurationService')->willReturn($configurationService);
     $rendered = $instance->renderField($parameters, $parent);
     $this->assertContains('<optgroup label="myextension">', $rendered);
     $this->assertContains('<option', $rendered);
     $this->assertContains('value="test1"', $rendered);
     $this->assertContains('value="test2"', $rendered);
 }
Esempio n. 20
0
 /**
  * @test
  * @dataProvider getPreviewTestOptions
  * @param array $options
  * @param string $finalAssertionMethod
  * @return void
  */
 public function rendersPreviews(array $options, $finalAssertionMethod)
 {
     $provider = $this->objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider');
     $form = Form::create(array('name' => 'test', 'options' => array('preview' => $options)));
     $grid = Form\Container\Grid::create(array());
     $grid->createContainer('Row', 'row')->createContainer('Column', 'column');
     $provider->setGrid($grid);
     $provider->setForm($form);
     $provider->setTemplatePaths(array());
     $provider->setTemplatePathAndFilename($this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_PREVIEW));
     $previewView = $this->getMock($this->createInstanceClassName(), array('registerTargetContentAreaInSession'));
     $previewView->expects($this->any())->method('registerTargetContentAreaInSession');
     $previewView->injectConfigurationService($this->objectManager->get('FluidTYPO3\\Flux\\Service\\FluxService'));
     $previewView->injectConfigurationManager($this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'));
     $previewView->injectWorkspacesAwareRecordService($this->objectManager->get('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService'));
     $preview = $previewView->getPreview($provider, Records::$contentRecordIsParentAndHasChildren);
     $this->{$finalAssertionMethod}($preview);
 }
 /**
  * @param string $class
  * @param string $table
  * @return Form
  */
 public function generateFormInstanceFromClassName($class, $table)
 {
     $labelFields = AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Label', FALSE);
     $iconAnnotation = AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Icon');
     $extensionName = $this->getExtensionNameFromModelClassName($class);
     $values = AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Form\\Field', FALSE);
     $sheets = AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Form\\Sheet', FALSE);
     $labels = TRUE === is_array($labelFields) ? array_keys($labelFields) : array(key($values));
     foreach ($labels as $index => $labelField) {
         $labels[$index] = GeneralUtility::camelCaseToLowerCaseUnderscored($labelField);
     }
     $icon = TRUE === isset($iconAnnotation['config']['path']) ? $iconAnnotation['config']['path'] : 'ext_icon.png';
     $hasVisibilityToggle = (bool) AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Control\\Hide');
     $hasDeleteToggle = (bool) AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Control\\Delete');
     $hasStartTimeToggle = (bool) AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Control\\StartTime');
     $hasEndTimeToggle = (bool) AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Control\\EndTime');
     $hasFrontendGroupToggle = (bool) AnnotationUtility::getAnnotationValueFromClass($class, 'Flux\\Control\\FrontendUserGroup');
     $form = Form::create();
     $form->setName($table);
     $form->setExtensionName($extensionName);
     $form->setOption('labels', $labels);
     $form->setOption('delete', $hasDeleteToggle);
     $form->setOption('hide', $hasVisibilityToggle);
     $form->setOption('start', $hasStartTimeToggle);
     $form->setOption('end', $hasEndTimeToggle);
     $form->setOption(Form::OPTION_ICON, $icon);
     $form->setOption('frontendUserGroup', $hasFrontendGroupToggle);
     $fields = array();
     foreach ($sheets as $propertyName => $sheetAnnotation) {
         $sheetName = $sheetAnnotation['type'];
         if (FALSE === isset($fields[$sheetName])) {
             $fields[$sheetName] = array();
         }
         array_push($fields[$sheetName], $propertyName);
     }
     foreach ($fields as $sheetName => $propertyNames) {
         $form->remove($sheetName);
         $sheet = $form->createContainer('Sheet', $sheetName);
         foreach ($propertyNames as $propertyName) {
             $settings = $values[$propertyName];
             $propertyName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
             if (TRUE === isset($settings['type'])) {
                 $fieldType = implode('/', array_map('ucfirst', explode('.', $settings['type'])));
                 $field = $sheet->createField($fieldType, $propertyName);
                 foreach ($settings['config'] as $settingName => $settingValue) {
                     ObjectAccess::setProperty($field, $settingName, $settingValue);
                 }
             }
         }
     }
     return $form;
 }
Esempio n. 22
0
 /**
  * @param array $settings
  * @return void
  */
 public function loadSettings(array $settings)
 {
     if (TRUE === isset($settings['name'])) {
         $this->setName($settings['name']);
     }
     if (TRUE === isset($settings['form'])) {
         $form = Form::create($settings['form']);
         if (TRUE === isset($settings['extensionKey'])) {
             $extensionKey = $settings['extensionKey'];
             $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey);
             $form->setExtensionName($extensionName);
         }
         $settings['form'] = $form;
     }
     if (TRUE === isset($settings['grid'])) {
         $settings['grid'] = Grid::create($settings['grid']);
     }
     foreach ($settings as $name => $value) {
         $this->{$name} = $value;
     }
     $fieldName = $this->getFieldName(array());
     if (TRUE === isset($settings['listType'])) {
         $listType = $settings['listType'];
         $GLOBALS['TCA'][$this->tableName]['types']['list']['subtypes_addlist'][$listType] = $fieldName;
     }
     $GLOBALS['TCA'][$this->tableName]['columns'][$fieldName]['config']['type'] = 'flex';
 }
Esempio n. 23
0
 /**
  * @return array
  */
 public function getConvertFlexFormContentToArrayTestValues()
 {
     return array(array('', NULL, '', '', array()), array('', Form::create(), '', '', array()), array(Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD, Form::create(), '', '', array('settings' => array('input' => 0))));
 }
Esempio n. 24
0
 /**
  * @test
  */
 public function canSetForm()
 {
     $form = Form::create(array('name' => 'test'));
     $record = Records::$contentRecordWithoutParentAndWithoutChildren;
     $provider = $this->getConfigurationProviderInstance();
     $provider->setForm($form);
     $this->assertSame($form, $provider->getForm($record));
 }
 /**
  * @test
  */
 public function canGetGridWhenItDoesNotExistAndStorageDoesNotExist()
 {
     $form = Form::create();
     $instance = $this->createMockedInstanceForVariableContainerTests();
     ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(FALSE));
     ObjectAccess::getProperty($instance, 'templateVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
     ObjectAccess::getProperty($instance, 'templateVariableContainer', TRUE)->expects($this->any())->method('get')->will($this->returnValue($form));
     $output = $this->callInaccessibleMethod($instance, 'getGrid');
     $this->assertInstanceOf('FluidTYPO3\\Flux\\Form\\Container\\Grid', $output);
 }
Esempio n. 26
0
 /**
  * @test
  */
 public function canGenerateLocalisableLabel()
 {
     $instance = $this->createInstance();
     $instance->setLabel(NULL);
     $instance->setExtensionName('Flux');
     /** @var Form $form */
     $instance->setName('testFormId');
     $form = Form::create(array('name' => 'test', 'extensionName' => 'flux'));
     $form->add($instance);
     $label = $instance->getLabel();
     $this->assertContains('switchableControllerActions', $label);
     $this->assertStringStartsWith('LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux', $label);
 }
Esempio n. 27
0
 /**
  * @test
  */
 public function canSetAndGetOutlet()
 {
     /** @var \FluidTYPO3\Flux\Outlet\StandardOutlet $outlet */
     $outlet = $this->getMock('FluidTYPO3\\Flux\\Outlet\\StandardOutlet');
     $form = Form::create();
     $form->setOutlet($outlet);
     $this->assertSame($outlet, $form->getOutlet());
 }
Esempio n. 28
0
 /**
  * @param array $row
  * @return \FluidTYPO3\Flux\Form|NULL
  */
 public function getForm(array $row)
 {
     if (TRUE === $this->isUsingSubFieldName()) {
         $configuration = $this->pageService->getPageTemplateConfiguration($row['uid']);
         if ($configuration[$this->mainAction] === $configuration[$this->subAction]) {
             $form = Form::create();
             $form->createField('UserFunction', '')->setFunction('FluidTYPO3\\Fluidpages\\UserFunction\\NoSubPageConfiguration->renderField');
             return $form;
         }
     }
     return parent::getForm($row);
 }
 /**
  * @test
  */
 public function canGetMergedConfigurationAndMergeToCache()
 {
     $form = Form::create();
     $form->createContainer('Grid', 'grid');
     $form->createField('Input', 'test');
     $form->createContainer('Object', 'testobject');
     $record = $this->getBasicRecord();
     $tree = array($record);
     $instance = $this->getMock(substr(get_class($this), 0, -4), array('getForm', 'getFlexFormValues', 'hasCacheForMergedConfiguration'));
     $instance->reset();
     $instance->expects($this->once())->method('getForm')->will($this->returnValue($form));
     $instance->expects($this->once())->method('hasCacheForMergedConfiguration')->will($this->returnValue(TRUE));
     $this->callInaccessibleMethod($instance, 'getMergedConfiguration', $tree, 'testing', TRUE);
 }
Esempio n. 30
0
 /**
  * @test
  */
 public function canGetRegisteredFormsForModelClassNames()
 {
     $fakeClass = 'MyFakeClass';
     $form = Form::create();
     Core::registerFormForModelObjectClassName($fakeClass, $form);
     $this->assertSame($form, Core::getRegisteredFormForModelObjectClass($fakeClass));
     $this->assertContains($form, Core::getRegisteredFormsForModelObjectClasses());
     Core::unregisterFormForModelObjectClassName($fakeClass);
 }