/** * @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)); }
/** * @param array $row * @return Grid|\FluidTYPO3\Flux\Provider\FluidTYPO3\Flux\Form\Container\Grid */ public function getGrid(array $row) { $extensionKey = $this->getExtensionKey($row); $values = $this->getFlexFormValues($row); $areas = $this->recursivelyFetchAllContentAreaNames($values['structure']); /** @var Grid $grid */ $grid = Grid::create(); $grid->setExtensionName($extensionKey); foreach ($areas as $areaName) { $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->createContainer('Content', $areaName)->setLabel($areaName); } return $grid; }
/** * @test */ public function canGetGridWhenItExistInStorage() { $form = Form::create(); $grid = Form\Container\Grid::create(); $grid->setName('test'); $grids = array('test' => $grid); $instance = $this->createMockedInstanceForVariableContainerTests(array('getForm')); $instance->expects($this->any())->method('getForm')->will($this->returnValue($form)); ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('exists')->will($this->returnValue(TRUE)); ObjectAccess::getProperty($instance, 'viewHelperVariableContainer', TRUE)->expects($this->any())->method('get')->will($this->returnValue($grids)); $output = $this->callInaccessibleMethod($instance, 'getGrid', 'test'); $this->assertSame($grid, $output); }
/** * @return array */ public function getBackendLayoutConfigurationTestValues() { $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord')); $standardProvider->setTemplatePaths(array()); $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()); $emptyGridProvider->setGrid(Grid::create()); $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default'); $grid = Grid::create(array()); $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('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'translatedlabel', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3))), '2.' => array('columns.' => array('1.' => array('name' => 'Fluid Content Area', 'colPos' => ContentService::COLPOS_FLUXCONTENT))))); return array(array($standardProvider, NULL, array()), array($standardProvider, array(), array()), array($actionLessProvider, array(), array()), array($emptyGridProvider, array(), array()), array($exceptionProvider, array(), array()), array($gridProvider, array(), $gridArray)); }
/** * @return array */ public function getPostProcessBackendLayoutTestValues() { $standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord')); $standardProvider->setTemplatePaths(array()); $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()); $emptyGridProvider->setGrid(Grid::create()); $emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default'); $grid = Grid::create(array()); $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' => 'translatedlabel', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3)))))), '__colPosList' => array(2), '__items' => array(array('translatedlabel', 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 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 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'; }
/** * @test */ public function canSetGrid() { $grid = Grid::create(array('name' => 'test')); $record = Records::$contentRecordWithoutParentAndWithoutChildren; $provider = $this->getConfigurationProviderInstance(); $provider->setGrid($grid); $this->assertSame($grid, $provider->getGrid($record)); }
/** * Reads a Grid constructed using flux:grid, returning an array of * defined rows and columns along with any content areas. * * Note about specific implementations: * * * EXT:fluidpages uses the Grid to render a BackendLayout on TYPO3 6.0 and above * * EXT:flux uses the Grid to render content areas inside content elements * registered with Flux * * But your custom extension is of course allowed to use the Grid for any * purpose. You can even read the Grid from - for example - the currently * selected page template to know exactly how the BackendLayout looks. * * @param ViewContext $viewContext * @param string $gridName * @return Grid|NULL */ public function getGridFromTemplateFile(ViewContext $viewContext, $gridName = 'grid') { $templatePathAndFilename = $viewContext->getTemplatePathAndFilename(); $section = $viewContext->getSectionName(); $grid = NULL; if (TRUE === file_exists($templatePathAndFilename)) { $exposedView = $this->getPreparedExposedTemplateView($viewContext); $exposedView->setTemplatePathAndFilename($templatePathAndFilename); $grid = $exposedView->getGrid($section, $gridName); } if (NULL === $grid) { $grid = Grid::create(array('name' => $gridName)); } return $grid; }
/** * @param array $record * @param boolean $withGrid * @return Provider */ protected function getMockProvider(array $record, $withGrid = TRUE) { $instance = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getViewVariables', 'getGrid')); if (FALSE === $withGrid) { $instance->expects($this->any())->method('getGrid')->willReturn(NULL); } else { $grid = Grid::create(); $grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColumnPosition(1)->setVariable('Fluidcontent', array('deniedContentTypes' => 'html', 'allowedContentTypes' => 'text')); $instance->expects($this->any())->method('getGrid')->willReturn($grid); } return $instance; }
/** * Reads a Grid constructed using flux:grid, returning an array of * defined rows and columns along with any content areas. * * Note about specific implementations: * * * EXT:fluidpages uses the Grid to render a BackendLayout on TYPO3 6.0 and above * * EXT:flux uses the Grid to render content areas inside content elements * registered with Flux * * But your custom extension is of course allowed to use the Grid for any * purpose. You can even read the Grid from - for example - the currently * selected page template to know exactly how the BackendLayout looks. * * @param string $templatePathAndFilename * @param string $section * @param string $gridName * @param array $paths * @param string $extensionName * @param array $variables * @return Grid|NULL */ public function getGridFromTemplateFile($templatePathAndFilename, $section = 'Configuration', $gridName = 'grid', array $paths = array(), $extensionName = NULL, array $variables = array()) { $grid = NULL; if (TRUE === file_exists($templatePathAndFilename)) { $exposedView = $this->getPreparedExposedTemplateView($extensionName, 'Flux', $paths, $variables); $exposedView->setTemplatePathAndFilename($templatePathAndFilename); $grid = $exposedView->getGrid($section, $gridName); } if (NULL === $grid) { $grid = Grid::create(array('name' => $gridName)); } return $grid; }