Пример #1
0
 /**
  * Set (override) the variable in $name.
  *
  * @param string $name
  * @param mixed $value
  * @return void
  */
 public function render($name, $value = NULL)
 {
     if ($value === NULL) {
         $value = $this->renderChildren();
     }
     if (FALSE === strpos($name, '.')) {
         if ($this->templateVariableContainer->exists($name) === TRUE) {
             $this->templateVariableContainer->remove($name);
         }
         $this->templateVariableContainer->add($name, $value);
     } elseif (1 == substr_count($name, '.')) {
         $parts = explode('.', $name);
         $objectName = array_shift($parts);
         $path = implode('.', $parts);
         if (FALSE === $this->templateVariableContainer->exists($objectName)) {
             return NULL;
         }
         $object = $this->templateVariableContainer->get($objectName);
         try {
             \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($object, $path, $value);
             // Note: re-insert the variable to ensure unreferenced values like arrays also get updated
             $this->templateVariableContainer->remove($objectName);
             $this->templateVariableContainer->add($objectName, $object);
         } catch (\Exception $error) {
             return NULL;
         }
     }
     return NULL;
 }
Пример #2
0
 /**
  * @param ControllerPipe $instance
  * @param string $controllerClassName
  * @return mixed
  */
 protected function performControllerExcecution(ControllerPipe $instance, $controllerClassName)
 {
     $controllerMock = $this->getMockForAbstractClass('FluidTYPO3\\Flux\\Controller\\AbstractFluxController', array(), $controllerClassName, TRUE, TRUE, TRUE, array('renderAction', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'canProcessRequest', 'mapRequestArgumentsToControllerArguments', 'checkRequestHash', 'buildControllerContext', 'setViewConfiguration', 'resolveView'));
     $controllerMock->expects($this->once())->method('initializeActionMethodArguments');
     $controllerMock->expects($this->once())->method('initializeActionMethodValidators');
     $controllerMock->expects($this->once())->method('renderAction')->will($this->returnValue($this->defaultData));
     $controllerMock->expects($this->once())->method('canProcessRequest')->will($this->returnValue(TRUE));
     $signalSlotDispatcherMock = $this->getMock('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher', array('dispatch'));
     $configurationManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', array('isFeatureEnabled'));
     $configurationManagerMock->expects($this->any())->method('isFeatureEnabled')->will($this->returnValue(TRUE));
     $propertyMappingServiceMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\MvcPropertyMappingConfigurationService', array('initializePropertyMappingConfigurationFromRequest'));
     $argumentsMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('getIterator'));
     $argumentsMock->expects($this->atLeastOnce())->method('getIterator')->will($this->returnValue(new \ArrayIterator(array(new Argument('test', 'string')))));
     ObjectAccess::setProperty($controllerMock, 'objectManager', $this->objectManager, TRUE);
     ObjectAccess::setProperty($controllerMock, 'configurationManager', $configurationManagerMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'mvcPropertyMappingConfigurationService', $propertyMappingServiceMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'arguments', $argumentsMock, TRUE);
     ObjectAccess::setProperty($controllerMock, 'signalSlotDispatcher', $signalSlotDispatcherMock, TRUE);
     $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'));
     $response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response', array('getContent'));
     $response->expects($this->once())->method('getContent')->will($this->returnValue($this->defaultData));
     $request = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request', array('getControllerActionName', 'getMethodParameters', 'getDispatched'));
     $request->expects($this->at(0))->method('getDispatched')->will($this->returnValue(FALSE));
     $request->expects($this->atLeastOnce())->method('getControllerActionName')->will($this->returnValue('render'));
     $dispatcherMock = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher', array('resolveController'), array($objectManagerMock));
     ObjectAccess::setProperty($dispatcherMock, 'signalSlotDispatcher', $signalSlotDispatcherMock, TRUE);
     ObjectAccess::setProperty($dispatcherMock, 'objectManager', $this->objectManager, TRUE);
     $dispatcherMock->expects($this->once())->method('resolveController')->will($this->returnValue($controllerMock));
     $objectManagerMock->expects($this->at(0))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request')->will($this->returnValue($request));
     $objectManagerMock->expects($this->at(1))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->will($this->returnValue($response));
     $objectManagerMock->expects($this->at(2))->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher')->will($this->returnValue($dispatcherMock));
     ObjectAccess::setProperty($instance, 'objectManager', $objectManagerMock, TRUE);
     return $instance->conduct($this->defaultData);
 }
