2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
31 $this->viewHelper = $this->getAccessibleMock(CheckboxViewHelper::class, array(
'setErrorClassAttribute',
'getName',
'getValueAttribute',
'isObjectAccessorMode',
'getPropertyValue',
'registerFieldNameForFormTokenGeneration'));
32 $this->arguments[
'property'] =
'';
34 $this->viewHelper->initializeArguments();
42 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
43 $mockTagBuilder->expects($this->once())->method(
'setTagName')->with(
'input');
44 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
45 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo');
46 $this->viewHelper->expects($this->once())->method(
'registerFieldNameForFormTokenGeneration')->with(
'foo');
47 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
49 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
50 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
51 $this->viewHelper->_set(
'tag', $mockTagBuilder);
53 $this->viewHelper->initialize();
54 $this->viewHelper->render();
62 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
63 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
64 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo');
65 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
66 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
68 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
69 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
70 $this->viewHelper->_set(
'tag', $mockTagBuilder);
72 $this->viewHelper->initialize();
73 $this->viewHelper->render(
true);
81 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
82 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
83 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo');
84 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
86 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
87 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
88 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
89 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(
true));
90 $this->viewHelper->_set(
'tag', $mockTagBuilder);
92 $this->viewHelper->initialize();
93 $this->viewHelper->render(
true);
94 $this->viewHelper->render(
false);
102 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
103 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
104 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo');
105 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
106 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
108 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
109 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
110 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
111 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(
true));
112 $this->viewHelper->_set(
'tag', $mockTagBuilder);
114 $this->viewHelper->initialize();
115 $this->viewHelper->render();
123 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
124 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
125 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo[]');
126 $this->viewHelper->expects($this->once())->method(
'registerFieldNameForFormTokenGeneration')->with(
'foo[]');
127 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
129 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
130 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
131 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
132 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(array()));
133 $this->viewHelper->_set(
'tag', $mockTagBuilder);
135 $this->viewHelper->initialize();
136 $this->viewHelper->render();
144 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
145 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
146 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo[]');
147 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
148 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
150 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
151 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
152 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
153 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(array(
'foo',
'bar',
'baz')));
154 $this->viewHelper->_set(
'tag', $mockTagBuilder);
156 $this->viewHelper->initialize();
157 $this->viewHelper->render();
165 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
166 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
167 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo[]');
168 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
169 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
171 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
172 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
173 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
174 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(
new \ArrayObject(array(
'foo',
'bar',
'baz'))));
175 $this->viewHelper->_set(
'tag', $mockTagBuilder);
177 $this->viewHelper->initialize();
178 $this->viewHelper->render();
186 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
187 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
188 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo');
189 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value',
'bar');
190 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
192 $this->viewHelper->expects($this->any())->method(
'getName')->will($this->returnValue(
'foo'));
193 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->will($this->returnValue(
'bar'));
194 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->will($this->returnValue(
true));
195 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->will($this->returnValue(
new \stdClass()));
196 $this->viewHelper->_set(
'tag', $mockTagBuilder);
198 $this->viewHelper->initialize();
199 $this->viewHelper->render();
207 $mockTagBuilder = $this->getMock(TagBuilder::class, array(
'setTagName',
'addAttribute'));
208 $mockTagBuilder->expects($this->at(1))->method(
'addAttribute')->with(
'type',
'checkbox');
209 $mockTagBuilder->expects($this->at(2))->method(
'addAttribute')->with(
'name',
'foo[]');
210 $mockTagBuilder->expects($this->at(3))->method(
'addAttribute')->with(
'value', 2);
211 $mockTagBuilder->expects($this->at(4))->method(
'addAttribute')->with(
'checked',
'checked');
213 $object1 = new \stdClass();
214 $object2 = new \stdClass();
215 $object3 = new \stdClass();
217 $this->viewHelper->expects($this->any())->method(
'getName')->willReturn(
'foo');
218 $this->viewHelper->expects($this->any())->method(
'getValueAttribute')->willReturn(2);
219 $this->viewHelper->expects($this->any())->method(
'isObjectAccessorMode')->willReturn(
true);
220 $this->viewHelper->expects($this->any())->method(
'getPropertyValue')->willReturn(array($object1, $object2, $object3));
221 $this->viewHelper->_set(
'tag', $mockTagBuilder);
223 $mockPersistenceManager = $this->getMock(PersistenceManagerInterface::class);
224 $mockPersistenceManager->expects($this->any())->method(
'getIdentifierByObject')->will($this->returnValueMap(array(
229 $this->viewHelper->_set(
'persistenceManager', $mockPersistenceManager);
231 $this->viewHelper->initialize();
232 $this->viewHelper->render();
240 $this->viewHelper->expects($this->once())->method(
'setErrorClassAttribute');
241 $this->viewHelper->render();