23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
58 protected function setUp()
60 $this->widgetRequestBuilder = $this->getAccessibleMock(WidgetRequestBuilder::class, [
'setArgumentsFromRawRequestData']);
61 $this->mockWidgetRequest = $this->createMock(WidgetRequest::class);
62 $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class);
63 $this->mockObjectManager->expects($this->once())->method(
'get')->with(WidgetRequest::class)->will($this->returnValue($this->mockWidgetRequest));
64 $this->widgetRequestBuilder->_set(
'objectManager', $this->mockObjectManager);
65 $this->mockWidgetContext = $this->createMock(WidgetContext::class);
66 $this->mockAjaxWidgetContextHolder = $this->createMock(AjaxWidgetContextHolder::class);
67 $this->widgetRequestBuilder->injectAjaxWidgetContextHolder($this->mockAjaxWidgetContextHolder);
76 'REMOTE_ADDR' =>
'foo',
77 'SSL_SESSION_ID' =>
'foo',
78 'REQUEST_URI' =>
'foo',
79 'ORIG_SCRIPT_NAME' =>
'foo',
80 'REQUEST_METHOD' =>
'foo'
83 'not-the-fluid-widget-id' =>
'foo'
85 $this->expectException(\InvalidArgumentException::class);
86 $this->expectExceptionCode(1521190675);
87 $this->widgetRequestBuilder->build();
96 'REMOTE_ADDR' =>
'foo',
97 'SSL_SESSION_ID' =>
'foo',
98 'REQUEST_URI' =>
'foo',
99 'ORIG_SCRIPT_NAME' =>
'foo',
100 'REQUEST_METHOD' =>
'foo'
103 'fluid-widget-id' =>
'foo'
105 $requestUri = GeneralUtility::getIndpEnv(
'TYPO3_REQUEST_URL');
106 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
107 $this->mockWidgetRequest->expects($this->once())->method(
'setRequestURI')->with($requestUri);
108 $this->widgetRequestBuilder->build();
117 'REMOTE_ADDR' =>
'foo',
118 'SSL_SESSION_ID' =>
'foo',
119 'REQUEST_URI' =>
'foo',
120 'ORIG_SCRIPT_NAME' =>
'foo',
121 'REQUEST_METHOD' =>
'foo'
124 'fluid-widget-id' =>
'foo'
126 $baseUri = GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL');
127 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
128 $this->mockWidgetRequest->expects($this->once())->method(
'setBaseURI')->with($baseUri);
129 $this->widgetRequestBuilder->build();
138 'REMOTE_ADDR' =>
'foo',
139 'SSL_SESSION_ID' =>
'foo',
140 'REQUEST_URI' =>
'foo',
141 'ORIG_SCRIPT_NAME' =>
'foo',
142 'REQUEST_METHOD' =>
'POST'
145 'fluid-widget-id' =>
'foo'
147 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
148 $this->mockWidgetRequest->expects($this->once())->method(
'setMethod')->with(
'POST');
149 $this->widgetRequestBuilder->build();
158 'REMOTE_ADDR' =>
'foo',
159 'SSL_SESSION_ID' =>
'foo',
160 'REQUEST_URI' =>
'foo',
161 'ORIG_SCRIPT_NAME' =>
'foo',
162 'REQUEST_METHOD' =>
'POST'
166 'fluid-widget-id' =>
'foo'
171 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
172 $this->mockWidgetRequest->expects($this->once())->method(
'setArguments')->with($_POST);
173 $this->widgetRequestBuilder->build();
182 'REMOTE_ADDR' =>
'foo',
183 'SSL_SESSION_ID' =>
'foo',
184 'REQUEST_URI' =>
'foo',
185 'ORIG_SCRIPT_NAME' =>
'foo',
186 'REQUEST_METHOD' =>
'GET'
190 'fluid-widget-id' =>
'foo'
195 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
196 $this->mockWidgetRequest->expects($this->once())->method(
'setArguments')->with($_GET);
197 $this->widgetRequestBuilder->build();
206 'REMOTE_ADDR' =>
'foo',
207 'SSL_SESSION_ID' =>
'foo',
208 'REQUEST_URI' =>
'foo',
209 'ORIG_SCRIPT_NAME' =>
'foo',
210 'REQUEST_METHOD' =>
'foo'
213 'action' =>
'myAction',
214 'fluid-widget-id' =>
'foo'
216 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
217 $this->mockWidgetRequest->expects($this->once())->method(
'setControllerActionName')->with(
'myAction');
218 $this->widgetRequestBuilder->build();
227 'REMOTE_ADDR' =>
'foo',
228 'SSL_SESSION_ID' =>
'foo',
229 'REQUEST_URI' =>
'foo',
230 'ORIG_SCRIPT_NAME' =>
'foo',
231 'REQUEST_METHOD' =>
'foo'
234 'fluid-widget-id' =>
'123'
236 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
237 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->with(
'123')->will($this->returnValue($this->mockWidgetContext));
238 $this->mockWidgetRequest->expects($this->once())->method(
'setWidgetContext')->with($this->mockWidgetContext);
239 $this->widgetRequestBuilder->build();
248 'REMOTE_ADDR' =>
'foo',
249 'SSL_SESSION_ID' =>
'foo',
250 'REQUEST_URI' =>
'foo',
251 'ORIG_SCRIPT_NAME' =>
'foo',
252 'REQUEST_METHOD' =>
'foo'
255 'fluid-widget-id' =>
'foo'
257 $this->mockAjaxWidgetContextHolder->expects($this->once())->method(
'get')->will($this->returnValue($this->mockWidgetContext));
259 $actual = $this->widgetRequestBuilder->build();
260 $this->assertSame($expected, $actual);