Пример #3
0
 /**
  * @test
  */
 public function throwsErrorWhenNoTidyIsInstalled()
 {
     $instance = $this->createInstance();
     ObjectAccess::setProperty($instance, 'hasTidy', FALSE, TRUE);
     $this->setExpectedException('RuntimeException', NULL, 1352059753);
     $instance->render('test');
 }
Пример #4
0
 /**
  * Processing the focus point crop (fallback to LocalCropScaleMaskHelper)
  *
  * @param TaskInterface $task
  *
  * @return array|NULL
  */
 public function process(TaskInterface $task)
 {
     $configuration = $task->getConfiguration();
     $crop = $configuration['crop'] ? json_decode($configuration['crop']) : null;
     if ($crop instanceof \stdClass && isset($crop->x)) {
         // if crop is enable release the process
         return parent::process($task);
     }
     $sourceFile = $task->getSourceFile();
     try {
         if (self::$deepCheck === false) {
             self::$deepCheck = true;
             $ratio = $this->getCurrentRatioConfiguration();
             $this->dimensionService->getRatio($ratio);
             $newFile = $this->focusCropService->getCroppedImageSrcByFile($sourceFile, $ratio);
             $file = ResourceFactory::getInstance()->retrieveFileOrFolderObject($newFile);
             $targetFile = $task->getTargetFile();
             ObjectAccess::setProperty($targetFile, 'originalFile', $file, true);
             ObjectAccess::setProperty($targetFile, 'originalFileSha1', $file->getSha1(), true);
             ObjectAccess::setProperty($targetFile, 'storage', $file->getStorage(), true);
             ObjectAccess::setProperty($task, 'sourceFile', $file, true);
             ObjectAccess::setProperty($task, 'targetFile', $targetFile, true);
         }
     } catch (\Exception $ex) {
     }
     self::$deepCheck = false;
     return parent::process($task);
 }
Пример #5
0
 /**
  * @param array $settings
  * @return void
  */
 public function loadSettings(array $settings)
 {
     foreach ($settings as $name => $value) {
         if (TRUE === property_exists($this, $name)) {
             ObjectAccess::setProperty($this, $name, $value);
         }
     }
 }
Пример #6
0
 /**
  * Extends a given default ControllerContext.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
  * @return ControllerContext
  */
 public static function extend(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $source)
 {
     $controllerContext = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(ControllerContext::class);
     $propertyNames = ObjectAccess::getGettableProperties($source);
     foreach ($propertyNames as $propertyName => $propertyValue) {
         ObjectAccess::setProperty($controllerContext, $propertyName, $propertyValue);
     }
     return $controllerContext;
 }
Пример #7
0
 /**
  * @test
  * @dataProvider linkedDataProvider
  */
 public function itemsAreAddedToContainer($subject, $predicate, $object, $objectType, $language, $name, $expected)
 {
     $this->fixture->setArguments(['subject' => $subject, 'predicate' => $predicate, 'object' => $object, 'objectType' => $objectType, 'language' => $language, 'name' => $name]);
     $this->templateVariableContainer->expects($this->once())->method('remove')->with($name);
     $this->templateVariableContainer->expects($this->once())->method('add')->with($name)->will($this->returnValue(''));
     ObjectAccess::setProperty($this->fixture, 'templateVariableContainer', $this->templateVariableContainer, true);
     $this->fixture->render();
     $this->markTestIncomplete('Todo');
 }
