/**
  * @test
  */
 public function viewHelperChildNodesCanBeReadAgain()
 {
     $viewHelperChildNodes = $this->createMock(\TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode::class);
     $renderingContext = $this->createMock(\TYPO3\Fluid\Core\Rendering\RenderingContextInterface::class);
     $this->widgetContext->setViewHelperChildNodes($viewHelperChildNodes, $renderingContext);
     $this->assertSame($viewHelperChildNodes, $this->widgetContext->getViewHelperChildNodes());
     $this->assertSame($renderingContext, $this->widgetContext->getViewHelperChildNodeRenderingContext());
 }
 /**
  * @test
  */
 public function viewHelperChildNodesCanBeReadAgain()
 {
     $viewHelperChildNodes = $this->getMock('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\RootNode');
     $renderingContext = $this->getMock('TYPO3\\Fluid\\Core\\Rendering\\RenderingContextInterface');
     $this->widgetContext->setViewHelperChildNodes($viewHelperChildNodes, $renderingContext);
     $this->assertSame($viewHelperChildNodes, $this->widgetContext->getViewHelperChildNodes());
     $this->assertSame($renderingContext, $this->widgetContext->getViewHelperChildNodeRenderingContext());
 }
Ejemplo n.º 3
0
 /**
  * Stores the WidgetContext inside the Context, and sets the
  * AjaxWidgetIdentifier inside the Widget Context correctly.
  *
  * @param \TYPO3\Fluid\Core\Widget\WidgetContext $widgetContext
  * @return void
  */
 public function store(\TYPO3\Fluid\Core\Widget\WidgetContext $widgetContext)
 {
     $ajaxWidgetId = md5(uniqid(mt_rand(), TRUE));
     $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
     $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
     $this->storeWidgetContexts();
 }
 /**
  * @test
  */
 public function processRequestShouldSetWidgetConfiguration()
 {
     $mockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $mockResponse = $this->getMock(\TYPO3\Flow\Http\Response::class);
     $httpRequest = Request::create(new Uri('http://localhost'));
     $mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($httpRequest));
     $expectedWidgetConfiguration = array('foo' => uniqid());
     $widgetContext = new WidgetContext();
     $widgetContext->setAjaxWidgetConfiguration($expectedWidgetConfiguration);
     $mockActionRequest->expects($this->atLeastOnce())->method('getInternalArgument')->with('__widgetContext')->will($this->returnValue($widgetContext));
     $abstractWidgetController = $this->getAccessibleMock(\TYPO3\Fluid\Core\Widget\AbstractWidgetController::class, array('resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'mapRequestArgumentsToControllerArguments', 'detectFormat', 'resolveView', 'callActionMethod'));
     $abstractWidgetController->_set('mvcPropertyMappingConfigurationService', $this->getMock(\TYPO3\Flow\Mvc\Controller\MvcPropertyMappingConfigurationService::class));
     $abstractWidgetController->processRequest($mockActionRequest, $mockResponse);
     $actualWidgetConfiguration = $abstractWidgetController->_get('widgetConfiguration');
     $this->assertEquals($expectedWidgetConfiguration, $actualWidgetConfiguration);
 }
Ejemplo n.º 5
0
 /**
  * The widget identifier is unique on the current page, and is used
  * in the URI as a namespace for the widget's arguments.
  *
  * @return string the widget identifier for this widget
  * @return void
  * @todo clean up, and make it somehow more routing compatible.
  */
 private function initializeWidgetIdentifier()
 {
     if (!$this->viewHelperVariableContainer->exists('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetViewHelper', 'nextWidgetNumber')) {
         $widgetCounter = 0;
     } else {
         $widgetCounter = $this->viewHelperVariableContainer->get('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetViewHelper', 'nextWidgetNumber');
     }
     $widgetIdentifier = '@widget_' . $widgetCounter;
     $this->viewHelperVariableContainer->addOrUpdate('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetViewHelper', 'nextWidgetNumber', $widgetCounter + 1);
     $this->widgetContext->setWidgetIdentifier($widgetIdentifier);
 }
 /**
  * @test
  */
 public function setChildNodesAddsChildNodesToWidgetContext()
 {
     $this->widgetContext = new \TYPO3\Fluid\Core\Widget\WidgetContext();
     $this->viewHelper->injectWidgetContext($this->widgetContext);
     $node1 = $this->getMock(\TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode::class);
     $node2 = $this->getMock(\TYPO3\Fluid\Core\Parser\SyntaxTree\TextNode::class, array(), array(), '', FALSE);
     $node3 = $this->getMock(\TYPO3\Fluid\Core\Parser\SyntaxTree\AbstractNode::class);
     $rootNode = new \TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode();
     $rootNode->addChildNode($node1);
     $rootNode->addChildNode($node2);
     $rootNode->addChildNode($node3);
     $this->objectManager->expects($this->once())->method('get')->with(\TYPO3\Fluid\Core\Parser\SyntaxTree\RootNode::class)->will($this->returnValue($rootNode));
     $renderingContext = $this->getMock(\TYPO3\Fluid\Core\Rendering\RenderingContextInterface::class);
     $this->viewHelper->_set('renderingContext', $renderingContext);
     $this->viewHelper->setChildNodes(array($node1, $node2, $node3));
     $this->assertEquals($rootNode, $this->widgetContext->getViewHelperChildNodes());
 }
Ejemplo n.º 7
0
 /**
  * @test
  */
 public function initiateSubRequestBuildsRequestProperly()
 {
     $controller = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetController', array(), array(), '', FALSE);
     $this->viewHelper->_set('controller', $controller);
     // Initial Setup
     $widgetRequest = $this->getMock('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $response = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->objectManager->expects($this->at(0))->method('create')->with('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest')->will($this->returnValue($widgetRequest));
     $this->objectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response')->will($this->returnValue($response));
     // Widget Context is set
     $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext);
     // The namespaced arguments are passed to the sub-request
     // and the action name is exctracted from the namespace.
     $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1'));
     $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array('k1' => 'k2', 'widget-1' => array('arg1' => 'val1', 'arg2' => 'val2', 'action' => 'myAction'))));
     $widgetRequest->expects($this->once())->method('setArguments')->with(array('arg1' => 'val1', 'arg2' => 'val2'));
     $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction');
     // Controller is called
     $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response);
     $output = $this->viewHelper->_call('initiateSubRequest');
     // SubResponse is returned
     $this->assertSame($response, $output);
 }
 /**
  * The widget identifier is unique on the current page, and is used
  * in the URI as a namespace for the widget's arguments.
  *
  * @return string the widget identifier for this widget
  * @return void
  */
 private function initializeWidgetIdentifier()
 {
     $widgetIdentifier = $this->hasArgument('widgetId') ? $this->arguments['widgetId'] : strtolower(str_replace('\\', '-', get_class($this)));
     $this->widgetContext->setWidgetIdentifier($widgetIdentifier);
 }
 /**
  * Stores the WidgetContext inside the Context, and sets the
  * AjaxWidgetIdentifier inside the Widget Context correctly.
  *
  * @param WidgetContext $widgetContext
  * @return void
  * @Flow\Session(autoStart=true)
  */
 public function store(WidgetContext $widgetContext)
 {
     $ajaxWidgetId = $this->nextFreeAjaxWidgetId++;
     $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
     $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
 }
Ejemplo n.º 10
0
 /**
  * Returns the unique URI namespace for this widget in the format pluginNamespace[widgetIdentifier]
  *
  * @return string
  */
 public function getArgumentPrefix()
 {
     return $this->widgetContext->getParentPluginNamespace() . '[' . $this->widgetContext->getWidgetIdentifier() . ']';
 }