Skip to content
This repository
Browse code

Revert formatting

  • Loading branch information...
commit 116c17c5e1245f4db404c43eea752ad0ebbc997d 1 parent 4c21c65
rb-cohen rb-cohen authored

Showing 1 changed file with 74 additions and 46 deletions. Show diff stats Hide diff stats

  1. +74 46 tests/ZendTest/Form/View/Helper/FormRowTest.php
120 tests/ZendTest/Form/View/Helper/FormRowTest.php
... ... @@ -1,5 +1,4 @@
1 1 <?php
2   -
3 2 /**
4 3 * Zend Framework (http://framework.zend.com/)
5 4 *
@@ -22,23 +21,25 @@
22 21 * @package Zend_Form
23 22 * @subpackage UnitTest
24 23 */
25   -class FormRowTest extends TestCase {
26   -
  24 +class FormRowTest extends TestCase
  25 +{
27 26 protected $helper;
28 27 protected $renderer;
29 28
30   - public function setUp() {
  29 + public function setUp()
  30 + {
31 31 $this->helper = new FormRowHelper();
32 32
33 33 $this->renderer = new PhpRenderer;
34 34 $helpers = $this->renderer->getHelperPluginManager();
35   - $config = new HelperConfig();
  35 + $config = new HelperConfig();
36 36 $config->configureServiceManager($helpers);
37 37
38 38 $this->helper->setView($this->renderer);
39 39 }
40 40
41   - public function testCanGenerateLabel() {
  41 + public function testCanGenerateLabel()
  42 + {
42 43 $element = new Element('foo');
43 44 $element->setLabel('The value for foo:');
44 45 $markup = $this->helper->render($element);
@@ -47,7 +48,8 @@ public function testCanGenerateLabel() {
47 48 $this->assertContains('</label>', $markup);
48 49 }
49 50
50   - public function testCanCreateLabelValueBeforeInput() {
  51 + public function testCanCreateLabelValueBeforeInput()
  52 + {
51 53 $element = new Element('foo');
52 54 $element->setLabel('The value for foo:');
53 55 $this->helper->setLabelPosition('prepend');
@@ -56,7 +58,8 @@ public function testCanCreateLabelValueBeforeInput() {
56 58 $this->assertContains('</label>', $markup);
57 59 }
58 60
59   - public function testCanCreateLabelValueAfterInput() {
  61 + public function testCanCreateLabelValueAfterInput()
  62 + {
60 63 $element = new Element('foo');
61 64 $element->setOptions(array(
62 65 'label' => 'The value for foo:',
@@ -67,7 +70,8 @@ public function testCanCreateLabelValueAfterInput() {
67 70 $this->assertContains('</label>', $markup);
68 71 }
69 72
70   - public function testCanRenderRowLabelAttributes() {
  73 + public function testCanRenderRowLabelAttributes()
  74 + {
71 75 $element = new Element('foo');
72 76 $element->setLabel('The value for foo:');
73 77 $element->setLabelAttributes(array('class' => 'bar'));
@@ -76,14 +80,16 @@ public function testCanRenderRowLabelAttributes() {
76 80 $this->assertContains("<label class=\"bar\">", $markup);
77 81 }
78 82
79   - public function testCanCreateMarkupWithoutLabel() {
  83 + public function testCanCreateMarkupWithoutLabel()
  84 + {
80 85 $element = new Element('foo');
81 86 $element->setAttribute('type', 'text');
82 87 $markup = $this->helper->render($element);
83 88 $this->assertRegexp('/<input name="foo" type="text"[^\/>]*\/?>/', $markup);
84 89 }
85 90
86   - public function testCanHandleMultiCheckboxesCorrectly() {
  91 + public function testCanHandleMultiCheckboxesCorrectly()
  92 + {
87 93 $options = array(
88 94 'This is the first label' => 'value1',
89 95 'This is the second label' => 'value2',
@@ -100,7 +106,9 @@ public function testCanHandleMultiCheckboxesCorrectly() {
100 106 $this->assertContains("<label>", $markup);
101 107 }
102 108
103   - public function testRenderAttributeId() {
  109 +
  110 + public function testRenderAttributeId()
  111 + {
104 112 $element = new Element\Text('foo');
105 113 $element->setAttribute('type', 'text');
106 114 $element->setAttribute('id', 'textId');
@@ -110,8 +118,9 @@ public function testRenderAttributeId() {
110 118 $this->assertContains('<input type="text" name="foo" id="textId"', $markup);
111 119 }
112 120
113   - public function testCanRenderErrors() {
114   - $element = new Element('foo');
  121 + public function testCanRenderErrors()
  122 + {
  123 + $element = new Element('foo');
115 124 $element->setMessages(array(
116 125 'First error message',
117 126 'Second error message',
@@ -122,8 +131,9 @@ public function testCanRenderErrors() {
122 131 $this->assertRegexp('#<ul>\s*<li>First error message</li>\s*<li>Second error message</li>\s*<li>Third error message</li>\s*</ul>#s', $markup);
123 132 }
124 133
125   - public function testDoesNotRenderErrorsListIfSetToFalse() {
126   - $element = new Element('foo');
  134 + public function testDoesNotRenderErrorsListIfSetToFalse()
  135 + {
  136 + $element = new Element('foo');
127 137 $element->setMessages(array(
128 138 'First error message',
129 139 'Second error message',
@@ -134,8 +144,9 @@ public function testDoesNotRenderErrorsListIfSetToFalse() {
134 144 $this->assertRegexp('/<input name="foo" class="input-error" type="text" [^\/>]*\/?>/', $markup);
135 145 }
136 146
137   - public function testCanModifyDefaultErrorClass() {
138   - $element = new Element('foo');
  147 + public function testCanModifyDefaultErrorClass()
  148 + {
  149 + $element = new Element('foo');
139 150 $element->setMessages(array(
140 151 'Error message'
141 152 ));
@@ -144,8 +155,9 @@ public function testCanModifyDefaultErrorClass() {
144 155 $this->assertRegexp('/<input name="foo" class="custom-error-class" type="text" [^\/>]*\/?>/', $markup);
145 156 }
146 157
147   - public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors() {
148   - $element = new Element('foo');
  158 + public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors()
  159 + {
  160 + $element = new Element('foo');
149 161 $element->setMessages(array(
150 162 'Error message'
151 163 ));
@@ -155,18 +167,20 @@ public function testDoesNotOverrideClassesIfAlreadyPresentWhenThereAreErrors() {
155 167 $this->assertRegexp('/<input name="foo" class="foo bar custom-error-class" type="text" [^\/>]*\/?>/', $markup);
156 168 }
157 169
158   - public function testInvokeWithNoElementChainsHelper() {
  170 + public function testInvokeWithNoElementChainsHelper()
  171 + {
159 172 $this->assertSame($this->helper, $this->helper->__invoke());
160 173 }
161 174
162   - public function testLabelWillBeTranslated() {
  175 + public function testLabelWillBeTranslated()
  176 + {
163 177 $element = new Element('foo');
164 178 $element->setLabel('The value for foo:');
165 179
166 180 $mockTranslator = $this->getMock('Zend\I18n\Translator\Translator');
167 181 $mockTranslator->expects($this->any())
168   - ->method('translate')
169   - ->will($this->returnValue('translated content'));
  182 + ->method('translate')
  183 + ->will($this->returnValue('translated content'));
170 184
171 185 $this->helper->setTranslator($mockTranslator);
172 186 $this->assertTrue($this->helper->hasTranslator());
@@ -184,7 +198,8 @@ public function testLabelWillBeTranslated() {
184 198 $this->assertContains('</label>', $markup);
185 199 }
186 200
187   - public function testTranslatorMethods() {
  201 + public function testTranslatorMethods()
  202 + {
188 203 $translatorMock = $this->getMock('Zend\I18n\Translator\Translator');
189 204 $this->helper->setTranslator($translatorMock, 'foo');
190 205
@@ -197,46 +212,54 @@ public function testTranslatorMethods() {
197 212 $this->assertFalse($this->helper->isTranslatorEnabled());
198 213 }
199 214
200   - public function testInvokeSetLabelPositionToAppend() {
  215 + public function testInvokeSetLabelPositionToAppend()
  216 + {
201 217 $element = new Element('foo');
202 218 $this->helper->__invoke($element, 'append');
203 219
204 220 $this->assertSame('append', $this->helper->getLabelPosition());
205 221 }
206 222
207   - public function testSetLabelPositionInputNullRaisesException() {
  223 + public function testSetLabelPositionInputNullRaisesException()
  224 + {
208 225 $this->setExpectedException('Zend\Form\Exception\InvalidArgumentException');
209 226 $this->helper->setLabelPosition(null);
210 227 }
211 228
212   - public function testGetLabelPositionReturnsDefaultPrepend() {
  229 + public function testGetLabelPositionReturnsDefaultPrepend()
  230 + {
213 231 $labelPosition = $this->helper->getLabelPosition();
214 232 $this->assertEquals('prepend', $labelPosition);
215 233 }
216 234
217   - public function testGetLabelPositionReturnsAppend() {
  235 + public function testGetLabelPositionReturnsAppend()
  236 + {
218 237 $this->helper->setLabelPosition('append');
219 238 $labelPosition = $this->helper->getLabelPosition();
220 239 $this->assertEquals('append', $labelPosition);
221 240 }
222 241
223   - public function testGetRenderErrorsReturnsDefaultTrue() {
  242 + public function testGetRenderErrorsReturnsDefaultTrue()
  243 + {
224 244 $renderErrors = $this->helper->getRenderErrors();
225 245 $this->assertTrue($renderErrors);
226 246 }
227 247
228   - public function testGetRenderErrorsSetToFalse() {
  248 + public function testGetRenderErrorsSetToFalse()
  249 + {
229 250 $this->helper->setRenderErrors(false);
230 251 $renderErrors = $this->helper->getRenderErrors();
231 252 $this->assertFalse($renderErrors);
232 253 }
233 254
234   - public function testSetLabelAttributes() {
  255 + public function testSetLabelAttributes()
  256 + {
235 257 $this->helper->setLabelAttributes(array('foo', 'bar'));
236 258 $this->assertEquals(array(0 => 'foo', 1 => 'bar'), $this->helper->getLabelAttributes());
237 259 }
238 260
239   - public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan() {
  261 + public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan()
  262 + {
240 263 $element = new Element('foo');
241 264 $element->setLabel('The value for foo:');
242 265
@@ -251,12 +274,13 @@ public function testWhenUsingIdAndLabelBecomesEmptyRemoveSpan() {
251 274 $this->assertNotContains('</span>', $markup);
252 275 }
253 276
254   - public function testShowErrorInMultiCheckbox() {
  277 + public function testShowErrorInMultiCheckbox()
  278 + {
255 279 $element = new Element\MultiCheckbox('hobby');
256 280 $element->setLabel("Hobby");
257 281 $element->setValueOptions(array(
258   - '0' => 'working',
259   - '1' => 'coding'
  282 + '0'=>'working',
  283 + '1'=>'coding'
260 284 ));
261 285 $element->setMessages(array(
262 286 'Error message'
@@ -266,12 +290,13 @@ public function testShowErrorInMultiCheckbox() {
266 290 $this->assertContains('<ul><li>Error message</li></ul>', $markup);
267 291 }
268 292
269   - public function testShowErrorInRadio() {
  293 + public function testShowErrorInRadio()
  294 + {
270 295 $element = new Element\Radio('direction');
271 296 $element->setLabel("Direction");
272 297 $element->setValueOptions(array(
273   - '0' => 'programming',
274   - '1' => 'design'
  298 + '0'=>'programming',
  299 + '1'=>'design'
275 300 ));
276 301 $element->setMessages(array(
277 302 'Error message'
@@ -281,8 +306,9 @@ public function testShowErrorInRadio() {
281 306 $this->assertContains('<ul><li>Error message</li></ul>', $markup);
282 307 }
283 308
284   - public function testErrorShowTwice() {
285   - $element = new Element\Date('birth');
  309 + public function testErrorShowTwice()
  310 + {
  311 + $element = new Element\Date('birth');
286 312 $element->setFormat('Y-m-d');
287 313 $element->setValue('2010-13-13');
288 314
@@ -291,10 +317,11 @@ public function testErrorShowTwice() {
291 317 $element->setMessages($validator->getMessages());
292 318
293 319 $markup = $this->helper->__invoke($element);
294   - $this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
  320 + $this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
295 321 }
296   -
297   - public function testInvokeWithNoRenderErrors() {
  322 +
  323 + public function testInvokeWithNoRenderErrors()
  324 + {
298 325 $mock = $this->getMock(get_class($this->helper), array('setRenderErrors'));
299 326 $mock->expects($this->never())
300 327 ->method('setRenderErrors');
@@ -302,7 +329,8 @@ public function testInvokeWithNoRenderErrors() {
302 329 $mock->__invoke(new Element('foo'));
303 330 }
304 331
305   - public function testInvokeWithRenderErrorsTrue() {
  332 + public function testInvokeWithRenderErrorsTrue()
  333 + {
306 334 $mock = $this->getMock(get_class($this->helper), array('setRenderErrors'));
307 335 $mock->expects($this->once())
308 336 ->method('setRenderErrors')
@@ -310,5 +338,5 @@ public function testInvokeWithRenderErrorsTrue() {
310 338
311 339 $mock->__invoke(new Element('foo'), null, true);
312 340 }
313   -
  341 +
314 342 }

0 comments on commit 116c17c

Please sign in to comment.
Something went wrong with that request. Please try again.