Пример #8
0
 /**
  * @test
  */
 public function getParsedTemplateReturnsCompiledTemplateIfFound()
 {
     $instance = $this->getMock($this->createInstanceClassName(), array('getTemplateIdentifier'));
     $instance->expects($this->once())->method('getTemplateIdentifier');
     $compiler = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler', array('has', 'get'));
     $compiler->expects($this->once())->method('has')->willReturn(TRUE);
     $compiler->expects($this->once())->method('get')->willReturn('foobar');
     ObjectAccess::setProperty($instance, 'templateCompiler', $compiler, TRUE);
     $result = $this->callInaccessibleMethod($instance, 'getParsedTemplate');
     $this->assertEquals('foobar', $result);
 }
Пример #9
0
 /**
  * @return AbstractFluxController
  */
 protected function createAndTestDummyControllerInstance()
 {
     $record = Records::$contentRecordWithoutParentAndWithoutChildren;
     $record['pi_flexform'] = Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD;
     $record['tx_fed_fcefile'] = 'Flux:Default.html';
     $this->performDummyRegistration();
     $controllerClassName = 'FluidTYPO3\\Flux\\Controller\\ContentController';
     /** @var AbstractFluxController $instance */
     $instance = $this->objectManager->get($controllerClassName);
     ObjectAccess::setProperty($instance, 'extensionName', 'Flux', TRUE);
     return $instance;
 }
Пример #10
0
 /**
  * @dataProvider getRenderTestValues
  * @param array $arguments
  * @param mixed $selectedValue
  * @param mixed $content
  * @param string $expected
  */
 public function testRender(array $arguments, $selectedValue, $content, $expected)
 {
     $instance = $this->buildViewHelperInstance($arguments, array(), NULL, 'Vhs');
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     $viewHelperVariableContainer->add('FluidTYPO3\\Vhs\\ViewHelpers\\Form\\SelectViewHelper', 'options', array());
     $viewHelperVariableContainer->add('FluidTYPO3\\Vhs\\ViewHelpers\\Form\\SelectViewHelper', 'value', $selectedValue);
     ObjectAccess::setProperty($instance, 'viewHelperVariableContainer', $viewHelperVariableContainer, TRUE);
     $instance->setArguments($arguments);
     $instance->setRenderChildrenClosure(function () use($content) {
         return $content;
     });
     $result = $instance->render();
     $this->assertEquals($expected, $result);
 }
Пример #11
0
 /**
  * @return array
  */
 public function getNegativeTestValues()
 {
     $bar = new Bar();
     ObjectAccess::setProperty($bar, 'uid', 1, TRUE);
     $foo = new Foo();
     ObjectAccess::setProperty($foo, 'uid', 2, TRUE);
     $objectStorage = new ObjectStorage();
     $objectStorage->attach($bar);
     /** @var LazyObjectStorage $lazyObjectStorage */
     $lazyObjectStorage = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage', $bar, 'foo', 0);
     ObjectAccess::setProperty($lazyObjectStorage, 'isInitialized', TRUE, TRUE);
     $lazyObjectStorage->attach($foo);
     return array(array(array('foo'), 'bar'), array('foo,baz', 'bar'), array($objectStorage, $foo), array($lazyObjectStorage, $bar));
 }
Пример #12
0
 /**
  * @test
  */
 public function renderMethodCallsRenderChildrenAndTemplateVariableContainerAddAndRemoveIfAsArgumentGiven()
 {
     $array = array('1', '2', '3');
     $arguments = array('as' => 'test', 'content' => $array, 'glue' => ',');
     $mock = $this->getMock($this->getViewHelperClassName(), array('renderChildren'));
     $mock->expects($this->once())->method('renderChildren')->will($this->returnValue('test'));
     $mock->setArguments($arguments);
     $mockContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', array('add', 'get', 'remove', 'exists'));
     $mockContainer->expects($this->once())->method('exists')->with('test')->will($this->returnValue(TRUE));
     $mockContainer->expects($this->exactly(2))->method('add')->with('test', '1,2,3');
     $mockContainer->expects($this->once())->method('get')->with('test')->will($this->returnValue($array));
     $mockContainer->expects($this->exactly(2))->method('remove')->with('test');
     ObjectAccess::setProperty($mock, 'templateVariableContainer', $mockContainer, TRUE);
     $mock->render();
 }
