/** * @dataProvider getTestElementsWhiteAndBlackListsAndExpectedList * @test * @param array $items * @param string $whitelist * @param string $blacklist * @param array $expectedList */ public function processesWizardItems($items, $whitelist, $blacklist, $expectedList) { $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); /** @var WizardItemsHookSubscriber $instance */ $instance = $objectManager->get('FluidTYPO3\\Fluidcontent\\Hooks\\WizardItemsHookSubscriber'); $emulatedPageAndContentRecord = array('uid' => 1, 'tx_flux_column' => 'name'); $controller = new NewContentElementController(); $controller->colPos = 0; $controller->uid_pid = -1; $grid = new Grid(); $row = new Row(); $column = new Column(); $column->setColumnPosition(0); $column->setName('name'); $column->setVariable('Fluidcontent', array('allowedContentTypes' => $whitelist, 'deniedContentTypes' => $blacklist)); $row->add($column); $grid->add($row); /** @var Provider $provider1 */ $provider1 = $objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider'); $provider1->setTemplatePaths(array()); $provider1->setTemplateVariables(array()); $provider1->setGrid($grid); $provider2 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid')); $provider2->expects($this->exactly(1))->method('getGrid')->will($this->returnValue(NULL)); /** @var ConfigurationService|\PHPUnit_Framework_MockObject_MockObject $configurationService */ $configurationService = $this->getMock('FluidTYPO3\\Fluidcontent\\Service\\ConfigurationService', array('resolveConfigurationProviders', 'writeCachedConfigurationIfMissing')); $configurationService->expects($this->exactly(1))->method('resolveConfigurationProviders')->will($this->returnValue(array($provider1, $provider2))); /** @var WorkspacesAwareRecordService|\PHPUnit_Framework_MockObject_MockObject $recordService */ $recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle')); $recordService->expects($this->exactly(2))->method('getSingle')->will($this->returnValue($emulatedPageAndContentRecord)); $instance->injectConfigurationService($configurationService); $instance->injectRecordService($recordService); $instance->manipulateWizardItems($items, $controller); $this->assertEquals($expectedList, $items); }
/** * @dataProvider getTestElementsWhiteAndBlackListsAndExpectedList * @test * @param array $items * @param string $whitelist * @param string $blacklist * @param array $expectedList */ public function processesWizardItems($items, $whitelist, $blacklist, $expectedList) { $instance = $this->getMock('FluidTYPO3\\Flux\\Hooks\\WizardItemsHookSubscriber', array('getAreaNameAndParentFromRelativeRecordOrDefaults')); $instance->expects($this->once())->method('getAreaNameAndParentFromRelativeRecordOrDefaults')->willReturn(array(1, 'area')); $emulatedPageAndContentRecord = array('uid' => 1, 'tx_flux_column' => 'area'); $controller = new NewContentElementController(); $controller->colPos = 0; $controller->uid_pid = -1; $grid = new Grid(); $row = new Row(); $column = new Column(); $column->setColumnPosition(0); $column->setName('area'); $column->setVariable('allowedContentTypes', $whitelist); $column->setVariable('deniedContentTypes', $blacklist); $row->add($column); $grid->add($row); $provider1 = $this->objectManager->get('FluidTYPO3\\Flux\\Provider\\Provider'); $provider1->setTemplatePaths(array()); $provider1->setTemplateVariables(array()); $provider1->setGrid($grid); $provider2 = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getGrid')); $provider2->expects($this->exactly(2))->method('getGrid')->will($this->returnValue(NULL)); $configurationService = $this->getMock('FluidTYPO3\\Flux\\Service\\FluxService', array('resolveConfigurationProviders')); $configurationService->expects($this->exactly(2))->method('resolveConfigurationProviders')->will($this->returnValue(array($provider1, $provider2))); $recordService = $this->getMock('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService', array('getSingle')); $recordService->expects($this->exactly(2))->method('getSingle')->will($this->returnValue($emulatedPageAndContentRecord)); $instance->injectConfigurationService($configurationService); $instance->injectRecordService($recordService); $instance->manipulateWizardItems($items, $controller); $this->assertEquals($expectedList, $items); }