19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
31 protected function setUp()
35 $this->injectDependenciesIntoViewHelper($this->viewHelper);
43 $this->setArgumentsUnderTest(
49 $expectedResult =
'<input type="radio" name="foo" value="" />';
50 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
51 $this->assertEquals($expectedResult, $actualResult);
59 $this->setArgumentsUnderTest(
66 $expectedResult =
'<input type="radio" name="foo" value="" checked="checked" />';
67 $actualResult = $this->viewHelper->initializeArgumentsAndRender();
68 $this->assertEquals($expectedResult, $actualResult);
76 $this->setArgumentsUnderTest(
80 'property' =>
'someProperty',
84 $formObject = new \stdClass();
85 $formObject->someProperty =
false;
87 $this->stubVariableContainer($formObject);
88 $this->stubRequestWithoutMappingErrors();
90 $result = $this->viewHelper->initializeArgumentsAndRender();
92 $this->assertContains(
93 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" checked="checked" />',
103 $this->setArgumentsUnderTest(
107 'property' =>
'someProperty',
111 $formObject = new \stdClass();
112 $formObject->someProperty =
true;
114 $this->stubVariableContainer($formObject);
115 $this->stubRequestWithoutMappingErrors();
117 $result = $this->viewHelper->initializeArgumentsAndRender();
119 $this->assertContains(
120 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" checked="checked" />',
130 $this->setArgumentsUnderTest(
134 'property' =>
'someProperty',
138 $formObject = new \stdClass();
139 $formObject->someProperty = [];
141 $this->stubVariableContainer($formObject);
142 $this->stubRequestWithoutMappingErrors();
144 $result = $this->viewHelper->initializeArgumentsAndRender();
146 $this->assertContains(
147 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
157 $this->setArgumentsUnderTest(
161 'property' =>
'someProperty',
165 $formObject = new \stdClass();
166 $formObject->someProperty =
'';
168 $this->stubVariableContainer($formObject);
169 $this->stubRequestWithoutMappingErrors();
171 $result = $this->viewHelper->initializeArgumentsAndRender();
173 $this->assertContains(
174 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
184 $this->setArgumentsUnderTest(
188 'property' =>
'someProperty',
192 $formObject = new \stdClass();
193 $formObject->someProperty =
null;
195 $this->stubVariableContainer($formObject);
196 $this->stubRequestWithoutMappingErrors();
198 $result = $this->viewHelper->initializeArgumentsAndRender();
200 $this->assertContains(
201 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',
211 $this->setArgumentsUnderTest(
215 'property' =>
'someProperty',
219 $property1 = new \stdClass();
220 $property2 = new \stdClass();
221 $property3 = new \stdClass();
223 $persistenceManager = $this->prophesize(PersistenceManager::class);
224 $persistenceManager->getIdentifierByObject($property1)->willReturn(1);
225 $persistenceManager->getIdentifierByObject($property2)->willReturn(2);
226 $persistenceManager->getIdentifierByObject($property3)->willReturn(3);
227 $this->viewHelper->injectPersistenceManager($persistenceManager->reveal());
229 $formObject = new \stdClass();
230 $formObject->someProperty = [$property1, $property2, $property3];
232 $this->stubVariableContainer($formObject);
233 $this->stubRequestWithoutMappingErrors();
235 $result = $this->viewHelper->initializeArgumentsAndRender();
237 $this->assertContains(
238 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="2" />',
248 $this->setArgumentsUnderTest(
252 'property' =>
'someProperty',
253 'errorClass' =>
'error',
257 $formObject = new \stdClass();
258 $formObject->someProperty =
null;
260 $this->stubVariableContainer($formObject);
261 $this->stubRequestWithMappingErrors();
263 $result = $this->viewHelper->initializeArgumentsAndRender();
265 $this->assertContains(
266 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" class="error" />',
276 $this->setArgumentsUnderTest(
280 'property' =>
'someProperty',
284 $formObject = new \stdClass();
285 $formObject->someProperty =
null;
287 $this->stubVariableContainer($formObject);
288 $this->stubRequestWithMappingErrors();
290 $result = $this->viewHelper->initializeArgumentsAndRender();
292 $this->assertContains(
293 '<input type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" class="f3-form-error" />',
303 $this->setArgumentsUnderTest(
307 'property' =>
'someProperty',
308 'class' =>
'css_class'
312 $formObject = new \stdClass();
313 $formObject->someProperty =
null;
315 $this->stubVariableContainer($formObject);
316 $this->stubRequestWithMappingErrors();
318 $result = $this->viewHelper->initializeArgumentsAndRender();
320 $this->assertContains(
321 '<input class="css_class f3-form-error" type="radio" name="fieldPrefix[objectName][someProperty]" value="foo" />',