Пример #13
0
 /**
  * Duplicates (all public accessable properties) the given registration the
  * amount of times configured in amountOfRegistrations
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  *
  * @return void
  */
 public function createDependingRegistrations($registration)
 {
     $registrations = $registration->getAmountOfRegistrations();
     for ($i = 1; $i <= $registrations - 1; $i++) {
         /** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $newReg */
         $newReg = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration');
         $properties = ObjectAccess::getGettableProperties($registration);
         foreach ($properties as $propertyName => $propertyValue) {
             ObjectAccess::setProperty($newReg, $propertyName, $propertyValue);
         }
         $newReg->setMainRegistration($registration);
         $newReg->setAmountOfRegistrations(1);
         $newReg->setIgnoreNotifications(TRUE);
         $this->registrationRepository->add($newReg);
     }
 }
 /**
  * @return AbstractFluxController
  */
 protected function createAndTestDummyControllerInstance()
 {
     $record = Records::$contentRecordWithoutParentAndWithoutChildren;
     $record['pi_flexform'] = Xml::SIMPLE_FLEXFORM_SOURCE_DEFAULT_SHEET_ONE_FIELD;
     $record['tx_fed_fcefile'] = 'Flux:Default.html';
     $frontend = new TypoScriptFrontendController($GLOBALS['TYPO3_CONF_VARS'], 1, 0);
     $frontend->cObj = new ContentObjectRenderer();
     $frontend->cObj->start($record);
     $this->performDummyRegistration();
     $controllerClassName = substr(get_class($this), 0, -4);
     /** @var AbstractFluxController $instance */
     $instance = $this->objectManager->get($controllerClassName);
     ObjectAccess::setProperty($instance, 'extensionName', 'Flux', TRUE);
     ObjectAccess::getProperty($instance, 'configurationManager', TRUE)->setContentObject($frontend->cObj);
     return $instance;
 }
Пример #15
0
 /**
  * @test
  */
 public function stopsRenderingWhenProviderSaysStop()
 {
     $instance = $this->getMock('FluidTYPO3\\Flux\\Backend\\Preview', array('createShortcutIcon'));
     $instance->expects($this->never())->method('createShortcutIcon');
     $configurationServiceMock = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolveConfigurationProviders'));
     $providerOne = $this->getMock('FluidTYPO3\\Flux\\Provider\\ContentProvider', array('getPreview'));
     $providerOne->expects($this->once())->method('getPreview')->will($this->returnValue(array('test', 'test', FALSE)));
     $providerTwo = $this->getMock('FluidTYPO3\\Flux\\Provider\\ContentProvider', array('getPreview'));
     $providerTwo->expects($this->never())->method('getPreview');
     $configurationServiceMock->expects($this->once())->method('resolveConfigurationProviders')->will($this->returnValue(array($providerOne, $providerTwo)));
     ObjectAccess::setProperty($instance, 'configurationService', $configurationServiceMock, TRUE);
     $header = 'test';
     $item = 'test';
     $record = Records::$contentRecordIsParentAndHasChildren;
     $draw = TRUE;
     $this->setup();
     $instance->renderPreview($header, $item, $record, $draw);
 }
Пример #16
0
 /**
  * @test
  */
 public function getContentAreasDefinedInContentElementCallsExpectedMethods()
 {
     $grid = $this->getMock('FluidTYPO3\\Flux\\Form\\Container\\Grid', array('build'));
     $grid->expects($this->once())->method('build')->willReturn(array('rows' => array(array('columns' => array(array('label' => 'column-label', 'name' => 'column'))))));
     $mock = $this->getMock('FluidTYPO3\\Flux\\Backend\\AreaListItemsProcessor', array('dummy'), array(), '', FALSE);
     $provider1 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid'));
     $provider1->expects($this->once())->method('getGrid')->willReturn(NULL);
     $provider2 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid'));
     $provider2->expects($this->once())->method('getGrid')->willReturn($grid);
     $providers = array($provider1, $provider2);
     $recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\RecordService', array('getSingle'));
     $recordService->expects($this->once())->method('getSingle')->will($this->returnValue(array('foo' => 'bar')));
     $fluxService = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolveConfigurationProviders'));
     $fluxService->expects($this->once())->method('resolveConfigurationProviders')->willReturn($providers);
     ObjectAccess::setProperty($mock, 'fluxService', $fluxService, TRUE);
     ObjectAccess::setProperty($mock, 'recordService', $recordService, TRUE);
     $mock->getContentAreasDefinedInContentElement(1);
 }
Пример #17
0
 /**
  * @dataProvider getRenderTestValues
  * @param array $arguments
  * @param string|NULL $prefix
  * @param string|NULL $objectName
  * @param array|NULL $names
  * @param string $expected
  */
 public function testRender(array $arguments, $prefix, $objectName, $names, $expected)
 {
     $instance = $this->buildViewHelperInstance($arguments, array(), NULL, 'Vhs');
     $viewHelperVariableContainer = new ViewHelperVariableContainer();
     if (NULL !== $objectName) {
         $viewHelperVariableContainer->add('TYPO3\\CMS\\Fluid\\ViewHelpers\\FormViewHelper', 'formObjectName', $objectName);
     }
     if (NULL !== $prefix) {
         $viewHelperVariableContainer->add('TYPO3\\CMS\\Fluid\\ViewHelpers\\FormViewHelper', 'fieldNamePrefix', $prefix);
     }
     if (NULL !== $names) {
         $viewHelperVariableContainer->add('TYPO3\\CMS\\Fluid\\ViewHelpers\\FormViewHelper', 'formFieldNames', $names);
     }
     ObjectAccess::setProperty($instance, 'viewHelperVariableContainer', $viewHelperVariableContainer, TRUE);
     $instance->setArguments($arguments);
     $result = $instance->render();
     $this->assertEquals($expected, $result);
 }
 /**
  * Processing the focus point crop (fallback to LocalCropScaleMaskHelper)
  *
  * @param TaskInterface $task
  *
  * @return array|NULL
  */
 public function process(TaskInterface $task)
 {
     $sourceFile = $task->getSourceFile();
     try {
         $ratio = $this->getCurrentRatioConfiguration();
         $this->dimensionService->getRatio($ratio);
         $newFile = $this->focusCropService->getCroppedImageSrcByFile($sourceFile, $ratio);
         $file = ResourceFactory::getInstance()->retrieveFileOrFolderObject($newFile);
         $targetFile = $task->getTargetFile();
         ObjectAccess::setProperty($targetFile, 'originalFile', $file, TRUE);
         ObjectAccess::setProperty($targetFile, 'originalFileSha1', $file->getSha1(), TRUE);
         ObjectAccess::setProperty($targetFile, 'storage', $file->getStorage(), TRUE);
         ObjectAccess::setProperty($task, 'sourceFile', $file, TRUE);
         ObjectAccess::setProperty($task, 'targetFile', $targetFile, TRUE);
     } catch (\Exception $ex) {
     }
     return parent::process($task);
 }
Пример #19
0
 /**
  * @param FileProcessingService $fileProcessingService
  * @param DriverInterface $driver
  * @param ProcessedFile $processedFile
  * @param File $file
  * @param $taskType
  * @param array $configuration
  */
 public function optimizeImage(FileProcessingService $fileProcessingService, DriverInterface $driver, ProcessedFile $processedFile, File $file, $taskType, array $configuration = [])
 {
     if ($processedFile->getType() !== AbstractFile::FILETYPE_IMAGE) {
         return;
     }
     $optimizedProcessedFile = $this->processedFileRepository->findOneByOriginalFileAndTaskTypeAndConfiguration($file, $this->getTaskTypeForExtension($processedFile->getExtension()), $configuration);
     if (!$optimizedProcessedFile->isProcessed()) {
         $this->process($optimizedProcessedFile, $processedFile);
     }
     // This is a hack because we can not return the optimized file
     if ($optimizedProcessedFile->isProcessed() && $optimizedProcessedFile->getIdentifier() !== '') {
         ObjectAccess::setProperty($processedFile, 'name', $optimizedProcessedFile->getName(), TRUE);
         ObjectAccess::setProperty($processedFile, 'identifier', $optimizedProcessedFile->getIdentifier(), TRUE);
         $properties = $processedFile->getProperties();
         $properties['width'] = $optimizedProcessedFile->getProperty('width');
         $properties['height'] = $optimizedProcessedFile->getProperty('height');
         ObjectAccess::setProperty($processedFile, 'properties', $properties, TRUE);
     }
 }
 /**
  * @dataProvider getAddSubIconTestValues
  * @param array $parameters
  * @param ProviderInterface|NULL
  * @param string|NULL $expected
  */
 public function testAddSubIcon(array $parameters, $provider, $expected)
 {
     $GLOBALS['TCA']['tt_content']['columns']['field']['config']['type'] = 'flex';
     $cache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array('has', 'set'));
     $cache->expects($this->once())->method('has')->willReturn(FALSE);
     $cache->expects($this->once())->method('set')->willReturn('icon');
     $service = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolvePrimaryConfigurationProvider'));
     $service->expects($this->any())->method('resolvePrimaryConfigurationProvider')->willReturn($provider);
     $instance = new ContentIconHookSubscriber();
     $instance->injectFluxService($service);
     ObjectAccess::setProperty($instance, 'cache', $cache, TRUE);
     $result = $instance->addSubIcon($parameters, new PageLayoutView());
     if (NULL === $expected) {
         $this->assertNull($result);
     } else {
         $this->assertNotNull($result);
     }
     unset($GLOBALS['TCA']);
 }
 /**
  * @return void
  */
 public function testInitializeViewVariables()
 {
     /** @var CoreContentController|\PHPUnit_Framework_MockObject_MockObject $instance */
     $instance = $this->getMock('FluidTYPO3\\FluidcontentCore\\Controller\\CoreContentController', array('getRecord', 'initializeProvider'));
     $instance->expects($this->atLeastOnce())->method('getRecord')->willReturn(array('uid' => 0));
     /** @var FluxService|\PHPUnit_Framework_MockObject_MockObject $service */
     $service = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('convertFlexFormContentToArray'));
     $service->expects($this->exactly(2))->method('convertFlexFormContentToArray')->willReturn(array());
     /** @var ObjectManager $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $instance->injectObjectManager($objectManager);
     $instance->injectConfigurationService($service);
     $provider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getTemplateVariables', 'getForm'));
     $provider->expects($this->any())->method('getTemplateVariables')->willReturn(array());
     $provider->expects($this->any())->method('getForm')->willReturn(NULL);
     $view = $this->getMock('FluidTYPO3\\Flux\\View\\ExposedTemplateView', array('assign', 'assignMultiple'));
     $view->expects($this->any())->method('assign');
     $view->expects($this->any())->method('assignMultiple');
     ObjectAccess::setProperty($instance, 'provider', $provider, TRUE);
     ObjectAccess::setProperty($instance, 'view', $view, TRUE);
     $this->callInaccessibleMethod($instance, 'initializeViewVariables');
 }
Пример #22
0
 /**
  * @param array $settings
  * @return \FluidTYPO3\Flux\Form\Container\Section
  */
 public static function create(array $settings)
 {
     /** @var ObjectManagerInterface $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var Section */
     $section = $objectManager->get('FluidTYPO3\\Flux\\Form\\Container\\Section');
     foreach ($settings as $settingName => $settingValue) {
         $setterMethodName = ObjectAccess::buildSetterMethodName($settingName);
         if (TRUE === method_exists($section, $setterMethodName)) {
             ObjectAccess::setProperty($section, $settingName, $settingValue);
         }
     }
     if (TRUE === isset($settings['objects'])) {
         foreach ($settings['objects'] as $fieldName => $objectSettings) {
             if (FALSE === isset($objectSettings['name'])) {
                 $objectSettings['name'] = $fieldName;
             }
             $object = Object::create($objectSettings);
             $section->add($object);
         }
     }
     return $section;
 }
Пример #23
0
 /**
  * @test
  */
 public function createsGridIfNotSet()
 {
     /** @var ViewHelperVariableContainer $viewHelperContainer */
     $viewHelperContainer = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
     /** @var Request $request */
     $request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     /** @var ControllerContext $controllerContext */
     $controllerContext = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
     $controllerContext->setRequest($request);
     $column = $this->getMock('FluidTYPO3\\Flux\\Form\\Container\\Column', array('setName', 'setLabel'));
     $column->expects($this->once())->method('setName');
     $column->expects($this->once())->method('setLabel');
     $row = $this->getMock('FluidTYPO3\\Flux\\Form\\Container\\Row', array('createContainer'));
     $grid = $this->getMock('FluidTYPO3\\Flux\\Form\\Container\\Grid', array('createContainer'));
     $grid->expects($this->once())->method('createContainer')->will($this->returnValue($row));
     $row->expects($this->once())->method('createContainer')->will($this->returnValue($column));
     $mock = $this->getMock($this->createInstanceClassName(), array('getContainer', 'getGrid'));
     $mock->expects($this->once())->method('getContainer')->will($this->returnValue(NULL));
     $mock->expects($this->once())->method('getGrid')->will($this->returnValue($grid));
     ObjectAccess::setProperty($mock, 'viewHelperVariableContainer', $viewHelperContainer, TRUE);
     ObjectAccess::setProperty($mock, 'controllerContext', $controllerContext, TRUE);
     $mock->render();
 }
Пример #24
0
 /**
  * Main action for administration
  *
  * @param \GeorgRinger\News\Domain\Model\Dto\AdministrationDemand $demand
  * @dontvalidate  $demand
  * @return void
  */
 public function indexAction(\GeorgRinger\News\Domain\Model\Dto\AdministrationDemand $demand = NULL)
 {
     $this->redirectToPageOnStart();
     if (is_null($demand)) {
         $demand = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\Dto\\AdministrationDemand');
         // Preselect by TsConfig (e.g. tx_news.module.preselect.topNewsRestriction = 1)
         if (isset($this->tsConfiguration['preselect.']) && is_array($this->tsConfiguration['preselect.'])) {
             unset($this->tsConfiguration['preselect.']['orderByAllowed']);
             foreach ($this->tsConfiguration['preselect.'] as $propertyName => $propertyValue) {
                 \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
             }
         }
     }
     $demand = $this->createDemandObjectFromSettings($demand);
     $categories = $this->categoryRepository->findParentCategoriesByPid($this->pageUid);
     $idList = array();
     foreach ($categories as $c) {
         $idList[] = $c->getUid();
     }
     $assignedValues = array('moduleToken' => $this->getToken(TRUE), 'page' => $this->pageUid, 'demand' => $demand, 'news' => $this->newsRepository->findDemanded($demand, FALSE), 'categories' => $this->categoryRepository->findTree($idList), 'dateformat' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']);
     $this->emitActionSignal('AdministrationController', self::SIGNAL_ADMINISTRATION_INDEX_ACTION, $assignedValues);
     $this->view->assignMultiple($assignedValues);
 }
 /**
  * @param array $templateVariableContainerArguments
  * @return TemplateVariableContainer
  */
 protected function executeViewHelperClosure($templateVariableContainerArguments = array())
 {
     $instance = $this->objectManager->get('FluidTYPO3\\Flux\\ViewHelpers\\Field\\CustomViewHelper');
     $container = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
     $arguments = array('name' => 'custom');
     foreach ($templateVariableContainerArguments as $name => $value) {
         $container->add($name, $value);
     }
     $node = new ViewHelperNode($instance, $arguments);
     $childNode = new TextNode('Hello world!');
     $renderingContext = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext');
     ObjectAccess::setProperty($renderingContext, 'templateVariableContainer', $container);
     $node->addChildNode($childNode);
     ObjectAccess::setProperty($instance, 'templateVariableContainer', $container, TRUE);
     ObjectAccess::setProperty($instance, 'renderingContext', $renderingContext, TRUE);
     $instance->setViewHelperNode($node);
     /** @var \Closure $closure */
     $closure = $this->callInaccessibleMethod($instance, 'buildClosure');
     $parameters = array('itemFormElName' => 'test', 'itemFormElLabel' => 'Test label');
     $output = $closure($parameters);
     $this->assertNotEmpty($output);
     $this->assertSame('Hello world!', $output);
     return $instance->getTemplateVariableContainer();
 }
Пример #26
0
 /**
  * @test
  */
 public function postProcessCommandCallsExpectedMethodToPasteRecord()
 {
     $record = $this->getBasicRecord();
     $mock = $this->getMock(str_replace('Tests\\Unit\\', '', substr(get_class($this), 0, -4)), array('getCallbackCommand'));
     $mock->expects($this->once())->method('getCallbackCommand')->will($this->returnValue(array('paste' => 1)));
     $mockContentService = $this->getMock('FluidTYPO3\\Flux\\Service\\ContentService', array('pasteAfter', 'moveRecord'));
     $mockContentService->expects($this->once())->method('pasteAfter');
     ObjectAccess::setProperty($mock, 'contentService', $mockContentService, TRUE);
     $command = 'move';
     $id = 0;
     $relativeTo = 0;
     $reference = new DataHandler();
     $mock->reset();
     $mock->postProcessCommand($command, $id, $record, $relativeTo, $reference);
 }
Пример #27
0
 /**
  * @return \FluidTYPO3\Flux\Backend\TceMain
  */
 protected function getInstance()
 {
     /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
     $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     /** @var \FluidTYPO3\Flux\Backend\TceMain $tceMainInstance */
     $tceMainInstance = $objectManager->get('FluidTYPO3\\Flux\\Backend\\TceMain');
     ObjectAccess::setProperty($tceMainInstance, 'cachesCleared', FALSE, TRUE);
     return $tceMainInstance;
 }
Пример #28
0
 /**
  * @test
  */
 public function canGetTemplateVariables()
 {
     $provider = $this->getConfigurationProviderInstance();
     ObjectAccess::setProperty($provider, 'templatePaths', array(), TRUE);
     $provider->setTemplatePathAndFilename($this->getAbsoluteFixtureTemplatePathAndFilename(self::FIXTURE_TEMPLATE_ABSOLUTELYMINIMAL));
     $record = $this->getBasicRecord();
     $values = $provider->getTemplateVariables($record);
     $this->assertIsArray($values);
 }
 /**
  * @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;
 }
Пример #30
0
 /**
  * @return EmailPipe
  */
 protected function createInstance()
 {
     $pipe = $this->getMock('FluidTYPO3\\Flux\\Outlet\\Pipe\\EmailPipe', array('sendEmail'));
     ObjectAccess::setProperty($pipe, 'label', 'Mock EmailPipe', TRUE);
     return $pipe;
 }