diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
commit | 46b77928f746a4231d064774b5b67fd892c7ce86 (patch) | |
tree | e3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/form/Symfony/Component/Form/Tests | |
parent | 68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff) | |
download | wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip |
rm vendor
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests')
100 files changed, 0 insertions, 20550 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php deleted file mode 100644 index ee9ed8f2..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ /dev/null | |||
@@ -1,732 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormError; | ||
15 | use Symfony\Component\Form\Tests\Fixtures\AlternatingRowType; | ||
16 | |||
17 | abstract class AbstractDivLayoutTest extends AbstractLayoutTest | ||
18 | { | ||
19 | public function testRow() | ||
20 | { | ||
21 | $form = $this->factory->createNamed('name', 'text'); | ||
22 | $form->addError(new FormError('[trans]Error![/trans]')); | ||
23 | $view = $form->createView(); | ||
24 | $html = $this->renderRow($view); | ||
25 | |||
26 | $this->assertMatchesXpath($html, | ||
27 | '/div | ||
28 | [ | ||
29 | ./label[@for="name"] | ||
30 | /following-sibling::ul | ||
31 | [./li[.="[trans]Error![/trans]"]] | ||
32 | [count(./li)=1] | ||
33 | /following-sibling::input[@id="name"] | ||
34 | ] | ||
35 | ' | ||
36 | ); | ||
37 | } | ||
38 | |||
39 | public function testRowOverrideVariables() | ||
40 | { | ||
41 | $view = $this->factory->createNamed('name', 'text')->createView(); | ||
42 | $html = $this->renderRow($view, array( | ||
43 | 'attr' => array('class' => 'my&class'), | ||
44 | 'label' => 'foo&bar', | ||
45 | 'label_attr' => array('class' => 'my&label&class'), | ||
46 | )); | ||
47 | |||
48 | $this->assertMatchesXpath($html, | ||
49 | '/div | ||
50 | [ | ||
51 | ./label[@for="name"][@class="my&label&class required"][.="[trans]foo&bar[/trans]"] | ||
52 | /following-sibling::input[@id="name"][@class="my&class"] | ||
53 | ] | ||
54 | ' | ||
55 | ); | ||
56 | } | ||
57 | |||
58 | public function testRepeatedRow() | ||
59 | { | ||
60 | $form = $this->factory->createNamed('name', 'repeated'); | ||
61 | $form->addError(new FormError('[trans]Error![/trans]')); | ||
62 | $view = $form->createView(); | ||
63 | $html = $this->renderRow($view); | ||
64 | |||
65 | // The errors of the form are not rendered by intention! | ||
66 | // In practice, repeated fields cannot have errors as all errors | ||
67 | // on them are mapped to the first child. | ||
68 | // (see RepeatedTypeValidatorExtension) | ||
69 | |||
70 | $this->assertMatchesXpath($html, | ||
71 | '/div | ||
72 | [ | ||
73 | ./label[@for="name_first"] | ||
74 | /following-sibling::input[@id="name_first"] | ||
75 | ] | ||
76 | /following-sibling::div | ||
77 | [ | ||
78 | ./label[@for="name_second"] | ||
79 | /following-sibling::input[@id="name_second"] | ||
80 | ] | ||
81 | ' | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | public function testButtonRow() | ||
86 | { | ||
87 | $form = $this->factory->createNamed('name', 'button'); | ||
88 | $view = $form->createView(); | ||
89 | $html = $this->renderRow($view); | ||
90 | |||
91 | $this->assertMatchesXpath($html, | ||
92 | '/div | ||
93 | [ | ||
94 | ./button[@type="button"][@name="name"] | ||
95 | ] | ||
96 | [count(//label)=0] | ||
97 | ' | ||
98 | ); | ||
99 | } | ||
100 | |||
101 | public function testRest() | ||
102 | { | ||
103 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
104 | ->add('field1', 'text') | ||
105 | ->add('field2', 'repeated') | ||
106 | ->add('field3', 'text') | ||
107 | ->add('field4', 'text') | ||
108 | ->getForm() | ||
109 | ->createView(); | ||
110 | |||
111 | // Render field2 row -> does not implicitly call renderWidget because | ||
112 | // it is a repeated field! | ||
113 | $this->renderRow($view['field2']); | ||
114 | |||
115 | // Render field3 widget | ||
116 | $this->renderWidget($view['field3']); | ||
117 | |||
118 | // Rest should only contain field1 and field4 | ||
119 | $html = $this->renderRest($view); | ||
120 | |||
121 | $this->assertMatchesXpath($html, | ||
122 | '/div | ||
123 | [ | ||
124 | ./label[@for="name_field1"] | ||
125 | /following-sibling::input[@type="text"][@id="name_field1"] | ||
126 | ] | ||
127 | /following-sibling::div | ||
128 | [ | ||
129 | ./label[@for="name_field4"] | ||
130 | /following-sibling::input[@type="text"][@id="name_field4"] | ||
131 | ] | ||
132 | [count(../div)=2] | ||
133 | [count(..//label)=2] | ||
134 | [count(..//input)=3] | ||
135 | /following-sibling::input | ||
136 | [@type="hidden"] | ||
137 | [@id="name__token"] | ||
138 | ' | ||
139 | ); | ||
140 | } | ||
141 | |||
142 | public function testRestWithChildrenForms() | ||
143 | { | ||
144 | $child1 = $this->factory->createNamedBuilder('child1', 'form') | ||
145 | ->add('field1', 'text') | ||
146 | ->add('field2', 'text'); | ||
147 | |||
148 | $child2 = $this->factory->createNamedBuilder('child2', 'form') | ||
149 | ->add('field1', 'text') | ||
150 | ->add('field2', 'text'); | ||
151 | |||
152 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
153 | ->add($child1) | ||
154 | ->add($child2) | ||
155 | ->getForm() | ||
156 | ->createView(); | ||
157 | |||
158 | // Render child1.field1 row | ||
159 | $this->renderRow($view['child1']['field1']); | ||
160 | |||
161 | // Render child2.field2 widget (remember that widget don't render label) | ||
162 | $this->renderWidget($view['child2']['field2']); | ||
163 | |||
164 | // Rest should only contain child1.field2 and child2.field1 | ||
165 | $html = $this->renderRest($view); | ||
166 | |||
167 | $this->assertMatchesXpath($html, | ||
168 | '/div | ||
169 | [ | ||
170 | ./label[not(@for)] | ||
171 | /following-sibling::div[@id="parent_child1"] | ||
172 | [ | ||
173 | ./div | ||
174 | [ | ||
175 | ./label[@for="parent_child1_field2"] | ||
176 | /following-sibling::input[@id="parent_child1_field2"] | ||
177 | ] | ||
178 | ] | ||
179 | ] | ||
180 | |||
181 | /following-sibling::div | ||
182 | [ | ||
183 | ./label[not(@for)] | ||
184 | /following-sibling::div[@id="parent_child2"] | ||
185 | [ | ||
186 | ./div | ||
187 | [ | ||
188 | ./label[@for="parent_child2_field1"] | ||
189 | /following-sibling::input[@id="parent_child2_field1"] | ||
190 | ] | ||
191 | ] | ||
192 | ] | ||
193 | [count(//label)=4] | ||
194 | [count(//input[@type="text"])=2] | ||
195 | /following-sibling::input[@type="hidden"][@id="parent__token"] | ||
196 | ' | ||
197 | ); | ||
198 | } | ||
199 | |||
200 | public function testRestAndRepeatedWithRow() | ||
201 | { | ||
202 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
203 | ->add('first', 'text') | ||
204 | ->add('password', 'repeated') | ||
205 | ->getForm() | ||
206 | ->createView(); | ||
207 | |||
208 | $this->renderRow($view['password']); | ||
209 | |||
210 | $html = $this->renderRest($view); | ||
211 | |||
212 | $this->assertMatchesXpath($html, | ||
213 | '/div | ||
214 | [ | ||
215 | ./label[@for="name_first"] | ||
216 | /following-sibling::input[@type="text"][@id="name_first"] | ||
217 | ] | ||
218 | [count(.//input)=1] | ||
219 | /following-sibling::input | ||
220 | [@type="hidden"] | ||
221 | [@id="name__token"] | ||
222 | ' | ||
223 | ); | ||
224 | } | ||
225 | |||
226 | public function testRestAndRepeatedWithRowPerChild() | ||
227 | { | ||
228 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
229 | ->add('first', 'text') | ||
230 | ->add('password', 'repeated') | ||
231 | ->getForm() | ||
232 | ->createView(); | ||
233 | |||
234 | $this->renderRow($view['password']['first']); | ||
235 | $this->renderRow($view['password']['second']); | ||
236 | |||
237 | $html = $this->renderRest($view); | ||
238 | |||
239 | $this->assertMatchesXpath($html, | ||
240 | '/div | ||
241 | [ | ||
242 | ./label[@for="name_first"] | ||
243 | /following-sibling::input[@type="text"][@id="name_first"] | ||
244 | ] | ||
245 | [count(.//input)=1] | ||
246 | [count(.//label)=1] | ||
247 | /following-sibling::input | ||
248 | [@type="hidden"] | ||
249 | [@id="name__token"] | ||
250 | ' | ||
251 | ); | ||
252 | } | ||
253 | |||
254 | public function testRestAndRepeatedWithWidgetPerChild() | ||
255 | { | ||
256 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
257 | ->add('first', 'text') | ||
258 | ->add('password', 'repeated') | ||
259 | ->getForm() | ||
260 | ->createView(); | ||
261 | |||
262 | // The password form is considered as rendered as all its children | ||
263 | // are rendered | ||
264 | $this->renderWidget($view['password']['first']); | ||
265 | $this->renderWidget($view['password']['second']); | ||
266 | |||
267 | $html = $this->renderRest($view); | ||
268 | |||
269 | $this->assertMatchesXpath($html, | ||
270 | '/div | ||
271 | [ | ||
272 | ./label[@for="name_first"] | ||
273 | /following-sibling::input[@type="text"][@id="name_first"] | ||
274 | ] | ||
275 | [count(//input)=2] | ||
276 | [count(//label)=1] | ||
277 | /following-sibling::input | ||
278 | [@type="hidden"] | ||
279 | [@id="name__token"] | ||
280 | ' | ||
281 | ); | ||
282 | } | ||
283 | |||
284 | public function testCollection() | ||
285 | { | ||
286 | $form = $this->factory->createNamed('name', 'collection', array('a', 'b'), array( | ||
287 | 'type' => 'text', | ||
288 | )); | ||
289 | |||
290 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
291 | '/div | ||
292 | [ | ||
293 | ./div[./input[@type="text"][@value="a"]] | ||
294 | /following-sibling::div[./input[@type="text"][@value="b"]] | ||
295 | ] | ||
296 | [count(./div[./input])=2] | ||
297 | ' | ||
298 | ); | ||
299 | } | ||
300 | |||
301 | // https://github.com/symfony/symfony/issues/5038 | ||
302 | public function testCollectionWithAlternatingRowTypes() | ||
303 | { | ||
304 | $data = array( | ||
305 | array('title' => 'a'), | ||
306 | array('title' => 'b'), | ||
307 | ); | ||
308 | $form = $this->factory->createNamed('name', 'collection', $data, array( | ||
309 | 'type' => new AlternatingRowType(), | ||
310 | )); | ||
311 | |||
312 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
313 | '/div | ||
314 | [ | ||
315 | ./div[./div/div/input[@type="text"][@value="a"]] | ||
316 | /following-sibling::div[./div/div/textarea[.="b"]] | ||
317 | ] | ||
318 | [count(./div[./div/div/input])=1] | ||
319 | [count(./div[./div/div/textarea])=1] | ||
320 | ' | ||
321 | ); | ||
322 | } | ||
323 | |||
324 | public function testEmptyCollection() | ||
325 | { | ||
326 | $form = $this->factory->createNamed('name', 'collection', array(), array( | ||
327 | 'type' => 'text', | ||
328 | )); | ||
329 | |||
330 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
331 | '/div | ||
332 | [./input[@type="hidden"][@id="name__token"]] | ||
333 | [count(./div)=0] | ||
334 | ' | ||
335 | ); | ||
336 | } | ||
337 | |||
338 | public function testCollectionRow() | ||
339 | { | ||
340 | $collection = $this->factory->createNamedBuilder( | ||
341 | 'collection', | ||
342 | 'collection', | ||
343 | array('a', 'b'), | ||
344 | array('type' => 'text') | ||
345 | ); | ||
346 | |||
347 | $form = $this->factory->createNamedBuilder('form', 'form') | ||
348 | ->add($collection) | ||
349 | ->getForm(); | ||
350 | |||
351 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
352 | '/div | ||
353 | [ | ||
354 | ./div | ||
355 | [ | ||
356 | ./label[not(@for)] | ||
357 | /following-sibling::div | ||
358 | [ | ||
359 | ./div | ||
360 | [ | ||
361 | ./label[@for="form_collection_0"] | ||
362 | /following-sibling::input[@type="text"][@value="a"] | ||
363 | ] | ||
364 | /following-sibling::div | ||
365 | [ | ||
366 | ./label[@for="form_collection_1"] | ||
367 | /following-sibling::input[@type="text"][@value="b"] | ||
368 | ] | ||
369 | ] | ||
370 | ] | ||
371 | /following-sibling::input[@type="hidden"][@id="form__token"] | ||
372 | ] | ||
373 | [count(.//input)=3] | ||
374 | ' | ||
375 | ); | ||
376 | } | ||
377 | |||
378 | public function testForm() | ||
379 | { | ||
380 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
381 | ->setMethod('PUT') | ||
382 | ->setAction('http://example.com') | ||
383 | ->add('firstName', 'text') | ||
384 | ->add('lastName', 'text') | ||
385 | ->getForm(); | ||
386 | |||
387 | // include ampersands everywhere to validate escaping | ||
388 | $html = $this->renderForm($form->createView(), array( | ||
389 | 'id' => 'my&id', | ||
390 | 'attr' => array('class' => 'my&class'), | ||
391 | )); | ||
392 | |||
393 | $this->assertMatchesXpath($html, | ||
394 | '/form | ||
395 | [ | ||
396 | ./input[@type="hidden"][@name="_method"][@value="PUT"] | ||
397 | /following-sibling::div | ||
398 | [ | ||
399 | ./div | ||
400 | [ | ||
401 | ./label[@for="name_firstName"] | ||
402 | /following-sibling::input[@type="text"][@id="name_firstName"] | ||
403 | ] | ||
404 | /following-sibling::div | ||
405 | [ | ||
406 | ./label[@for="name_lastName"] | ||
407 | /following-sibling::input[@type="text"][@id="name_lastName"] | ||
408 | ] | ||
409 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
410 | ] | ||
411 | [count(.//input)=3] | ||
412 | [@id="my&id"] | ||
413 | [@class="my&class"] | ||
414 | ] | ||
415 | [@method="post"] | ||
416 | [@action="http://example.com"] | ||
417 | [@class="my&class"] | ||
418 | ' | ||
419 | ); | ||
420 | } | ||
421 | |||
422 | public function testFormWidget() | ||
423 | { | ||
424 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
425 | ->add('firstName', 'text') | ||
426 | ->add('lastName', 'text') | ||
427 | ->getForm(); | ||
428 | |||
429 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
430 | '/div | ||
431 | [ | ||
432 | ./div | ||
433 | [ | ||
434 | ./label[@for="name_firstName"] | ||
435 | /following-sibling::input[@type="text"][@id="name_firstName"] | ||
436 | ] | ||
437 | /following-sibling::div | ||
438 | [ | ||
439 | ./label[@for="name_lastName"] | ||
440 | /following-sibling::input[@type="text"][@id="name_lastName"] | ||
441 | ] | ||
442 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
443 | ] | ||
444 | [count(.//input)=3] | ||
445 | ' | ||
446 | ); | ||
447 | } | ||
448 | |||
449 | // https://github.com/symfony/symfony/issues/2308 | ||
450 | public function testNestedFormError() | ||
451 | { | ||
452 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
453 | ->add($this->factory | ||
454 | ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) | ||
455 | ->add('grandChild', 'form') | ||
456 | ) | ||
457 | ->getForm(); | ||
458 | |||
459 | $form->get('child')->addError(new FormError('[trans]Error![/trans]')); | ||
460 | |||
461 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
462 | '/div | ||
463 | [ | ||
464 | ./div/label | ||
465 | /following-sibling::ul[./li[.="[trans]Error![/trans]"]] | ||
466 | ] | ||
467 | [count(.//li[.="[trans]Error![/trans]"])=1] | ||
468 | ' | ||
469 | ); | ||
470 | } | ||
471 | |||
472 | public function testCsrf() | ||
473 | { | ||
474 | $this->csrfProvider->expects($this->any()) | ||
475 | ->method('generateCsrfToken') | ||
476 | ->will($this->returnValue('foo&bar')); | ||
477 | |||
478 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
479 | ->add($this->factory | ||
480 | // No CSRF protection on nested forms | ||
481 | ->createNamedBuilder('child', 'form') | ||
482 | ->add($this->factory->createNamedBuilder('grandchild', 'text')) | ||
483 | ) | ||
484 | ->getForm(); | ||
485 | |||
486 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
487 | '/div | ||
488 | [ | ||
489 | ./div | ||
490 | /following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"] | ||
491 | ] | ||
492 | [count(.//input[@type="hidden"])=1] | ||
493 | ' | ||
494 | ); | ||
495 | } | ||
496 | |||
497 | public function testRepeated() | ||
498 | { | ||
499 | $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( | ||
500 | 'type' => 'text', | ||
501 | )); | ||
502 | |||
503 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
504 | '/div | ||
505 | [ | ||
506 | ./div | ||
507 | [ | ||
508 | ./label[@for="name_first"] | ||
509 | /following-sibling::input[@type="text"][@id="name_first"] | ||
510 | ] | ||
511 | /following-sibling::div | ||
512 | [ | ||
513 | ./label[@for="name_second"] | ||
514 | /following-sibling::input[@type="text"][@id="name_second"] | ||
515 | ] | ||
516 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
517 | ] | ||
518 | [count(.//input)=3] | ||
519 | ' | ||
520 | ); | ||
521 | } | ||
522 | |||
523 | public function testRepeatedWithCustomOptions() | ||
524 | { | ||
525 | $form = $this->factory->createNamed('name', 'repeated', null, array( | ||
526 | // the global required value cannot be overridden | ||
527 | 'first_options' => array('label' => 'Test', 'required' => false), | ||
528 | 'second_options' => array('label' => 'Test2') | ||
529 | )); | ||
530 | |||
531 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
532 | '/div | ||
533 | [ | ||
534 | ./div | ||
535 | [ | ||
536 | ./label[@for="name_first"][.="[trans]Test[/trans]"] | ||
537 | /following-sibling::input[@type="text"][@id="name_first"][@required="required"] | ||
538 | ] | ||
539 | /following-sibling::div | ||
540 | [ | ||
541 | ./label[@for="name_second"][.="[trans]Test2[/trans]"] | ||
542 | /following-sibling::input[@type="text"][@id="name_second"][@required="required"] | ||
543 | ] | ||
544 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
545 | ] | ||
546 | [count(.//input)=3] | ||
547 | ' | ||
548 | ); | ||
549 | } | ||
550 | |||
551 | public function testSearchInputName() | ||
552 | { | ||
553 | $form = $this->factory->createNamedBuilder('full', 'form') | ||
554 | ->add('name', 'search') | ||
555 | ->getForm(); | ||
556 | |||
557 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
558 | '/div | ||
559 | [ | ||
560 | ./div | ||
561 | [ | ||
562 | ./label[@for="full_name"] | ||
563 | /following-sibling::input[@type="search"][@id="full_name"][@name="full[name]"] | ||
564 | ] | ||
565 | /following-sibling::input[@type="hidden"][@id="full__token"] | ||
566 | ] | ||
567 | [count(//input)=2] | ||
568 | ' | ||
569 | ); | ||
570 | } | ||
571 | |||
572 | public function testLabelHasNoId() | ||
573 | { | ||
574 | $form = $this->factory->createNamed('name', 'text'); | ||
575 | $html = $this->renderRow($form->createView()); | ||
576 | |||
577 | $this->assertMatchesXpath($html, | ||
578 | '/div | ||
579 | [ | ||
580 | ./label[@for="name"][not(@id)] | ||
581 | /following-sibling::input[@id="name"] | ||
582 | ] | ||
583 | ' | ||
584 | ); | ||
585 | } | ||
586 | |||
587 | public function testLabelIsNotRenderedWhenSetToFalse() | ||
588 | { | ||
589 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
590 | 'label' => false | ||
591 | )); | ||
592 | $html = $this->renderRow($form->createView()); | ||
593 | |||
594 | $this->assertMatchesXpath($html, | ||
595 | '/div | ||
596 | [ | ||
597 | ./input[@id="name"] | ||
598 | ] | ||
599 | [count(//label)=0] | ||
600 | ' | ||
601 | ); | ||
602 | } | ||
603 | |||
604 | /** | ||
605 | * @dataProvider themeBlockInheritanceProvider | ||
606 | */ | ||
607 | public function testThemeBlockInheritance($theme) | ||
608 | { | ||
609 | $view = $this->factory | ||
610 | ->createNamed('name', 'email') | ||
611 | ->createView() | ||
612 | ; | ||
613 | |||
614 | $this->setTheme($view, $theme); | ||
615 | |||
616 | $this->assertMatchesXpath( | ||
617 | $this->renderWidget($view), | ||
618 | '/input[@type="email"][@rel="theme"]' | ||
619 | ); | ||
620 | } | ||
621 | |||
622 | /** | ||
623 | * @dataProvider themeInheritanceProvider | ||
624 | */ | ||
625 | public function testThemeInheritance($parentTheme, $childTheme) | ||
626 | { | ||
627 | $child = $this->factory->createNamedBuilder('child', 'form') | ||
628 | ->add('field', 'text'); | ||
629 | |||
630 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
631 | ->add('field', 'text') | ||
632 | ->add($child) | ||
633 | ->getForm() | ||
634 | ->createView() | ||
635 | ; | ||
636 | |||
637 | $this->setTheme($view, $parentTheme); | ||
638 | $this->setTheme($view['child'], $childTheme); | ||
639 | |||
640 | $this->assertWidgetMatchesXpath($view, array(), | ||
641 | '/div | ||
642 | [ | ||
643 | ./div | ||
644 | [ | ||
645 | ./label[.="parent"] | ||
646 | /following-sibling::input[@type="text"] | ||
647 | ] | ||
648 | /following-sibling::div | ||
649 | [ | ||
650 | ./label[.="child"] | ||
651 | /following-sibling::div | ||
652 | [ | ||
653 | ./div | ||
654 | [ | ||
655 | ./label[.="child"] | ||
656 | /following-sibling::input[@type="text"] | ||
657 | ] | ||
658 | ] | ||
659 | ] | ||
660 | /following-sibling::input[@type="hidden"] | ||
661 | ] | ||
662 | ' | ||
663 | ); | ||
664 | } | ||
665 | |||
666 | /** | ||
667 | * The block "_name_child_label" should be overridden in the theme of the | ||
668 | * implemented driver. | ||
669 | */ | ||
670 | public function testCollectionRowWithCustomBlock() | ||
671 | { | ||
672 | $collection = array('one', 'two', 'three'); | ||
673 | $form = $this->factory->createNamedBuilder('name', 'collection', $collection) | ||
674 | ->getForm(); | ||
675 | |||
676 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
677 | '/div | ||
678 | [ | ||
679 | ./div[./label[.="Custom label: [trans]0[/trans]"]] | ||
680 | /following-sibling::div[./label[.="Custom label: [trans]1[/trans]"]] | ||
681 | /following-sibling::div[./label[.="Custom label: [trans]2[/trans]"]] | ||
682 | ] | ||
683 | ' | ||
684 | ); | ||
685 | } | ||
686 | |||
687 | public function testFormEndWithRest() | ||
688 | { | ||
689 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
690 | ->add('field1', 'text') | ||
691 | ->add('field2', 'text') | ||
692 | ->getForm() | ||
693 | ->createView(); | ||
694 | |||
695 | $this->renderWidget($view['field1']); | ||
696 | |||
697 | // Rest should only contain field2 | ||
698 | $html = $this->renderEnd($view); | ||
699 | |||
700 | // Insert the start tag, the end tag should be rendered by the helper | ||
701 | $this->assertMatchesXpath('<form>' . $html, | ||
702 | '/form | ||
703 | [ | ||
704 | ./div | ||
705 | [ | ||
706 | ./label[@for="name_field2"] | ||
707 | /following-sibling::input[@type="text"][@id="name_field2"] | ||
708 | ] | ||
709 | /following-sibling::input | ||
710 | [@type="hidden"] | ||
711 | [@id="name__token"] | ||
712 | ] | ||
713 | ' | ||
714 | ); | ||
715 | } | ||
716 | |||
717 | public function testFormEndWithoutRest() | ||
718 | { | ||
719 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
720 | ->add('field1', 'text') | ||
721 | ->add('field2', 'text') | ||
722 | ->getForm() | ||
723 | ->createView(); | ||
724 | |||
725 | $this->renderWidget($view['field1']); | ||
726 | |||
727 | // Rest should only contain field2, but isn't rendered | ||
728 | $html = $this->renderEnd($view, array('render_rest' => false)); | ||
729 | |||
730 | $this->assertEquals('</form>', $html); | ||
731 | } | ||
732 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php deleted file mode 100644 index c16cb221..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractExtension; | ||
15 | use Symfony\Component\Form\Tests\Fixtures\FooType; | ||
16 | |||
17 | class AbstractExtensionTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | public function testHasType() | ||
20 | { | ||
21 | $loader = new ConcreteExtension(); | ||
22 | $this->assertTrue($loader->hasType('foo')); | ||
23 | $this->assertFalse($loader->hasType('bar')); | ||
24 | } | ||
25 | |||
26 | public function testGetType() | ||
27 | { | ||
28 | $loader = new ConcreteExtension(); | ||
29 | $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('foo')); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | class ConcreteExtension extends AbstractExtension | ||
34 | { | ||
35 | protected function loadTypes() | ||
36 | { | ||
37 | return array(new FooType()); | ||
38 | } | ||
39 | |||
40 | protected function loadTypeGuesser() | ||
41 | { | ||
42 | } | ||
43 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php deleted file mode 100644 index 29118187..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
16 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
17 | |||
18 | abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | /** | ||
21 | * @var EventDispatcherInterface | ||
22 | */ | ||
23 | protected $dispatcher; | ||
24 | |||
25 | /** | ||
26 | * @var \Symfony\Component\Form\FormFactoryInterface | ||
27 | */ | ||
28 | protected $factory; | ||
29 | |||
30 | /** | ||
31 | * @var \Symfony\Component\Form\FormInterface | ||
32 | */ | ||
33 | protected $form; | ||
34 | |||
35 | protected function setUp() | ||
36 | { | ||
37 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
38 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
39 | } | ||
40 | |||
41 | // We need an actual dispatcher to use the deprecated | ||
42 | // bindRequest() method | ||
43 | $this->dispatcher = new EventDispatcher(); | ||
44 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
45 | $this->form = $this->createForm(); | ||
46 | } | ||
47 | |||
48 | protected function tearDown() | ||
49 | { | ||
50 | $this->dispatcher = null; | ||
51 | $this->factory = null; | ||
52 | $this->form = null; | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return \Symfony\Component\Form\FormInterface | ||
57 | */ | ||
58 | abstract protected function createForm(); | ||
59 | |||
60 | /** | ||
61 | * @param string $name | ||
62 | * @param EventDispatcherInterface $dispatcher | ||
63 | * @param string $dataClass | ||
64 | * | ||
65 | * @return FormBuilder | ||
66 | */ | ||
67 | protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null, $dataClass = null) | ||
68 | { | ||
69 | return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * @param string $name | ||
74 | * | ||
75 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
76 | */ | ||
77 | protected function getMockForm($name = 'name') | ||
78 | { | ||
79 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
80 | $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); | ||
81 | |||
82 | $form->expects($this->any()) | ||
83 | ->method('getName') | ||
84 | ->will($this->returnValue($name)); | ||
85 | $form->expects($this->any()) | ||
86 | ->method('getConfig') | ||
87 | ->will($this->returnValue($config)); | ||
88 | |||
89 | return $form; | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * @param string $name | ||
94 | * | ||
95 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
96 | */ | ||
97 | protected function getValidForm($name) | ||
98 | { | ||
99 | $form = $this->getMockForm($name); | ||
100 | |||
101 | $form->expects($this->any()) | ||
102 | ->method('isValid') | ||
103 | ->will($this->returnValue(true)); | ||
104 | |||
105 | return $form; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * @param string $name | ||
110 | * | ||
111 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
112 | */ | ||
113 | protected function getInvalidForm($name) | ||
114 | { | ||
115 | $form = $this->getMockForm($name); | ||
116 | |||
117 | $form->expects($this->any()) | ||
118 | ->method('isValid') | ||
119 | ->will($this->returnValue(false)); | ||
120 | |||
121 | return $form; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
126 | */ | ||
127 | protected function getDataMapper() | ||
128 | { | ||
129 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
134 | */ | ||
135 | protected function getDataTransformer() | ||
136 | { | ||
137 | return $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
142 | */ | ||
143 | protected function getFormValidator() | ||
144 | { | ||
145 | return $this->getMock('Symfony\Component\Form\FormValidatorInterface'); | ||
146 | } | ||
147 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php deleted file mode 100644 index 8f632a2b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ /dev/null | |||
@@ -1,1876 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormError; | ||
15 | use Symfony\Component\Form\FormView; | ||
16 | use Symfony\Component\Form\Extension\Csrf\CsrfExtension; | ||
17 | |||
18 | abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase | ||
19 | { | ||
20 | protected $csrfProvider; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | if (!extension_loaded('intl')) { | ||
25 | $this->markTestSkipped('The "intl" extension is not available'); | ||
26 | } | ||
27 | |||
28 | \Locale::setDefault('en'); | ||
29 | |||
30 | $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); | ||
31 | |||
32 | parent::setUp(); | ||
33 | } | ||
34 | |||
35 | protected function getExtensions() | ||
36 | { | ||
37 | return array( | ||
38 | new CsrfExtension($this->csrfProvider), | ||
39 | ); | ||
40 | } | ||
41 | |||
42 | protected function tearDown() | ||
43 | { | ||
44 | $this->csrfProvider = null; | ||
45 | |||
46 | parent::tearDown(); | ||
47 | } | ||
48 | |||
49 | protected function assertXpathNodeValue(\DomElement $element, $expression, $nodeValue) | ||
50 | { | ||
51 | $xpath = new \DOMXPath($element->ownerDocument); | ||
52 | $nodeList = $xpath->evaluate($expression); | ||
53 | $this->assertEquals(1, $nodeList->length); | ||
54 | $this->assertEquals($nodeValue, $nodeList->item(0)->nodeValue); | ||
55 | } | ||
56 | |||
57 | protected function assertMatchesXpath($html, $expression, $count = 1) | ||
58 | { | ||
59 | $dom = new \DomDocument('UTF-8'); | ||
60 | try { | ||
61 | // Wrap in <root> node so we can load HTML with multiple tags at | ||
62 | // the top level | ||
63 | $dom->loadXml('<root>'.$html.'</root>'); | ||
64 | } catch (\Exception $e) { | ||
65 | $this->fail(sprintf( | ||
66 | "Failed loading HTML:\n\n%s\n\nError: %s", | ||
67 | $html, | ||
68 | $e->getMessage() | ||
69 | )); | ||
70 | } | ||
71 | $xpath = new \DOMXPath($dom); | ||
72 | $nodeList = $xpath->evaluate('/root'.$expression); | ||
73 | |||
74 | if ($nodeList->length != $count) { | ||
75 | $dom->formatOutput = true; | ||
76 | $this->fail(sprintf( | ||
77 | "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s", | ||
78 | $expression, | ||
79 | $count == 1 ? 'once' : $count.' times', | ||
80 | $nodeList->length == 1 ? 'once' : $nodeList->length.' times', | ||
81 | // strip away <root> and </root> | ||
82 | substr($dom->saveHTML(), 6, -8) | ||
83 | )); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | protected function assertWidgetMatchesXpath(FormView $view, array $vars, $xpath) | ||
88 | { | ||
89 | // include ampersands everywhere to validate escaping | ||
90 | $html = $this->renderWidget($view, array_merge(array( | ||
91 | 'id' => 'my&id', | ||
92 | 'attr' => array('class' => 'my&class'), | ||
93 | ), $vars)); | ||
94 | |||
95 | $xpath = trim($xpath).' | ||
96 | [@id="my&id"] | ||
97 | [@class="my&class"]'; | ||
98 | |||
99 | $this->assertMatchesXpath($html, $xpath); | ||
100 | } | ||
101 | |||
102 | abstract protected function renderForm(FormView $view, array $vars = array()); | ||
103 | |||
104 | abstract protected function renderEnctype(FormView $view); | ||
105 | |||
106 | abstract protected function renderLabel(FormView $view, $label = null, array $vars = array()); | ||
107 | |||
108 | abstract protected function renderErrors(FormView $view); | ||
109 | |||
110 | abstract protected function renderWidget(FormView $view, array $vars = array()); | ||
111 | |||
112 | abstract protected function renderRow(FormView $view, array $vars = array()); | ||
113 | |||
114 | abstract protected function renderRest(FormView $view, array $vars = array()); | ||
115 | |||
116 | abstract protected function renderStart(FormView $view, array $vars = array()); | ||
117 | |||
118 | abstract protected function renderEnd(FormView $view, array $vars = array()); | ||
119 | |||
120 | abstract protected function setTheme(FormView $view, array $themes); | ||
121 | |||
122 | public function testEnctype() | ||
123 | { | ||
124 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
125 | ->add('file', 'file') | ||
126 | ->getForm(); | ||
127 | |||
128 | $this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView())); | ||
129 | } | ||
130 | |||
131 | public function testNoEnctype() | ||
132 | { | ||
133 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
134 | ->add('text', 'text') | ||
135 | ->getForm(); | ||
136 | |||
137 | $this->assertEquals('', $this->renderEnctype($form->createView())); | ||
138 | } | ||
139 | |||
140 | public function testLabel() | ||
141 | { | ||
142 | $form = $this->factory->createNamed('name', 'text'); | ||
143 | $view = $form->createView(); | ||
144 | $this->renderWidget($view, array('label' => 'foo')); | ||
145 | $html = $this->renderLabel($view); | ||
146 | |||
147 | $this->assertMatchesXpath($html, | ||
148 | '/label | ||
149 | [@for="name"] | ||
150 | [.="[trans]Name[/trans]"] | ||
151 | ' | ||
152 | ); | ||
153 | } | ||
154 | |||
155 | public function testLabelOnForm() | ||
156 | { | ||
157 | $form = $this->factory->createNamed('name', 'date'); | ||
158 | $view = $form->createView(); | ||
159 | $this->renderWidget($view, array('label' => 'foo')); | ||
160 | $html = $this->renderLabel($view); | ||
161 | |||
162 | $this->assertMatchesXpath($html, | ||
163 | '/label | ||
164 | [@class="required"] | ||
165 | [.="[trans]Name[/trans]"] | ||
166 | ' | ||
167 | ); | ||
168 | } | ||
169 | |||
170 | public function testLabelWithCustomTextPassedAsOption() | ||
171 | { | ||
172 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
173 | 'label' => 'Custom label', | ||
174 | )); | ||
175 | $html = $this->renderLabel($form->createView()); | ||
176 | |||
177 | $this->assertMatchesXpath($html, | ||
178 | '/label | ||
179 | [@for="name"] | ||
180 | [.="[trans]Custom label[/trans]"] | ||
181 | ' | ||
182 | ); | ||
183 | } | ||
184 | |||
185 | public function testLabelWithCustomTextPassedDirectly() | ||
186 | { | ||
187 | $form = $this->factory->createNamed('name', 'text'); | ||
188 | $html = $this->renderLabel($form->createView(), 'Custom label'); | ||
189 | |||
190 | $this->assertMatchesXpath($html, | ||
191 | '/label | ||
192 | [@for="name"] | ||
193 | [.="[trans]Custom label[/trans]"] | ||
194 | ' | ||
195 | ); | ||
196 | } | ||
197 | |||
198 | public function testLabelWithCustomTextPassedAsOptionAndDirectly() | ||
199 | { | ||
200 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
201 | 'label' => 'Custom label', | ||
202 | )); | ||
203 | $html = $this->renderLabel($form->createView(), 'Overridden label'); | ||
204 | |||
205 | $this->assertMatchesXpath($html, | ||
206 | '/label | ||
207 | [@for="name"] | ||
208 | [.="[trans]Overridden label[/trans]"] | ||
209 | ' | ||
210 | ); | ||
211 | } | ||
212 | |||
213 | public function testLabelDoesNotRenderFieldAttributes() | ||
214 | { | ||
215 | $form = $this->factory->createNamed('name', 'text'); | ||
216 | $html = $this->renderLabel($form->createView(), null, array( | ||
217 | 'attr' => array( | ||
218 | 'class' => 'my&class' | ||
219 | ), | ||
220 | )); | ||
221 | |||
222 | $this->assertMatchesXpath($html, | ||
223 | '/label | ||
224 | [@for="name"] | ||
225 | [@class="required"] | ||
226 | ' | ||
227 | ); | ||
228 | } | ||
229 | |||
230 | public function testLabelWithCustomAttributesPassedDirectly() | ||
231 | { | ||
232 | $form = $this->factory->createNamed('name', 'text'); | ||
233 | $html = $this->renderLabel($form->createView(), null, array( | ||
234 | 'label_attr' => array( | ||
235 | 'class' => 'my&class' | ||
236 | ), | ||
237 | )); | ||
238 | |||
239 | $this->assertMatchesXpath($html, | ||
240 | '/label | ||
241 | [@for="name"] | ||
242 | [@class="my&class required"] | ||
243 | ' | ||
244 | ); | ||
245 | } | ||
246 | |||
247 | public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() | ||
248 | { | ||
249 | $form = $this->factory->createNamed('name', 'text'); | ||
250 | $html = $this->renderLabel($form->createView(), 'Custom label', array( | ||
251 | 'label_attr' => array( | ||
252 | 'class' => 'my&class' | ||
253 | ), | ||
254 | )); | ||
255 | |||
256 | $this->assertMatchesXpath($html, | ||
257 | '/label | ||
258 | [@for="name"] | ||
259 | [@class="my&class required"] | ||
260 | [.="[trans]Custom label[/trans]"] | ||
261 | ' | ||
262 | ); | ||
263 | } | ||
264 | |||
265 | // https://github.com/symfony/symfony/issues/5029 | ||
266 | public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() | ||
267 | { | ||
268 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
269 | 'label' => 'Custom label', | ||
270 | )); | ||
271 | $html = $this->renderLabel($form->createView(), null, array( | ||
272 | 'label_attr' => array( | ||
273 | 'class' => 'my&class' | ||
274 | ), | ||
275 | )); | ||
276 | |||
277 | $this->assertMatchesXpath($html, | ||
278 | '/label | ||
279 | [@for="name"] | ||
280 | [@class="my&class required"] | ||
281 | [.="[trans]Custom label[/trans]"] | ||
282 | ' | ||
283 | ); | ||
284 | } | ||
285 | |||
286 | public function testErrors() | ||
287 | { | ||
288 | $form = $this->factory->createNamed('name', 'text'); | ||
289 | $form->addError(new FormError('[trans]Error 1[/trans]')); | ||
290 | $form->addError(new FormError('[trans]Error 2[/trans]')); | ||
291 | $view = $form->createView(); | ||
292 | $html = $this->renderErrors($view); | ||
293 | |||
294 | $this->assertMatchesXpath($html, | ||
295 | '/ul | ||
296 | [ | ||
297 | ./li[.="[trans]Error 1[/trans]"] | ||
298 | /following-sibling::li[.="[trans]Error 2[/trans]"] | ||
299 | ] | ||
300 | [count(./li)=2] | ||
301 | ' | ||
302 | ); | ||
303 | } | ||
304 | |||
305 | public function testWidgetById() | ||
306 | { | ||
307 | $form = $this->factory->createNamed('text_id', 'text'); | ||
308 | $html = $this->renderWidget($form->createView()); | ||
309 | |||
310 | $this->assertMatchesXpath($html, | ||
311 | '/div | ||
312 | [ | ||
313 | ./input | ||
314 | [@type="text"] | ||
315 | [@id="text_id"] | ||
316 | ] | ||
317 | [@id="container"] | ||
318 | ' | ||
319 | ); | ||
320 | } | ||
321 | |||
322 | public function testCheckedCheckbox() | ||
323 | { | ||
324 | $form = $this->factory->createNamed('name', 'checkbox', true); | ||
325 | |||
326 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
327 | '/input | ||
328 | [@type="checkbox"] | ||
329 | [@name="name"] | ||
330 | [@checked="checked"] | ||
331 | [@value="1"] | ||
332 | ' | ||
333 | ); | ||
334 | } | ||
335 | |||
336 | public function testUncheckedCheckbox() | ||
337 | { | ||
338 | $form = $this->factory->createNamed('name', 'checkbox', false); | ||
339 | |||
340 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
341 | '/input | ||
342 | [@type="checkbox"] | ||
343 | [@name="name"] | ||
344 | [not(@checked)] | ||
345 | ' | ||
346 | ); | ||
347 | } | ||
348 | |||
349 | public function testCheckboxWithValue() | ||
350 | { | ||
351 | $form = $this->factory->createNamed('name', 'checkbox', false, array( | ||
352 | 'value' => 'foo&bar', | ||
353 | )); | ||
354 | |||
355 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
356 | '/input | ||
357 | [@type="checkbox"] | ||
358 | [@name="name"] | ||
359 | [@value="foo&bar"] | ||
360 | ' | ||
361 | ); | ||
362 | } | ||
363 | |||
364 | public function testSingleChoice() | ||
365 | { | ||
366 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
367 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
368 | 'multiple' => false, | ||
369 | 'expanded' => false, | ||
370 | )); | ||
371 | |||
372 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
373 | '/select | ||
374 | [@name="name"] | ||
375 | [@required="required"] | ||
376 | [ | ||
377 | ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
378 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
379 | ] | ||
380 | [count(./option)=2] | ||
381 | ' | ||
382 | ); | ||
383 | } | ||
384 | |||
385 | public function testSingleChoiceWithPreferred() | ||
386 | { | ||
387 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
388 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
389 | 'preferred_choices' => array('&b'), | ||
390 | 'multiple' => false, | ||
391 | 'expanded' => false, | ||
392 | )); | ||
393 | |||
394 | $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '-- sep --'), | ||
395 | '/select | ||
396 | [@name="name"] | ||
397 | [@required="required"] | ||
398 | [ | ||
399 | ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
400 | /following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"] | ||
401 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
402 | ] | ||
403 | [count(./option)=3] | ||
404 | ' | ||
405 | ); | ||
406 | } | ||
407 | |||
408 | public function testSingleChoiceWithPreferredAndNoSeparator() | ||
409 | { | ||
410 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
411 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
412 | 'preferred_choices' => array('&b'), | ||
413 | 'multiple' => false, | ||
414 | 'expanded' => false, | ||
415 | )); | ||
416 | |||
417 | $this->assertWidgetMatchesXpath($form->createView(), array('separator' => null), | ||
418 | '/select | ||
419 | [@name="name"] | ||
420 | [@required="required"] | ||
421 | [ | ||
422 | ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
423 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
424 | ] | ||
425 | [count(./option)=2] | ||
426 | ' | ||
427 | ); | ||
428 | } | ||
429 | |||
430 | public function testSingleChoiceWithPreferredAndBlankSeparator() | ||
431 | { | ||
432 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
433 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
434 | 'preferred_choices' => array('&b'), | ||
435 | 'multiple' => false, | ||
436 | 'expanded' => false, | ||
437 | )); | ||
438 | |||
439 | $this->assertWidgetMatchesXpath($form->createView(), array('separator' => ''), | ||
440 | '/select | ||
441 | [@name="name"] | ||
442 | [@required="required"] | ||
443 | [ | ||
444 | ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
445 | /following-sibling::option[@disabled="disabled"][not(@selected)][.=""] | ||
446 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
447 | ] | ||
448 | [count(./option)=3] | ||
449 | ' | ||
450 | ); | ||
451 | } | ||
452 | |||
453 | public function testChoiceWithOnlyPreferred() | ||
454 | { | ||
455 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
456 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
457 | 'preferred_choices' => array('&a', '&b'), | ||
458 | 'multiple' => false, | ||
459 | 'expanded' => false, | ||
460 | )); | ||
461 | |||
462 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
463 | '/select | ||
464 | [count(./option)=2] | ||
465 | ' | ||
466 | ); | ||
467 | } | ||
468 | |||
469 | public function testSingleChoiceNonRequired() | ||
470 | { | ||
471 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
472 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
473 | 'required' => false, | ||
474 | 'multiple' => false, | ||
475 | 'expanded' => false, | ||
476 | )); | ||
477 | |||
478 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
479 | '/select | ||
480 | [@name="name"] | ||
481 | [not(@required)] | ||
482 | [ | ||
483 | ./option[@value=""][.="[trans][/trans]"] | ||
484 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
485 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
486 | ] | ||
487 | [count(./option)=3] | ||
488 | ' | ||
489 | ); | ||
490 | } | ||
491 | |||
492 | public function testSingleChoiceNonRequiredNoneSelected() | ||
493 | { | ||
494 | $form = $this->factory->createNamed('name', 'choice', null, array( | ||
495 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
496 | 'required' => false, | ||
497 | 'multiple' => false, | ||
498 | 'expanded' => false, | ||
499 | )); | ||
500 | |||
501 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
502 | '/select | ||
503 | [@name="name"] | ||
504 | [not(@required)] | ||
505 | [ | ||
506 | ./option[@value=""][.="[trans][/trans]"] | ||
507 | /following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"] | ||
508 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
509 | ] | ||
510 | [count(./option)=3] | ||
511 | ' | ||
512 | ); | ||
513 | } | ||
514 | |||
515 | public function testSingleChoiceWithNonRequiredEmptyValue() | ||
516 | { | ||
517 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
518 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
519 | 'multiple' => false, | ||
520 | 'expanded' => false, | ||
521 | 'required' => false, | ||
522 | 'empty_value' => 'Select&Anything&Not&Me', | ||
523 | )); | ||
524 | |||
525 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
526 | '/select | ||
527 | [@name="name"] | ||
528 | [not(@required)] | ||
529 | [ | ||
530 | ./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"] | ||
531 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
532 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
533 | ] | ||
534 | [count(./option)=3] | ||
535 | ' | ||
536 | ); | ||
537 | } | ||
538 | |||
539 | public function testSingleChoiceRequiredWithEmptyValue() | ||
540 | { | ||
541 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
542 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
543 | 'required' => true, | ||
544 | 'multiple' => false, | ||
545 | 'expanded' => false, | ||
546 | 'empty_value' => 'Test&Me' | ||
547 | )); | ||
548 | |||
549 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
550 | '/select | ||
551 | [@name="name"] | ||
552 | [@required="required"] | ||
553 | [ | ||
554 | ./option[not(@value)][not(@selected)][@disabled][.="[trans]Test&Me[/trans]"] | ||
555 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
556 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
557 | ] | ||
558 | [count(./option)=3] | ||
559 | ' | ||
560 | ); | ||
561 | } | ||
562 | |||
563 | public function testSingleChoiceRequiredWithEmptyValueViaView() | ||
564 | { | ||
565 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
566 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
567 | 'required' => true, | ||
568 | 'multiple' => false, | ||
569 | 'expanded' => false, | ||
570 | )); | ||
571 | |||
572 | $this->assertWidgetMatchesXpath($form->createView(), array('empty_value' => ''), | ||
573 | '/select | ||
574 | [@name="name"] | ||
575 | [@required="required"] | ||
576 | [ | ||
577 | ./option[not(@value)][not(@selected)][@disabled][.="[trans][/trans]"] | ||
578 | /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
579 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
580 | ] | ||
581 | [count(./option)=3] | ||
582 | ' | ||
583 | ); | ||
584 | } | ||
585 | |||
586 | public function testSingleChoiceGrouped() | ||
587 | { | ||
588 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
589 | 'choices' => array( | ||
590 | 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
591 | 'Group&2' => array('&c' => 'Choice&C'), | ||
592 | ), | ||
593 | 'multiple' => false, | ||
594 | 'expanded' => false, | ||
595 | )); | ||
596 | |||
597 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
598 | '/select | ||
599 | [@name="name"] | ||
600 | [./optgroup[@label="[trans]Group&1[/trans]"] | ||
601 | [ | ||
602 | ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
603 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
604 | ] | ||
605 | [count(./option)=2] | ||
606 | ] | ||
607 | [./optgroup[@label="[trans]Group&2[/trans]"] | ||
608 | [./option[@value="&c"][not(@selected)][.="[trans]Choice&C[/trans]"]] | ||
609 | [count(./option)=1] | ||
610 | ] | ||
611 | [count(./optgroup)=2] | ||
612 | ' | ||
613 | ); | ||
614 | } | ||
615 | |||
616 | public function testMultipleChoice() | ||
617 | { | ||
618 | $form = $this->factory->createNamed('name', 'choice', array('&a'), array( | ||
619 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
620 | 'multiple' => true, | ||
621 | 'expanded' => false, | ||
622 | )); | ||
623 | |||
624 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
625 | '/select | ||
626 | [@name="name[]"] | ||
627 | [@multiple="multiple"] | ||
628 | [ | ||
629 | ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
630 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
631 | ] | ||
632 | [count(./option)=2] | ||
633 | ' | ||
634 | ); | ||
635 | } | ||
636 | |||
637 | public function testMultipleChoiceSkipsEmptyValue() | ||
638 | { | ||
639 | $form = $this->factory->createNamed('name', 'choice', array('&a'), array( | ||
640 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
641 | 'multiple' => true, | ||
642 | 'expanded' => false, | ||
643 | 'empty_value' => 'Test&Me' | ||
644 | )); | ||
645 | |||
646 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
647 | '/select | ||
648 | [@name="name[]"] | ||
649 | [@multiple="multiple"] | ||
650 | [ | ||
651 | ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
652 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
653 | ] | ||
654 | [count(./option)=2] | ||
655 | ' | ||
656 | ); | ||
657 | } | ||
658 | |||
659 | public function testMultipleChoiceNonRequired() | ||
660 | { | ||
661 | $form = $this->factory->createNamed('name', 'choice', array('&a'), array( | ||
662 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
663 | 'required' => false, | ||
664 | 'multiple' => true, | ||
665 | 'expanded' => false, | ||
666 | )); | ||
667 | |||
668 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
669 | '/select | ||
670 | [@name="name[]"] | ||
671 | [@multiple="multiple"] | ||
672 | [ | ||
673 | ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] | ||
674 | /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] | ||
675 | ] | ||
676 | [count(./option)=2] | ||
677 | ' | ||
678 | ); | ||
679 | } | ||
680 | |||
681 | public function testSingleChoiceExpanded() | ||
682 | { | ||
683 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
684 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
685 | 'multiple' => false, | ||
686 | 'expanded' => true, | ||
687 | )); | ||
688 | |||
689 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
690 | '/div | ||
691 | [ | ||
692 | ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] | ||
693 | /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] | ||
694 | /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)] | ||
695 | /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] | ||
696 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
697 | ] | ||
698 | [count(./input)=3] | ||
699 | ' | ||
700 | ); | ||
701 | } | ||
702 | |||
703 | public function testSingleChoiceExpandedWithEmptyValue() | ||
704 | { | ||
705 | $form = $this->factory->createNamed('name', 'choice', '&a', array( | ||
706 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), | ||
707 | 'multiple' => false, | ||
708 | 'expanded' => true, | ||
709 | 'empty_value' => 'Test&Me' | ||
710 | )); | ||
711 | |||
712 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
713 | '/div | ||
714 | [ | ||
715 | ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)] | ||
716 | /following-sibling::label[@for="name_placeholder"][.="[trans]Test&Me[/trans]"] | ||
717 | /following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked] | ||
718 | /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] | ||
719 | /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] | ||
720 | /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] | ||
721 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
722 | ] | ||
723 | [count(./input)=4] | ||
724 | ' | ||
725 | ); | ||
726 | } | ||
727 | |||
728 | public function testSingleChoiceExpandedWithBooleanValue() | ||
729 | { | ||
730 | $form = $this->factory->createNamed('name', 'choice', true, array( | ||
731 | 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), | ||
732 | 'multiple' => false, | ||
733 | 'expanded' => true, | ||
734 | )); | ||
735 | |||
736 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
737 | '/div | ||
738 | [ | ||
739 | ./input[@type="radio"][@name="name"][@id="name_0"][@checked] | ||
740 | /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] | ||
741 | /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] | ||
742 | /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] | ||
743 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
744 | ] | ||
745 | [count(./input)=3] | ||
746 | ' | ||
747 | ); | ||
748 | } | ||
749 | |||
750 | public function testMultipleChoiceExpanded() | ||
751 | { | ||
752 | $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( | ||
753 | 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), | ||
754 | 'multiple' => true, | ||
755 | 'expanded' => true, | ||
756 | 'required' => true, | ||
757 | )); | ||
758 | |||
759 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
760 | '/div | ||
761 | [ | ||
762 | ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] | ||
763 | /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] | ||
764 | /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)] | ||
765 | /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] | ||
766 | /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)] | ||
767 | /following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"] | ||
768 | /following-sibling::input[@type="hidden"][@id="name__token"] | ||
769 | ] | ||
770 | [count(./input)=4] | ||
771 | ' | ||
772 | ); | ||
773 | } | ||
774 | |||
775 | public function testCountry() | ||
776 | { | ||
777 | $form = $this->factory->createNamed('name', 'country', 'AT'); | ||
778 | |||
779 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
780 | '/select | ||
781 | [@name="name"] | ||
782 | [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] | ||
783 | [count(./option)>200] | ||
784 | ' | ||
785 | ); | ||
786 | } | ||
787 | |||
788 | public function testCountryWithEmptyValue() | ||
789 | { | ||
790 | $form = $this->factory->createNamed('name', 'country', 'AT', array( | ||
791 | 'empty_value' => 'Select&Country', | ||
792 | 'required' => false, | ||
793 | )); | ||
794 | |||
795 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
796 | '/select | ||
797 | [@name="name"] | ||
798 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]] | ||
799 | [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] | ||
800 | [count(./option)>201] | ||
801 | ' | ||
802 | ); | ||
803 | } | ||
804 | |||
805 | public function testDateTime() | ||
806 | { | ||
807 | $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( | ||
808 | 'input' => 'string', | ||
809 | 'with_seconds' => false, | ||
810 | )); | ||
811 | |||
812 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
813 | '/div | ||
814 | [ | ||
815 | ./div | ||
816 | [@id="name_date"] | ||
817 | [ | ||
818 | ./select | ||
819 | [@id="name_date_month"] | ||
820 | [./option[@value="2"][@selected="selected"]] | ||
821 | /following-sibling::select | ||
822 | [@id="name_date_day"] | ||
823 | [./option[@value="3"][@selected="selected"]] | ||
824 | /following-sibling::select | ||
825 | [@id="name_date_year"] | ||
826 | [./option[@value="2011"][@selected="selected"]] | ||
827 | ] | ||
828 | /following-sibling::div | ||
829 | [@id="name_time"] | ||
830 | [ | ||
831 | ./select | ||
832 | [@id="name_time_hour"] | ||
833 | [./option[@value="4"][@selected="selected"]] | ||
834 | /following-sibling::select | ||
835 | [@id="name_time_minute"] | ||
836 | [./option[@value="5"][@selected="selected"]] | ||
837 | ] | ||
838 | ] | ||
839 | [count(.//select)=5] | ||
840 | ' | ||
841 | ); | ||
842 | } | ||
843 | |||
844 | public function testDateTimeWithEmptyValueGlobal() | ||
845 | { | ||
846 | $form = $this->factory->createNamed('name', 'datetime', null, array( | ||
847 | 'input' => 'string', | ||
848 | 'empty_value' => 'Change&Me', | ||
849 | 'required' => false, | ||
850 | )); | ||
851 | |||
852 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
853 | '/div | ||
854 | [ | ||
855 | ./div | ||
856 | [@id="name_date"] | ||
857 | [ | ||
858 | ./select | ||
859 | [@id="name_date_month"] | ||
860 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
861 | /following-sibling::select | ||
862 | [@id="name_date_day"] | ||
863 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
864 | /following-sibling::select | ||
865 | [@id="name_date_year"] | ||
866 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
867 | ] | ||
868 | /following-sibling::div | ||
869 | [@id="name_time"] | ||
870 | [ | ||
871 | ./select | ||
872 | [@id="name_time_hour"] | ||
873 | [./option[@value=""][.="[trans]Change&Me[/trans]"]] | ||
874 | /following-sibling::select | ||
875 | [@id="name_time_minute"] | ||
876 | [./option[@value=""][.="[trans]Change&Me[/trans]"]] | ||
877 | ] | ||
878 | ] | ||
879 | [count(.//select)=5] | ||
880 | ' | ||
881 | ); | ||
882 | } | ||
883 | |||
884 | public function testDateTimeWithEmptyValueOnTime() | ||
885 | { | ||
886 | $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '', 'minute' => ''); | ||
887 | |||
888 | $form = $this->factory->createNamed('name', 'datetime', $data, array( | ||
889 | 'input' => 'array', | ||
890 | 'empty_value' => array('hour' => 'Change&Me', 'minute' => 'Change&Me'), | ||
891 | 'required' => false, | ||
892 | )); | ||
893 | |||
894 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
895 | '/div | ||
896 | [ | ||
897 | ./div | ||
898 | [@id="name_date"] | ||
899 | [ | ||
900 | ./select | ||
901 | [@id="name_date_month"] | ||
902 | [./option[@value="2"][@selected="selected"]] | ||
903 | /following-sibling::select | ||
904 | [@id="name_date_day"] | ||
905 | [./option[@value="3"][@selected="selected"]] | ||
906 | /following-sibling::select | ||
907 | [@id="name_date_year"] | ||
908 | [./option[@value="2011"][@selected="selected"]] | ||
909 | ] | ||
910 | /following-sibling::div | ||
911 | [@id="name_time"] | ||
912 | [ | ||
913 | ./select | ||
914 | [@id="name_time_hour"] | ||
915 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
916 | /following-sibling::select | ||
917 | [@id="name_time_minute"] | ||
918 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
919 | ] | ||
920 | ] | ||
921 | [count(.//select)=5] | ||
922 | ' | ||
923 | ); | ||
924 | } | ||
925 | |||
926 | public function testDateTimeWithSeconds() | ||
927 | { | ||
928 | $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( | ||
929 | 'input' => 'string', | ||
930 | 'with_seconds' => true, | ||
931 | )); | ||
932 | |||
933 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
934 | '/div | ||
935 | [ | ||
936 | ./div | ||
937 | [@id="name_date"] | ||
938 | [ | ||
939 | ./select | ||
940 | [@id="name_date_month"] | ||
941 | [./option[@value="2"][@selected="selected"]] | ||
942 | /following-sibling::select | ||
943 | [@id="name_date_day"] | ||
944 | [./option[@value="3"][@selected="selected"]] | ||
945 | /following-sibling::select | ||
946 | [@id="name_date_year"] | ||
947 | [./option[@value="2011"][@selected="selected"]] | ||
948 | ] | ||
949 | /following-sibling::div | ||
950 | [@id="name_time"] | ||
951 | [ | ||
952 | ./select | ||
953 | [@id="name_time_hour"] | ||
954 | [./option[@value="4"][@selected="selected"]] | ||
955 | /following-sibling::select | ||
956 | [@id="name_time_minute"] | ||
957 | [./option[@value="5"][@selected="selected"]] | ||
958 | /following-sibling::select | ||
959 | [@id="name_time_second"] | ||
960 | [./option[@value="6"][@selected="selected"]] | ||
961 | ] | ||
962 | ] | ||
963 | [count(.//select)=6] | ||
964 | ' | ||
965 | ); | ||
966 | } | ||
967 | |||
968 | public function testDateTimeSingleText() | ||
969 | { | ||
970 | $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( | ||
971 | 'input' => 'string', | ||
972 | 'date_widget' => 'single_text', | ||
973 | 'time_widget' => 'single_text', | ||
974 | )); | ||
975 | |||
976 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
977 | '/div | ||
978 | [ | ||
979 | ./input | ||
980 | [@type="date"] | ||
981 | [@id="name_date"] | ||
982 | [@name="name[date]"] | ||
983 | [@value="2011-02-03"] | ||
984 | /following-sibling::input | ||
985 | [@type="time"] | ||
986 | [@id="name_time"] | ||
987 | [@name="name[time]"] | ||
988 | [@value="04:05"] | ||
989 | ] | ||
990 | ' | ||
991 | ); | ||
992 | } | ||
993 | |||
994 | public function testDateTimeWithWidgetSingleText() | ||
995 | { | ||
996 | $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( | ||
997 | 'input' => 'string', | ||
998 | 'widget' => 'single_text', | ||
999 | 'model_timezone' => 'UTC', | ||
1000 | 'view_timezone' => 'UTC', | ||
1001 | )); | ||
1002 | |||
1003 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1004 | '/input | ||
1005 | [@type="datetime"] | ||
1006 | [@name="name"] | ||
1007 | [@value="2011-02-03T04:05:06Z"] | ||
1008 | ' | ||
1009 | ); | ||
1010 | } | ||
1011 | |||
1012 | public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() | ||
1013 | { | ||
1014 | $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( | ||
1015 | 'input' => 'string', | ||
1016 | 'date_widget' => 'choice', | ||
1017 | 'time_widget' => 'choice', | ||
1018 | 'widget' => 'single_text', | ||
1019 | 'model_timezone' => 'UTC', | ||
1020 | 'view_timezone' => 'UTC', | ||
1021 | )); | ||
1022 | |||
1023 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1024 | '/input | ||
1025 | [@type="datetime"] | ||
1026 | [@name="name"] | ||
1027 | [@value="2011-02-03T04:05:06Z"] | ||
1028 | ' | ||
1029 | ); | ||
1030 | } | ||
1031 | |||
1032 | public function testDateChoice() | ||
1033 | { | ||
1034 | $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( | ||
1035 | 'input' => 'string', | ||
1036 | 'widget' => 'choice', | ||
1037 | )); | ||
1038 | |||
1039 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1040 | '/div | ||
1041 | [ | ||
1042 | ./select | ||
1043 | [@id="name_month"] | ||
1044 | [./option[@value="2"][@selected="selected"]] | ||
1045 | /following-sibling::select | ||
1046 | [@id="name_day"] | ||
1047 | [./option[@value="3"][@selected="selected"]] | ||
1048 | /following-sibling::select | ||
1049 | [@id="name_year"] | ||
1050 | [./option[@value="2011"][@selected="selected"]] | ||
1051 | ] | ||
1052 | [count(./select)=3] | ||
1053 | ' | ||
1054 | ); | ||
1055 | } | ||
1056 | |||
1057 | public function testDateChoiceWithEmptyValueGlobal() | ||
1058 | { | ||
1059 | $form = $this->factory->createNamed('name', 'date', null, array( | ||
1060 | 'input' => 'string', | ||
1061 | 'widget' => 'choice', | ||
1062 | 'empty_value' => 'Change&Me', | ||
1063 | 'required' => false, | ||
1064 | )); | ||
1065 | |||
1066 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1067 | '/div | ||
1068 | [ | ||
1069 | ./select | ||
1070 | [@id="name_month"] | ||
1071 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1072 | /following-sibling::select | ||
1073 | [@id="name_day"] | ||
1074 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1075 | /following-sibling::select | ||
1076 | [@id="name_year"] | ||
1077 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1078 | ] | ||
1079 | [count(./select)=3] | ||
1080 | ' | ||
1081 | ); | ||
1082 | } | ||
1083 | |||
1084 | public function testDateChoiceWithEmptyValueOnYear() | ||
1085 | { | ||
1086 | $form = $this->factory->createNamed('name', 'date', null, array( | ||
1087 | 'input' => 'string', | ||
1088 | 'widget' => 'choice', | ||
1089 | 'required' => false, | ||
1090 | 'empty_value' => array('year' => 'Change&Me'), | ||
1091 | )); | ||
1092 | |||
1093 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1094 | '/div | ||
1095 | [ | ||
1096 | ./select | ||
1097 | [@id="name_month"] | ||
1098 | [./option[@value="1"]] | ||
1099 | /following-sibling::select | ||
1100 | [@id="name_day"] | ||
1101 | [./option[@value="1"]] | ||
1102 | /following-sibling::select | ||
1103 | [@id="name_year"] | ||
1104 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1105 | ] | ||
1106 | [count(./select)=3] | ||
1107 | ' | ||
1108 | ); | ||
1109 | } | ||
1110 | |||
1111 | public function testDateText() | ||
1112 | { | ||
1113 | $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( | ||
1114 | 'input' => 'string', | ||
1115 | 'widget' => 'text', | ||
1116 | )); | ||
1117 | |||
1118 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1119 | '/div | ||
1120 | [ | ||
1121 | ./input | ||
1122 | [@id="name_month"] | ||
1123 | [@type="text"] | ||
1124 | [@value="2"] | ||
1125 | /following-sibling::input | ||
1126 | [@id="name_day"] | ||
1127 | [@type="text"] | ||
1128 | [@value="3"] | ||
1129 | /following-sibling::input | ||
1130 | [@id="name_year"] | ||
1131 | [@type="text"] | ||
1132 | [@value="2011"] | ||
1133 | ] | ||
1134 | [count(./input)=3] | ||
1135 | ' | ||
1136 | ); | ||
1137 | } | ||
1138 | |||
1139 | public function testDateSingleText() | ||
1140 | { | ||
1141 | $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( | ||
1142 | 'input' => 'string', | ||
1143 | 'widget' => 'single_text', | ||
1144 | )); | ||
1145 | |||
1146 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1147 | '/input | ||
1148 | [@type="date"] | ||
1149 | [@name="name"] | ||
1150 | [@value="2011-02-03"] | ||
1151 | ' | ||
1152 | ); | ||
1153 | } | ||
1154 | |||
1155 | public function testDateErrorBubbling() | ||
1156 | { | ||
1157 | $form = $this->factory->createNamedBuilder('form', 'form') | ||
1158 | ->add('date', 'date') | ||
1159 | ->getForm(); | ||
1160 | $form->get('date')->addError(new FormError('[trans]Error![/trans]')); | ||
1161 | $view = $form->createView(); | ||
1162 | |||
1163 | $this->assertEmpty($this->renderErrors($view)); | ||
1164 | $this->assertNotEmpty($this->renderErrors($view['date'])); | ||
1165 | } | ||
1166 | |||
1167 | public function testBirthDay() | ||
1168 | { | ||
1169 | $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( | ||
1170 | 'input' => 'string', | ||
1171 | )); | ||
1172 | |||
1173 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1174 | '/div | ||
1175 | [ | ||
1176 | ./select | ||
1177 | [@id="name_month"] | ||
1178 | [./option[@value="2"][@selected="selected"]] | ||
1179 | /following-sibling::select | ||
1180 | [@id="name_day"] | ||
1181 | [./option[@value="3"][@selected="selected"]] | ||
1182 | /following-sibling::select | ||
1183 | [@id="name_year"] | ||
1184 | [./option[@value="2000"][@selected="selected"]] | ||
1185 | ] | ||
1186 | [count(./select)=3] | ||
1187 | ' | ||
1188 | ); | ||
1189 | } | ||
1190 | |||
1191 | public function testBirthDayWithEmptyValue() | ||
1192 | { | ||
1193 | $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( | ||
1194 | 'input' => 'string', | ||
1195 | 'empty_value' => '', | ||
1196 | 'required' => false, | ||
1197 | )); | ||
1198 | |||
1199 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1200 | '/div | ||
1201 | [ | ||
1202 | ./select | ||
1203 | [@id="name_month"] | ||
1204 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] | ||
1205 | [./option[@value="1"][@selected="selected"]] | ||
1206 | /following-sibling::select | ||
1207 | [@id="name_day"] | ||
1208 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] | ||
1209 | [./option[@value="1"][@selected="selected"]] | ||
1210 | /following-sibling::select | ||
1211 | [@id="name_year"] | ||
1212 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] | ||
1213 | [./option[@value="1950"][@selected="selected"]] | ||
1214 | ] | ||
1215 | [count(./select)=3] | ||
1216 | ' | ||
1217 | ); | ||
1218 | } | ||
1219 | |||
1220 | public function testEmail() | ||
1221 | { | ||
1222 | $form = $this->factory->createNamed('name', 'email', 'foo&bar'); | ||
1223 | |||
1224 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1225 | '/input | ||
1226 | [@type="email"] | ||
1227 | [@name="name"] | ||
1228 | [@value="foo&bar"] | ||
1229 | [not(@maxlength)] | ||
1230 | ' | ||
1231 | ); | ||
1232 | } | ||
1233 | |||
1234 | public function testEmailWithMaxLength() | ||
1235 | { | ||
1236 | $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( | ||
1237 | 'max_length' => 123, | ||
1238 | )); | ||
1239 | |||
1240 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1241 | '/input | ||
1242 | [@type="email"] | ||
1243 | [@name="name"] | ||
1244 | [@value="foo&bar"] | ||
1245 | [@maxlength="123"] | ||
1246 | ' | ||
1247 | ); | ||
1248 | } | ||
1249 | |||
1250 | public function testFile() | ||
1251 | { | ||
1252 | $form = $this->factory->createNamed('name', 'file'); | ||
1253 | |||
1254 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1255 | '/input | ||
1256 | [@type="file"] | ||
1257 | ' | ||
1258 | ); | ||
1259 | } | ||
1260 | |||
1261 | public function testHidden() | ||
1262 | { | ||
1263 | $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); | ||
1264 | |||
1265 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1266 | '/input | ||
1267 | [@type="hidden"] | ||
1268 | [@name="name"] | ||
1269 | [@value="foo&bar"] | ||
1270 | ' | ||
1271 | ); | ||
1272 | } | ||
1273 | |||
1274 | public function testReadOnly() | ||
1275 | { | ||
1276 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
1277 | 'read_only' => true, | ||
1278 | )); | ||
1279 | |||
1280 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1281 | '/input | ||
1282 | [@type="text"] | ||
1283 | [@name="name"] | ||
1284 | [@readonly="readonly"] | ||
1285 | ' | ||
1286 | ); | ||
1287 | } | ||
1288 | |||
1289 | public function testDisabled() | ||
1290 | { | ||
1291 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
1292 | 'disabled' => true, | ||
1293 | )); | ||
1294 | |||
1295 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1296 | '/input | ||
1297 | [@type="text"] | ||
1298 | [@name="name"] | ||
1299 | [@disabled="disabled"] | ||
1300 | ' | ||
1301 | ); | ||
1302 | } | ||
1303 | |||
1304 | public function testInteger() | ||
1305 | { | ||
1306 | $form = $this->factory->createNamed('name', 'integer', 123); | ||
1307 | |||
1308 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1309 | '/input | ||
1310 | [@type="number"] | ||
1311 | [@name="name"] | ||
1312 | [@value="123"] | ||
1313 | ' | ||
1314 | ); | ||
1315 | } | ||
1316 | |||
1317 | public function testLanguage() | ||
1318 | { | ||
1319 | $form = $this->factory->createNamed('name', 'language', 'de'); | ||
1320 | |||
1321 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1322 | '/select | ||
1323 | [@name="name"] | ||
1324 | [./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]] | ||
1325 | [count(./option)>200] | ||
1326 | ' | ||
1327 | ); | ||
1328 | } | ||
1329 | |||
1330 | public function testLocale() | ||
1331 | { | ||
1332 | $form = $this->factory->createNamed('name', 'locale', 'de_AT'); | ||
1333 | |||
1334 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1335 | '/select | ||
1336 | [@name="name"] | ||
1337 | [./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]] | ||
1338 | [count(./option)>200] | ||
1339 | ' | ||
1340 | ); | ||
1341 | } | ||
1342 | |||
1343 | public function testMoney() | ||
1344 | { | ||
1345 | $form = $this->factory->createNamed('name', 'money', 1234.56, array( | ||
1346 | 'currency' => 'EUR', | ||
1347 | )); | ||
1348 | |||
1349 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1350 | '/input | ||
1351 | [@type="text"] | ||
1352 | [@name="name"] | ||
1353 | [@value="1234.56"] | ||
1354 | [contains(.., "€")] | ||
1355 | ' | ||
1356 | ); | ||
1357 | } | ||
1358 | |||
1359 | public function testNumber() | ||
1360 | { | ||
1361 | $form = $this->factory->createNamed('name', 'number', 1234.56); | ||
1362 | |||
1363 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1364 | '/input | ||
1365 | [@type="text"] | ||
1366 | [@name="name"] | ||
1367 | [@value="1234.56"] | ||
1368 | ' | ||
1369 | ); | ||
1370 | } | ||
1371 | |||
1372 | public function testPassword() | ||
1373 | { | ||
1374 | $form = $this->factory->createNamed('name', 'password', 'foo&bar'); | ||
1375 | |||
1376 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1377 | '/input | ||
1378 | [@type="password"] | ||
1379 | [@name="name"] | ||
1380 | ' | ||
1381 | ); | ||
1382 | } | ||
1383 | |||
1384 | public function testPasswordSubmittedWithNotAlwaysEmpty() | ||
1385 | { | ||
1386 | $form = $this->factory->createNamed('name', 'password', null, array( | ||
1387 | 'always_empty' => false, | ||
1388 | )); | ||
1389 | $form->submit('foo&bar'); | ||
1390 | |||
1391 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1392 | '/input | ||
1393 | [@type="password"] | ||
1394 | [@name="name"] | ||
1395 | [@value="foo&bar"] | ||
1396 | ' | ||
1397 | ); | ||
1398 | } | ||
1399 | |||
1400 | public function testPasswordWithMaxLength() | ||
1401 | { | ||
1402 | $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( | ||
1403 | 'max_length' => 123, | ||
1404 | )); | ||
1405 | |||
1406 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1407 | '/input | ||
1408 | [@type="password"] | ||
1409 | [@name="name"] | ||
1410 | [@maxlength="123"] | ||
1411 | ' | ||
1412 | ); | ||
1413 | } | ||
1414 | |||
1415 | public function testPercent() | ||
1416 | { | ||
1417 | $form = $this->factory->createNamed('name', 'percent', 0.1); | ||
1418 | |||
1419 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1420 | '/input | ||
1421 | [@type="text"] | ||
1422 | [@name="name"] | ||
1423 | [@value="10"] | ||
1424 | [contains(.., "%")] | ||
1425 | ' | ||
1426 | ); | ||
1427 | } | ||
1428 | |||
1429 | public function testCheckedRadio() | ||
1430 | { | ||
1431 | $form = $this->factory->createNamed('name', 'radio', true); | ||
1432 | |||
1433 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1434 | '/input | ||
1435 | [@type="radio"] | ||
1436 | [@name="name"] | ||
1437 | [@checked="checked"] | ||
1438 | [@value="1"] | ||
1439 | ' | ||
1440 | ); | ||
1441 | } | ||
1442 | |||
1443 | public function testUncheckedRadio() | ||
1444 | { | ||
1445 | $form = $this->factory->createNamed('name', 'radio', false); | ||
1446 | |||
1447 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1448 | '/input | ||
1449 | [@type="radio"] | ||
1450 | [@name="name"] | ||
1451 | [not(@checked)] | ||
1452 | ' | ||
1453 | ); | ||
1454 | } | ||
1455 | |||
1456 | public function testRadioWithValue() | ||
1457 | { | ||
1458 | $form = $this->factory->createNamed('name', 'radio', false, array( | ||
1459 | 'value' => 'foo&bar', | ||
1460 | )); | ||
1461 | |||
1462 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1463 | '/input | ||
1464 | [@type="radio"] | ||
1465 | [@name="name"] | ||
1466 | [@value="foo&bar"] | ||
1467 | ' | ||
1468 | ); | ||
1469 | } | ||
1470 | |||
1471 | public function testTextarea() | ||
1472 | { | ||
1473 | $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( | ||
1474 | 'pattern' => 'foo', | ||
1475 | )); | ||
1476 | |||
1477 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1478 | '/textarea | ||
1479 | [@name="name"] | ||
1480 | [not(@pattern)] | ||
1481 | [.="foo&bar"] | ||
1482 | ' | ||
1483 | ); | ||
1484 | } | ||
1485 | |||
1486 | public function testText() | ||
1487 | { | ||
1488 | $form = $this->factory->createNamed('name', 'text', 'foo&bar'); | ||
1489 | |||
1490 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1491 | '/input | ||
1492 | [@type="text"] | ||
1493 | [@name="name"] | ||
1494 | [@value="foo&bar"] | ||
1495 | [not(@maxlength)] | ||
1496 | ' | ||
1497 | ); | ||
1498 | } | ||
1499 | |||
1500 | public function testTextWithMaxLength() | ||
1501 | { | ||
1502 | $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( | ||
1503 | 'max_length' => 123, | ||
1504 | )); | ||
1505 | |||
1506 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1507 | '/input | ||
1508 | [@type="text"] | ||
1509 | [@name="name"] | ||
1510 | [@value="foo&bar"] | ||
1511 | [@maxlength="123"] | ||
1512 | ' | ||
1513 | ); | ||
1514 | } | ||
1515 | |||
1516 | public function testSearch() | ||
1517 | { | ||
1518 | $form = $this->factory->createNamed('name', 'search', 'foo&bar'); | ||
1519 | |||
1520 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1521 | '/input | ||
1522 | [@type="search"] | ||
1523 | [@name="name"] | ||
1524 | [@value="foo&bar"] | ||
1525 | [not(@maxlength)] | ||
1526 | ' | ||
1527 | ); | ||
1528 | } | ||
1529 | |||
1530 | public function testTime() | ||
1531 | { | ||
1532 | $form = $this->factory->createNamed('name', 'time', '04:05:06', array( | ||
1533 | 'input' => 'string', | ||
1534 | 'with_seconds' => false, | ||
1535 | )); | ||
1536 | |||
1537 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1538 | '/div | ||
1539 | [ | ||
1540 | ./select | ||
1541 | [@id="name_hour"] | ||
1542 | [not(@size)] | ||
1543 | [./option[@value="4"][@selected="selected"]] | ||
1544 | /following-sibling::select | ||
1545 | [@id="name_minute"] | ||
1546 | [not(@size)] | ||
1547 | [./option[@value="5"][@selected="selected"]] | ||
1548 | ] | ||
1549 | [count(./select)=2] | ||
1550 | ' | ||
1551 | ); | ||
1552 | } | ||
1553 | |||
1554 | public function testTimeWithSeconds() | ||
1555 | { | ||
1556 | $form = $this->factory->createNamed('name', 'time', '04:05:06', array( | ||
1557 | 'input' => 'string', | ||
1558 | 'with_seconds' => true, | ||
1559 | )); | ||
1560 | |||
1561 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1562 | '/div | ||
1563 | [ | ||
1564 | ./select | ||
1565 | [@id="name_hour"] | ||
1566 | [not(@size)] | ||
1567 | [./option[@value="4"][@selected="selected"]] | ||
1568 | [count(./option)>23] | ||
1569 | /following-sibling::select | ||
1570 | [@id="name_minute"] | ||
1571 | [not(@size)] | ||
1572 | [./option[@value="5"][@selected="selected"]] | ||
1573 | [count(./option)>59] | ||
1574 | /following-sibling::select | ||
1575 | [@id="name_second"] | ||
1576 | [not(@size)] | ||
1577 | [./option[@value="6"][@selected="selected"]] | ||
1578 | [count(./option)>59] | ||
1579 | ] | ||
1580 | [count(./select)=3] | ||
1581 | ' | ||
1582 | ); | ||
1583 | } | ||
1584 | |||
1585 | public function testTimeText() | ||
1586 | { | ||
1587 | $form = $this->factory->createNamed('name', 'time', '04:05:06', array( | ||
1588 | 'input' => 'string', | ||
1589 | 'widget' => 'text', | ||
1590 | )); | ||
1591 | |||
1592 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1593 | '/div | ||
1594 | [ | ||
1595 | ./input | ||
1596 | [@type="text"] | ||
1597 | [@id="name_hour"] | ||
1598 | [@name="name[hour]"] | ||
1599 | [@value="04"] | ||
1600 | [@size="1"] | ||
1601 | [@required="required"] | ||
1602 | /following-sibling::input | ||
1603 | [@type="text"] | ||
1604 | [@id="name_minute"] | ||
1605 | [@name="name[minute]"] | ||
1606 | [@value="05"] | ||
1607 | [@size="1"] | ||
1608 | [@required="required"] | ||
1609 | ] | ||
1610 | [count(./input)=2] | ||
1611 | ' | ||
1612 | ); | ||
1613 | } | ||
1614 | |||
1615 | public function testTimeSingleText() | ||
1616 | { | ||
1617 | $form = $this->factory->createNamed('name', 'time', '04:05:06', array( | ||
1618 | 'input' => 'string', | ||
1619 | 'widget' => 'single_text', | ||
1620 | )); | ||
1621 | |||
1622 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1623 | '/input | ||
1624 | [@type="time"] | ||
1625 | [@name="name"] | ||
1626 | [@value="04:05"] | ||
1627 | [not(@size)] | ||
1628 | ' | ||
1629 | ); | ||
1630 | } | ||
1631 | |||
1632 | public function testTimeWithEmptyValueGlobal() | ||
1633 | { | ||
1634 | $form = $this->factory->createNamed('name', 'time', null, array( | ||
1635 | 'input' => 'string', | ||
1636 | 'empty_value' => 'Change&Me', | ||
1637 | 'required' => false, | ||
1638 | )); | ||
1639 | |||
1640 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1641 | '/div | ||
1642 | [ | ||
1643 | ./select | ||
1644 | [@id="name_hour"] | ||
1645 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1646 | [count(./option)>24] | ||
1647 | /following-sibling::select | ||
1648 | [@id="name_minute"] | ||
1649 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1650 | [count(./option)>60] | ||
1651 | ] | ||
1652 | [count(./select)=2] | ||
1653 | ' | ||
1654 | ); | ||
1655 | } | ||
1656 | |||
1657 | public function testTimeWithEmptyValueOnYear() | ||
1658 | { | ||
1659 | $form = $this->factory->createNamed('name', 'time', null, array( | ||
1660 | 'input' => 'string', | ||
1661 | 'required' => false, | ||
1662 | 'empty_value' => array('hour' => 'Change&Me'), | ||
1663 | )); | ||
1664 | |||
1665 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1666 | '/div | ||
1667 | [ | ||
1668 | ./select | ||
1669 | [@id="name_hour"] | ||
1670 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] | ||
1671 | [count(./option)>24] | ||
1672 | /following-sibling::select | ||
1673 | [@id="name_minute"] | ||
1674 | [./option[@value="1"]] | ||
1675 | [count(./option)>59] | ||
1676 | ] | ||
1677 | [count(./select)=2] | ||
1678 | ' | ||
1679 | ); | ||
1680 | } | ||
1681 | |||
1682 | public function testTimeErrorBubbling() | ||
1683 | { | ||
1684 | $form = $this->factory->createNamedBuilder('form', 'form') | ||
1685 | ->add('time', 'time') | ||
1686 | ->getForm(); | ||
1687 | $form->get('time')->addError(new FormError('[trans]Error![/trans]')); | ||
1688 | $view = $form->createView(); | ||
1689 | |||
1690 | $this->assertEmpty($this->renderErrors($view)); | ||
1691 | $this->assertNotEmpty($this->renderErrors($view['time'])); | ||
1692 | } | ||
1693 | |||
1694 | public function testTimezone() | ||
1695 | { | ||
1696 | $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); | ||
1697 | |||
1698 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1699 | '/select | ||
1700 | [@name="name"] | ||
1701 | [@required="required"] | ||
1702 | [./optgroup | ||
1703 | [@label="[trans]Europe[/trans]"] | ||
1704 | [./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]] | ||
1705 | ] | ||
1706 | [count(./optgroup)>10] | ||
1707 | [count(.//option)>200] | ||
1708 | ' | ||
1709 | ); | ||
1710 | } | ||
1711 | |||
1712 | public function testTimezoneWithEmptyValue() | ||
1713 | { | ||
1714 | $form = $this->factory->createNamed('name', 'timezone', null, array( | ||
1715 | 'empty_value' => 'Select&Timezone', | ||
1716 | 'required' => false, | ||
1717 | )); | ||
1718 | |||
1719 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1720 | '/select | ||
1721 | [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] | ||
1722 | [count(./optgroup)>10] | ||
1723 | [count(.//option)>201] | ||
1724 | ' | ||
1725 | ); | ||
1726 | } | ||
1727 | |||
1728 | public function testUrl() | ||
1729 | { | ||
1730 | $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; | ||
1731 | $form = $this->factory->createNamed('name', 'url', $url); | ||
1732 | |||
1733 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1734 | '/input | ||
1735 | [@type="url"] | ||
1736 | [@name="name"] | ||
1737 | [@value="http://www.google.com?foo1=bar1&foo2=bar2"] | ||
1738 | ' | ||
1739 | ); | ||
1740 | } | ||
1741 | |||
1742 | public function testCollectionPrototype() | ||
1743 | { | ||
1744 | $form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three'))) | ||
1745 | ->add('items', 'collection', array('allow_add' => true)) | ||
1746 | ->getForm() | ||
1747 | ->createView(); | ||
1748 | |||
1749 | $html = $this->renderWidget($form); | ||
1750 | |||
1751 | $this->assertMatchesXpath($html, | ||
1752 | '//div[@id="name_items"][@data-prototype] | ||
1753 | | | ||
1754 | //table[@id="name_items"][@data-prototype]' | ||
1755 | ); | ||
1756 | } | ||
1757 | |||
1758 | public function testEmptyRootFormName() | ||
1759 | { | ||
1760 | $form = $this->factory->createNamedBuilder('', 'form') | ||
1761 | ->add('child', 'text') | ||
1762 | ->getForm(); | ||
1763 | |||
1764 | $this->assertMatchesXpath($this->renderWidget($form->createView()), | ||
1765 | '//input[@type="hidden"][@id="_token"][@name="_token"] | ||
1766 | | | ||
1767 | //input[@type="text"][@id="child"][@name="child"]' | ||
1768 | , 2); | ||
1769 | } | ||
1770 | |||
1771 | public function testButton() | ||
1772 | { | ||
1773 | $form = $this->factory->createNamed('name', 'button'); | ||
1774 | |||
1775 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1776 | '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]' | ||
1777 | ); | ||
1778 | } | ||
1779 | |||
1780 | public function testButtonLabelIsEmpty() | ||
1781 | { | ||
1782 | $form = $this->factory->createNamed('name', 'button'); | ||
1783 | |||
1784 | $this->assertSame('', $this->renderLabel($form->createView())); | ||
1785 | } | ||
1786 | |||
1787 | public function testSubmit() | ||
1788 | { | ||
1789 | $form = $this->factory->createNamed('name', 'submit'); | ||
1790 | |||
1791 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1792 | '/button[@type="submit"][@name="name"]' | ||
1793 | ); | ||
1794 | } | ||
1795 | |||
1796 | public function testReset() | ||
1797 | { | ||
1798 | $form = $this->factory->createNamed('name', 'reset'); | ||
1799 | |||
1800 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
1801 | '/button[@type="reset"][@name="name"]' | ||
1802 | ); | ||
1803 | } | ||
1804 | |||
1805 | public function testStartTag() | ||
1806 | { | ||
1807 | $form = $this->factory->create('form', null, array( | ||
1808 | 'method' => 'get', | ||
1809 | 'action' => 'http://example.com/directory' | ||
1810 | )); | ||
1811 | |||
1812 | $html = $this->renderStart($form->createView()); | ||
1813 | |||
1814 | $this->assertSame('<form method="get" action="http://example.com/directory">', $html); | ||
1815 | } | ||
1816 | |||
1817 | public function testStartTagForPutRequest() | ||
1818 | { | ||
1819 | $form = $this->factory->create('form', null, array( | ||
1820 | 'method' => 'put', | ||
1821 | 'action' => 'http://example.com/directory' | ||
1822 | )); | ||
1823 | |||
1824 | $html = $this->renderStart($form->createView()); | ||
1825 | |||
1826 | $this->assertMatchesXpath($html . '</form>', | ||
1827 | '/form | ||
1828 | [./input[@type="hidden"][@name="_method"][@value="PUT"]] | ||
1829 | [@method="post"] | ||
1830 | [@action="http://example.com/directory"]' | ||
1831 | ); | ||
1832 | } | ||
1833 | |||
1834 | public function testStartTagWithOverriddenVars() | ||
1835 | { | ||
1836 | $form = $this->factory->create('form', null, array( | ||
1837 | 'method' => 'put', | ||
1838 | 'action' => 'http://example.com/directory', | ||
1839 | )); | ||
1840 | |||
1841 | $html = $this->renderStart($form->createView(), array( | ||
1842 | 'method' => 'post', | ||
1843 | 'action' => 'http://foo.com/directory' | ||
1844 | )); | ||
1845 | |||
1846 | $this->assertSame('<form method="post" action="http://foo.com/directory">', $html); | ||
1847 | } | ||
1848 | |||
1849 | public function testStartTagForMultipartForm() | ||
1850 | { | ||
1851 | $form = $this->factory->createBuilder('form', null, array( | ||
1852 | 'method' => 'get', | ||
1853 | 'action' => 'http://example.com/directory' | ||
1854 | )) | ||
1855 | ->add('file', 'file') | ||
1856 | ->getForm(); | ||
1857 | |||
1858 | $html = $this->renderStart($form->createView()); | ||
1859 | |||
1860 | $this->assertSame('<form method="get" action="http://example.com/directory" enctype="multipart/form-data">', $html); | ||
1861 | } | ||
1862 | |||
1863 | public function testStartTagWithExtraAttributes() | ||
1864 | { | ||
1865 | $form = $this->factory->create('form', null, array( | ||
1866 | 'method' => 'get', | ||
1867 | 'action' => 'http://example.com/directory' | ||
1868 | )); | ||
1869 | |||
1870 | $html = $this->renderStart($form->createView(), array( | ||
1871 | 'attr' => array('class' => 'foobar'), | ||
1872 | )); | ||
1873 | |||
1874 | $this->assertSame('<form method="get" action="http://example.com/directory" class="foobar">', $html); | ||
1875 | } | ||
1876 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php deleted file mode 100644 index cef8f3bf..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | /** | ||
20 | * @var \Symfony\Component\Form\RequestHandlerInterface | ||
21 | */ | ||
22 | protected $requestHandler; | ||
23 | |||
24 | protected $request; | ||
25 | |||
26 | protected function setUp() | ||
27 | { | ||
28 | $this->requestHandler = $this->getRequestHandler(); | ||
29 | $this->request = null; | ||
30 | } | ||
31 | |||
32 | public function methodExceptGetProvider() | ||
33 | { | ||
34 | return array( | ||
35 | array('POST'), | ||
36 | array('PUT'), | ||
37 | array('DELETE'), | ||
38 | array('PATCH'), | ||
39 | ); | ||
40 | } | ||
41 | |||
42 | public function methodProvider() | ||
43 | { | ||
44 | return array_merge(array( | ||
45 | array('GET'), | ||
46 | ), $this->methodExceptGetProvider()); | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @dataProvider methodProvider | ||
51 | */ | ||
52 | public function testSubmitIfNameInRequest($method) | ||
53 | { | ||
54 | $form = $this->getMockForm('param1', $method); | ||
55 | |||
56 | $this->setRequestData($method, array( | ||
57 | 'param1' => 'DATA', | ||
58 | )); | ||
59 | |||
60 | $form->expects($this->once()) | ||
61 | ->method('submit') | ||
62 | ->with('DATA', 'PATCH' !== $method); | ||
63 | |||
64 | $this->requestHandler->handleRequest($form, $this->request); | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * @dataProvider methodProvider | ||
69 | */ | ||
70 | public function testDoNotSubmitIfWrongRequestMethod($method) | ||
71 | { | ||
72 | $form = $this->getMockForm('param1', $method); | ||
73 | |||
74 | $otherMethod = 'POST' === $method ? 'PUT' : 'POST'; | ||
75 | |||
76 | $this->setRequestData($otherMethod, array( | ||
77 | 'param1' => 'DATA', | ||
78 | )); | ||
79 | |||
80 | $form->expects($this->never()) | ||
81 | ->method('submit'); | ||
82 | |||
83 | $this->requestHandler->handleRequest($form, $this->request); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * @dataProvider methodExceptGetProvider | ||
88 | */ | ||
89 | public function testSubmitSimpleFormWithNullIfNameNotInRequestAndNotGetRequest($method) | ||
90 | { | ||
91 | $form = $this->getMockForm('param1', $method, false); | ||
92 | |||
93 | $this->setRequestData($method, array( | ||
94 | 'paramx' => array(), | ||
95 | )); | ||
96 | |||
97 | $form->expects($this->once()) | ||
98 | ->method('submit') | ||
99 | ->with($this->identicalTo(null), 'PATCH' !== $method); | ||
100 | |||
101 | $this->requestHandler->handleRequest($form, $this->request); | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * @dataProvider methodExceptGetProvider | ||
106 | */ | ||
107 | public function testSubmitCompoundFormWithArrayIfNameNotInRequestAndNotGetRequest($method) | ||
108 | { | ||
109 | $form = $this->getMockForm('param1', $method, true); | ||
110 | |||
111 | $this->setRequestData($method, array( | ||
112 | 'paramx' => array(), | ||
113 | )); | ||
114 | |||
115 | $form->expects($this->once()) | ||
116 | ->method('submit') | ||
117 | ->with($this->identicalTo(array()), 'PATCH' !== $method); | ||
118 | |||
119 | $this->requestHandler->handleRequest($form, $this->request); | ||
120 | } | ||
121 | |||
122 | public function testDoNotSubmitIfNameNotInRequestAndGetRequest() | ||
123 | { | ||
124 | $form = $this->getMockForm('param1', 'GET'); | ||
125 | |||
126 | $this->setRequestData('GET', array( | ||
127 | 'paramx' => array(), | ||
128 | )); | ||
129 | |||
130 | $form->expects($this->never()) | ||
131 | ->method('submit'); | ||
132 | |||
133 | $this->requestHandler->handleRequest($form, $this->request); | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * @dataProvider methodProvider | ||
138 | */ | ||
139 | public function testSubmitFormWithEmptyNameIfAtLeastOneFieldInRequest($method) | ||
140 | { | ||
141 | $form = $this->getMockForm('', $method); | ||
142 | $form->expects($this->any()) | ||
143 | ->method('all') | ||
144 | ->will($this->returnValue(array( | ||
145 | 'param1' => $this->getMockForm('param1'), | ||
146 | 'param2' => $this->getMockForm('param2'), | ||
147 | ))); | ||
148 | |||
149 | $this->setRequestData($method, $requestData = array( | ||
150 | 'param1' => 'submitted value', | ||
151 | 'paramx' => 'submitted value', | ||
152 | )); | ||
153 | |||
154 | $form->expects($this->once()) | ||
155 | ->method('submit') | ||
156 | ->with($requestData, 'PATCH' !== $method); | ||
157 | |||
158 | $this->requestHandler->handleRequest($form, $this->request); | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * @dataProvider methodProvider | ||
163 | */ | ||
164 | public function testDoNotSubmitFormWithEmptyNameIfNoFieldInRequest($method) | ||
165 | { | ||
166 | $form = $this->getMockForm('', $method); | ||
167 | $form->expects($this->any()) | ||
168 | ->method('all') | ||
169 | ->will($this->returnValue(array( | ||
170 | 'param1' => $this->getMockForm('param1'), | ||
171 | 'param2' => $this->getMockForm('param2'), | ||
172 | ))); | ||
173 | |||
174 | $this->setRequestData($method, array( | ||
175 | 'paramx' => 'submitted value', | ||
176 | )); | ||
177 | |||
178 | $form->expects($this->never()) | ||
179 | ->method('submit'); | ||
180 | |||
181 | $this->requestHandler->handleRequest($form, $this->request); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * @dataProvider methodExceptGetProvider | ||
186 | */ | ||
187 | public function testMergeParamsAndFiles($method) | ||
188 | { | ||
189 | $form = $this->getMockForm('param1', $method); | ||
190 | $file = $this->getMockFile(); | ||
191 | |||
192 | $this->setRequestData($method, array( | ||
193 | 'param1' => array( | ||
194 | 'field1' => 'DATA', | ||
195 | ), | ||
196 | ), array( | ||
197 | 'param1' => array( | ||
198 | 'field2' => $file, | ||
199 | ), | ||
200 | )); | ||
201 | |||
202 | $form->expects($this->once()) | ||
203 | ->method('submit') | ||
204 | ->with(array( | ||
205 | 'field1' => 'DATA', | ||
206 | 'field2' => $file, | ||
207 | ), 'PATCH' !== $method); | ||
208 | |||
209 | $this->requestHandler->handleRequest($form, $this->request); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * @dataProvider methodExceptGetProvider | ||
214 | */ | ||
215 | public function testParamTakesPrecedenceOverFile($method) | ||
216 | { | ||
217 | $form = $this->getMockForm('param1', $method); | ||
218 | $file = $this->getMockFile(); | ||
219 | |||
220 | $this->setRequestData($method, array( | ||
221 | 'param1' => 'DATA', | ||
222 | ), array( | ||
223 | 'param1' => $file, | ||
224 | )); | ||
225 | |||
226 | $form->expects($this->once()) | ||
227 | ->method('submit') | ||
228 | ->with('DATA', 'PATCH' !== $method); | ||
229 | |||
230 | $this->requestHandler->handleRequest($form, $this->request); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * @dataProvider methodExceptGetProvider | ||
235 | */ | ||
236 | public function testSubmitFileIfNoParam($method) | ||
237 | { | ||
238 | $form = $this->getMockForm('param1', $method); | ||
239 | $file = $this->getMockFile(); | ||
240 | |||
241 | $this->setRequestData($method, array( | ||
242 | 'param1' => null, | ||
243 | ), array( | ||
244 | 'param1' => $file, | ||
245 | )); | ||
246 | |||
247 | $form->expects($this->once()) | ||
248 | ->method('submit') | ||
249 | ->with($file, 'PATCH' !== $method); | ||
250 | |||
251 | $this->requestHandler->handleRequest($form, $this->request); | ||
252 | } | ||
253 | |||
254 | abstract protected function setRequestData($method, $data, $files = array()); | ||
255 | |||
256 | abstract protected function getRequestHandler(); | ||
257 | |||
258 | abstract protected function getMockFile(); | ||
259 | |||
260 | protected function getMockForm($name, $method = null, $compound = true) | ||
261 | { | ||
262 | $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); | ||
263 | $config->expects($this->any()) | ||
264 | ->method('getMethod') | ||
265 | ->will($this->returnValue($method)); | ||
266 | $config->expects($this->any()) | ||
267 | ->method('getCompound') | ||
268 | ->will($this->returnValue($compound)); | ||
269 | |||
270 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
271 | $form->expects($this->any()) | ||
272 | ->method('getName') | ||
273 | ->will($this->returnValue($name)); | ||
274 | $form->expects($this->any()) | ||
275 | ->method('getConfig') | ||
276 | ->will($this->returnValue($config)); | ||
277 | |||
278 | return $form; | ||
279 | } | ||
280 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php deleted file mode 100644 index 5c911951..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ /dev/null | |||
@@ -1,509 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormError; | ||
15 | |||
16 | abstract class AbstractTableLayoutTest extends AbstractLayoutTest | ||
17 | { | ||
18 | public function testRow() | ||
19 | { | ||
20 | $form = $this->factory->createNamed('name', 'text'); | ||
21 | $form->addError(new FormError('[trans]Error![/trans]')); | ||
22 | $view = $form->createView(); | ||
23 | $html = $this->renderRow($view); | ||
24 | |||
25 | $this->assertMatchesXpath($html, | ||
26 | '/tr | ||
27 | [ | ||
28 | ./td | ||
29 | [./label[@for="name"]] | ||
30 | /following-sibling::td | ||
31 | [ | ||
32 | ./ul | ||
33 | [./li[.="[trans]Error![/trans]"]] | ||
34 | [count(./li)=1] | ||
35 | /following-sibling::input[@id="name"] | ||
36 | ] | ||
37 | ] | ||
38 | ' | ||
39 | ); | ||
40 | } | ||
41 | |||
42 | public function testLabelIsNotRenderedWhenSetToFalse() | ||
43 | { | ||
44 | $form = $this->factory->createNamed('name', 'text', null, array( | ||
45 | 'label' => false | ||
46 | )); | ||
47 | $html = $this->renderRow($form->createView()); | ||
48 | |||
49 | $this->assertMatchesXpath($html, | ||
50 | '/tr | ||
51 | [ | ||
52 | ./td | ||
53 | [count(//label)=0] | ||
54 | /following-sibling::td | ||
55 | [./input[@id="name"]] | ||
56 | ] | ||
57 | ' | ||
58 | ); | ||
59 | } | ||
60 | |||
61 | public function testRepeatedRow() | ||
62 | { | ||
63 | $form = $this->factory->createNamed('name', 'repeated'); | ||
64 | $html = $this->renderRow($form->createView()); | ||
65 | |||
66 | $this->assertMatchesXpath($html, | ||
67 | '/tr | ||
68 | [ | ||
69 | ./td | ||
70 | [./label[@for="name_first"]] | ||
71 | /following-sibling::td | ||
72 | [./input[@id="name_first"]] | ||
73 | ] | ||
74 | /following-sibling::tr | ||
75 | [ | ||
76 | ./td | ||
77 | [./label[@for="name_second"]] | ||
78 | /following-sibling::td | ||
79 | [./input[@id="name_second"]] | ||
80 | ] | ||
81 | /following-sibling::tr[@style="display: none"] | ||
82 | [./td[@colspan="2"]/input | ||
83 | [@type="hidden"] | ||
84 | [@id="name__token"] | ||
85 | ] | ||
86 | [count(../tr)=3] | ||
87 | ' | ||
88 | ); | ||
89 | } | ||
90 | |||
91 | public function testRepeatedRowWithErrors() | ||
92 | { | ||
93 | $form = $this->factory->createNamed('name', 'repeated'); | ||
94 | $form->addError(new FormError('[trans]Error![/trans]')); | ||
95 | $view = $form->createView(); | ||
96 | $html = $this->renderRow($view); | ||
97 | |||
98 | // The errors of the form are not rendered by intention! | ||
99 | // In practice, repeated fields cannot have errors as all errors | ||
100 | // on them are mapped to the first child. | ||
101 | // (see RepeatedTypeValidatorExtension) | ||
102 | |||
103 | $this->assertMatchesXpath($html, | ||
104 | '/tr | ||
105 | [ | ||
106 | ./td | ||
107 | [./label[@for="name_first"]] | ||
108 | /following-sibling::td | ||
109 | [./input[@id="name_first"]] | ||
110 | ] | ||
111 | /following-sibling::tr | ||
112 | [ | ||
113 | ./td | ||
114 | [./label[@for="name_second"]] | ||
115 | /following-sibling::td | ||
116 | [./input[@id="name_second"]] | ||
117 | ] | ||
118 | /following-sibling::tr[@style="display: none"] | ||
119 | [./td[@colspan="2"]/input | ||
120 | [@type="hidden"] | ||
121 | [@id="name__token"] | ||
122 | ] | ||
123 | [count(../tr)=3] | ||
124 | ' | ||
125 | ); | ||
126 | } | ||
127 | |||
128 | public function testButtonRow() | ||
129 | { | ||
130 | $form = $this->factory->createNamed('name', 'button'); | ||
131 | $view = $form->createView(); | ||
132 | $html = $this->renderRow($view); | ||
133 | |||
134 | $this->assertMatchesXpath($html, | ||
135 | '/tr | ||
136 | [ | ||
137 | ./td | ||
138 | [.=""] | ||
139 | /following-sibling::td | ||
140 | [./button[@type="button"][@name="name"]] | ||
141 | ] | ||
142 | [count(//label)=0] | ||
143 | ' | ||
144 | ); | ||
145 | } | ||
146 | |||
147 | public function testRest() | ||
148 | { | ||
149 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
150 | ->add('field1', 'text') | ||
151 | ->add('field2', 'repeated') | ||
152 | ->add('field3', 'text') | ||
153 | ->add('field4', 'text') | ||
154 | ->getForm() | ||
155 | ->createView(); | ||
156 | |||
157 | // Render field2 row -> does not implicitly call renderWidget because | ||
158 | // it is a repeated field! | ||
159 | $this->renderRow($view['field2']); | ||
160 | |||
161 | // Render field3 widget | ||
162 | $this->renderWidget($view['field3']); | ||
163 | |||
164 | // Rest should only contain field1 and field4 | ||
165 | $html = $this->renderRest($view); | ||
166 | |||
167 | $this->assertMatchesXpath($html, | ||
168 | '/tr | ||
169 | [ | ||
170 | ./td | ||
171 | [./label[@for="name_field1"]] | ||
172 | /following-sibling::td | ||
173 | [./input[@id="name_field1"]] | ||
174 | ] | ||
175 | /following-sibling::tr | ||
176 | [ | ||
177 | ./td | ||
178 | [./label[@for="name_field4"]] | ||
179 | /following-sibling::td | ||
180 | [./input[@id="name_field4"]] | ||
181 | ] | ||
182 | [count(../tr)=3] | ||
183 | [count(..//label)=2] | ||
184 | [count(..//input)=3] | ||
185 | /following-sibling::tr[@style="display: none"] | ||
186 | [./td[@colspan="2"]/input | ||
187 | [@type="hidden"] | ||
188 | [@id="name__token"] | ||
189 | ] | ||
190 | ' | ||
191 | ); | ||
192 | } | ||
193 | |||
194 | public function testCollection() | ||
195 | { | ||
196 | $form = $this->factory->createNamed('name', 'collection', array('a', 'b'), array( | ||
197 | 'type' => 'text', | ||
198 | )); | ||
199 | |||
200 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
201 | '/table | ||
202 | [ | ||
203 | ./tr[./td/input[@type="text"][@value="a"]] | ||
204 | /following-sibling::tr[./td/input[@type="text"][@value="b"]] | ||
205 | /following-sibling::tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="name__token"]] | ||
206 | ] | ||
207 | [count(./tr[./td/input])=3] | ||
208 | ' | ||
209 | ); | ||
210 | } | ||
211 | |||
212 | public function testEmptyCollection() | ||
213 | { | ||
214 | $form = $this->factory->createNamed('name', 'collection', array(), array( | ||
215 | 'type' => 'text', | ||
216 | )); | ||
217 | |||
218 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
219 | '/table | ||
220 | [./tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="name__token"]]] | ||
221 | [count(./tr[./td/input])=1] | ||
222 | ' | ||
223 | ); | ||
224 | } | ||
225 | |||
226 | public function testForm() | ||
227 | { | ||
228 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
229 | ->setMethod('PUT') | ||
230 | ->setAction('http://example.com') | ||
231 | ->add('firstName', 'text') | ||
232 | ->add('lastName', 'text') | ||
233 | ->getForm() | ||
234 | ->createView(); | ||
235 | |||
236 | $html = $this->renderForm($view, array( | ||
237 | 'id' => 'my&id', | ||
238 | 'attr' => array('class' => 'my&class'), | ||
239 | )); | ||
240 | |||
241 | $this->assertMatchesXpath($html, | ||
242 | '/form | ||
243 | [ | ||
244 | ./input[@type="hidden"][@name="_method"][@value="PUT"] | ||
245 | /following-sibling::table | ||
246 | [ | ||
247 | ./tr | ||
248 | [ | ||
249 | ./td | ||
250 | [./label[@for="name_firstName"]] | ||
251 | /following-sibling::td | ||
252 | [./input[@id="name_firstName"]] | ||
253 | ] | ||
254 | /following-sibling::tr | ||
255 | [ | ||
256 | ./td | ||
257 | [./label[@for="name_lastName"]] | ||
258 | /following-sibling::td | ||
259 | [./input[@id="name_lastName"]] | ||
260 | ] | ||
261 | /following-sibling::tr[@style="display: none"] | ||
262 | [./td[@colspan="2"]/input | ||
263 | [@type="hidden"] | ||
264 | [@id="name__token"] | ||
265 | ] | ||
266 | ] | ||
267 | [count(.//input)=3] | ||
268 | [@id="my&id"] | ||
269 | [@class="my&class"] | ||
270 | ] | ||
271 | [@method="post"] | ||
272 | [@action="http://example.com"] | ||
273 | [@class="my&class"] | ||
274 | ' | ||
275 | ); | ||
276 | } | ||
277 | |||
278 | public function testFormWidget() | ||
279 | { | ||
280 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
281 | ->add('firstName', 'text') | ||
282 | ->add('lastName', 'text') | ||
283 | ->getForm() | ||
284 | ->createView(); | ||
285 | |||
286 | $this->assertWidgetMatchesXpath($view, array(), | ||
287 | '/table | ||
288 | [ | ||
289 | ./tr | ||
290 | [ | ||
291 | ./td | ||
292 | [./label[@for="name_firstName"]] | ||
293 | /following-sibling::td | ||
294 | [./input[@id="name_firstName"]] | ||
295 | ] | ||
296 | /following-sibling::tr | ||
297 | [ | ||
298 | ./td | ||
299 | [./label[@for="name_lastName"]] | ||
300 | /following-sibling::td | ||
301 | [./input[@id="name_lastName"]] | ||
302 | ] | ||
303 | /following-sibling::tr[@style="display: none"] | ||
304 | [./td[@colspan="2"]/input | ||
305 | [@type="hidden"] | ||
306 | [@id="name__token"] | ||
307 | ] | ||
308 | ] | ||
309 | [count(.//input)=3] | ||
310 | ' | ||
311 | ); | ||
312 | } | ||
313 | |||
314 | // https://github.com/symfony/symfony/issues/2308 | ||
315 | public function testNestedFormError() | ||
316 | { | ||
317 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
318 | ->add($this->factory | ||
319 | ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) | ||
320 | ->add('grandChild', 'form') | ||
321 | ) | ||
322 | ->getForm(); | ||
323 | |||
324 | $form->get('child')->addError(new FormError('[trans]Error![/trans]')); | ||
325 | |||
326 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
327 | '/table | ||
328 | [ | ||
329 | ./tr/td/ul[./li[.="[trans]Error![/trans]"]] | ||
330 | /following-sibling::table[@id="name_child"] | ||
331 | ] | ||
332 | [count(.//li[.="[trans]Error![/trans]"])=1] | ||
333 | ' | ||
334 | ); | ||
335 | } | ||
336 | |||
337 | public function testCsrf() | ||
338 | { | ||
339 | $this->csrfProvider->expects($this->any()) | ||
340 | ->method('generateCsrfToken') | ||
341 | ->will($this->returnValue('foo&bar')); | ||
342 | |||
343 | $form = $this->factory->createNamedBuilder('name', 'form') | ||
344 | ->add($this->factory | ||
345 | // No CSRF protection on nested forms | ||
346 | ->createNamedBuilder('child', 'form') | ||
347 | ->add($this->factory->createNamedBuilder('grandchild', 'text')) | ||
348 | ) | ||
349 | ->getForm(); | ||
350 | |||
351 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
352 | '/table | ||
353 | [ | ||
354 | ./tr[@style="display: none"] | ||
355 | [./td[@colspan="2"]/input | ||
356 | [@type="hidden"] | ||
357 | [@id="name__token"] | ||
358 | ] | ||
359 | ] | ||
360 | [count(.//input[@type="hidden"])=1] | ||
361 | ' | ||
362 | ); | ||
363 | } | ||
364 | |||
365 | public function testRepeated() | ||
366 | { | ||
367 | $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( | ||
368 | 'type' => 'text', | ||
369 | )); | ||
370 | |||
371 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
372 | '/table | ||
373 | [ | ||
374 | ./tr | ||
375 | [ | ||
376 | ./td | ||
377 | [./label[@for="name_first"]] | ||
378 | /following-sibling::td | ||
379 | [./input[@type="text"][@id="name_first"]] | ||
380 | ] | ||
381 | /following-sibling::tr | ||
382 | [ | ||
383 | ./td | ||
384 | [./label[@for="name_second"]] | ||
385 | /following-sibling::td | ||
386 | [./input[@type="text"][@id="name_second"]] | ||
387 | ] | ||
388 | /following-sibling::tr[@style="display: none"] | ||
389 | [./td[@colspan="2"]/input | ||
390 | [@type="hidden"] | ||
391 | [@id="name__token"] | ||
392 | ] | ||
393 | ] | ||
394 | [count(.//input)=3] | ||
395 | ' | ||
396 | ); | ||
397 | } | ||
398 | |||
399 | public function testRepeatedWithCustomOptions() | ||
400 | { | ||
401 | $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( | ||
402 | 'type' => 'password', | ||
403 | 'first_options' => array('label' => 'Test', 'required' => false), | ||
404 | 'second_options' => array('label' => 'Test2') | ||
405 | )); | ||
406 | |||
407 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
408 | '/table | ||
409 | [ | ||
410 | ./tr | ||
411 | [ | ||
412 | ./td | ||
413 | [./label[@for="name_first"][.="[trans]Test[/trans]"]] | ||
414 | /following-sibling::td | ||
415 | [./input[@type="password"][@id="name_first"][@required="required"]] | ||
416 | ] | ||
417 | /following-sibling::tr | ||
418 | [ | ||
419 | ./td | ||
420 | [./label[@for="name_second"][.="[trans]Test2[/trans]"]] | ||
421 | /following-sibling::td | ||
422 | [./input[@type="password"][@id="name_second"][@required="required"]] | ||
423 | ] | ||
424 | /following-sibling::tr[@style="display: none"] | ||
425 | [./td[@colspan="2"]/input | ||
426 | [@type="hidden"] | ||
427 | [@id="name__token"] | ||
428 | ] | ||
429 | ] | ||
430 | [count(.//input)=3] | ||
431 | ' | ||
432 | ); | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * The block "_name_child_label" should be overridden in the theme of the | ||
437 | * implemented driver. | ||
438 | */ | ||
439 | public function testCollectionRowWithCustomBlock() | ||
440 | { | ||
441 | $collection = array('one', 'two', 'three'); | ||
442 | $form = $this->factory->createNamedBuilder('name', 'collection', $collection) | ||
443 | ->getForm(); | ||
444 | |||
445 | $this->assertWidgetMatchesXpath($form->createView(), array(), | ||
446 | '/table | ||
447 | [ | ||
448 | ./tr[./td/label[.="Custom label: [trans]0[/trans]"]] | ||
449 | /following-sibling::tr[./td/label[.="Custom label: [trans]1[/trans]"]] | ||
450 | /following-sibling::tr[./td/label[.="Custom label: [trans]2[/trans]"]] | ||
451 | ] | ||
452 | ' | ||
453 | ); | ||
454 | } | ||
455 | |||
456 | public function testFormEndWithRest() | ||
457 | { | ||
458 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
459 | ->add('field1', 'text') | ||
460 | ->add('field2', 'text') | ||
461 | ->getForm() | ||
462 | ->createView(); | ||
463 | |||
464 | $this->renderWidget($view['field1']); | ||
465 | |||
466 | // Rest should only contain field2 | ||
467 | $html = $this->renderEnd($view); | ||
468 | |||
469 | // Insert the start tag, the end tag should be rendered by the helper | ||
470 | // Unfortunately this is not valid HTML, because the surrounding table | ||
471 | // tag is missing. If someone renders a form with table layout | ||
472 | // manually, she should call form_rest() explicitly within the <table> | ||
473 | // tag. | ||
474 | $this->assertMatchesXpath('<form>' . $html, | ||
475 | '/form | ||
476 | [ | ||
477 | ./tr | ||
478 | [ | ||
479 | ./td | ||
480 | [./label[@for="name_field2"]] | ||
481 | /following-sibling::td | ||
482 | [./input[@id="name_field2"]] | ||
483 | ] | ||
484 | /following-sibling::tr[@style="display: none"] | ||
485 | [./td[@colspan="2"]/input | ||
486 | [@type="hidden"] | ||
487 | [@id="name__token"] | ||
488 | ] | ||
489 | ] | ||
490 | ' | ||
491 | ); | ||
492 | } | ||
493 | |||
494 | public function testFormEndWithoutRest() | ||
495 | { | ||
496 | $view = $this->factory->createNamedBuilder('name', 'form') | ||
497 | ->add('field1', 'text') | ||
498 | ->add('field2', 'text') | ||
499 | ->getForm() | ||
500 | ->createView(); | ||
501 | |||
502 | $this->renderWidget($view['field1']); | ||
503 | |||
504 | // Rest should only contain field2, but isn't rendered | ||
505 | $html = $this->renderEnd($view, array('render_rest' => false)); | ||
506 | |||
507 | $this->assertEquals('</form>', $html); | ||
508 | } | ||
509 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php deleted file mode 100644 index 73c602c5..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | class CompoundFormPerformanceTest extends \Symfony\Component\Form\Tests\FormPerformanceTestCase | ||
18 | { | ||
19 | /** | ||
20 | * Create a compound form multiple times, as happens in a collection form | ||
21 | * | ||
22 | * @group benchmark | ||
23 | */ | ||
24 | public function testArrayBasedForm() | ||
25 | { | ||
26 | $this->setMaxRunningTime(1); | ||
27 | |||
28 | for ($i = 0; $i < 40; ++$i) { | ||
29 | $form = $this->factory->createBuilder('form') | ||
30 | ->add('firstName', 'text') | ||
31 | ->add('lastName', 'text') | ||
32 | ->add('gender', 'choice', array( | ||
33 | 'choices' => array('male' => 'Male', 'female' => 'Female'), | ||
34 | 'required' => false, | ||
35 | )) | ||
36 | ->add('age', 'number') | ||
37 | ->add('birthDate', 'birthday') | ||
38 | ->add('city', 'choice', array( | ||
39 | // simulate 300 different cities | ||
40 | 'choices' => range(1, 300), | ||
41 | )) | ||
42 | ->getForm(); | ||
43 | |||
44 | // load the form into a view | ||
45 | $form->createView(); | ||
46 | } | ||
47 | } | ||
48 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php deleted file mode 100644 index b240d2d0..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php +++ /dev/null | |||
@@ -1,759 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; | ||
15 | use Symfony\Component\Form\FormError; | ||
16 | use Symfony\Component\HttpFoundation\Request; | ||
17 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
18 | use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; | ||
19 | |||
20 | class CompoundFormTest extends AbstractFormTest | ||
21 | { | ||
22 | public function testValidIfAllChildrenAreValid() | ||
23 | { | ||
24 | $this->form->add($this->getValidForm('firstName')); | ||
25 | $this->form->add($this->getValidForm('lastName')); | ||
26 | |||
27 | $this->form->submit(array( | ||
28 | 'firstName' => 'Bernhard', | ||
29 | 'lastName' => 'Schussek', | ||
30 | )); | ||
31 | |||
32 | $this->assertTrue($this->form->isValid()); | ||
33 | } | ||
34 | |||
35 | public function testInvalidIfChildIsInvalid() | ||
36 | { | ||
37 | $this->form->add($this->getValidForm('firstName')); | ||
38 | $this->form->add($this->getInvalidForm('lastName')); | ||
39 | |||
40 | $this->form->submit(array( | ||
41 | 'firstName' => 'Bernhard', | ||
42 | 'lastName' => 'Schussek', | ||
43 | )); | ||
44 | |||
45 | $this->assertFalse($this->form->isValid()); | ||
46 | } | ||
47 | |||
48 | public function testSubmitForwardsNullIfValueIsMissing() | ||
49 | { | ||
50 | $child = $this->getMockForm('firstName'); | ||
51 | |||
52 | $this->form->add($child); | ||
53 | |||
54 | $child->expects($this->once()) | ||
55 | ->method('submit') | ||
56 | ->with($this->equalTo(null)); | ||
57 | |||
58 | $this->form->submit(array()); | ||
59 | } | ||
60 | |||
61 | public function testSubmitDoesNotForwardNullIfNotClearMissing() | ||
62 | { | ||
63 | $child = $this->getMockForm('firstName'); | ||
64 | |||
65 | $this->form->add($child); | ||
66 | |||
67 | $child->expects($this->never()) | ||
68 | ->method('submit'); | ||
69 | |||
70 | $this->form->submit(array(), false); | ||
71 | } | ||
72 | |||
73 | public function testClearMissingFlagIsForwarded() | ||
74 | { | ||
75 | $child = $this->getMockForm('firstName'); | ||
76 | |||
77 | $this->form->add($child); | ||
78 | |||
79 | $child->expects($this->once()) | ||
80 | ->method('submit') | ||
81 | ->with($this->equalTo('foo'), false); | ||
82 | |||
83 | $this->form->submit(array('firstName' => 'foo'), false); | ||
84 | } | ||
85 | |||
86 | public function testCloneChildren() | ||
87 | { | ||
88 | $child = $this->getBuilder('child')->getForm(); | ||
89 | $this->form->add($child); | ||
90 | |||
91 | $clone = clone $this->form; | ||
92 | |||
93 | $this->assertNotSame($this->form, $clone); | ||
94 | $this->assertNotSame($child, $clone['child']); | ||
95 | } | ||
96 | |||
97 | public function testNotEmptyIfChildNotEmpty() | ||
98 | { | ||
99 | $child = $this->getMockForm(); | ||
100 | $child->expects($this->once()) | ||
101 | ->method('isEmpty') | ||
102 | ->will($this->returnValue(false)); | ||
103 | |||
104 | $this->form->setData(null); | ||
105 | $this->form->add($child); | ||
106 | |||
107 | $this->assertFalse($this->form->isEmpty()); | ||
108 | } | ||
109 | |||
110 | public function testValidIfSubmittedAndDisabledWithChildren() | ||
111 | { | ||
112 | $this->factory->expects($this->once()) | ||
113 | ->method('createNamedBuilder') | ||
114 | ->with('name', 'text', null, array()) | ||
115 | ->will($this->returnValue($this->getBuilder('name'))); | ||
116 | |||
117 | $form = $this->getBuilder('person') | ||
118 | ->setDisabled(true) | ||
119 | ->setCompound(true) | ||
120 | ->setDataMapper($this->getDataMapper()) | ||
121 | ->add('name', 'text') | ||
122 | ->getForm(); | ||
123 | $form->submit(array('name' => 'Jacques Doe')); | ||
124 | |||
125 | $this->assertTrue($form->isValid()); | ||
126 | } | ||
127 | |||
128 | public function testNotValidIfChildNotValid() | ||
129 | { | ||
130 | $child = $this->getMockForm(); | ||
131 | $child->expects($this->once()) | ||
132 | ->method('isValid') | ||
133 | ->will($this->returnValue(false)); | ||
134 | |||
135 | $this->form->add($child); | ||
136 | $this->form->submit(array()); | ||
137 | |||
138 | $this->assertFalse($this->form->isValid()); | ||
139 | } | ||
140 | |||
141 | public function testAdd() | ||
142 | { | ||
143 | $child = $this->getBuilder('foo')->getForm(); | ||
144 | $this->form->add($child); | ||
145 | |||
146 | $this->assertTrue($this->form->has('foo')); | ||
147 | $this->assertSame($this->form, $child->getParent()); | ||
148 | $this->assertSame(array('foo' => $child), $this->form->all()); | ||
149 | } | ||
150 | |||
151 | public function testAddUsingNameAndType() | ||
152 | { | ||
153 | $child = $this->getBuilder('foo')->getForm(); | ||
154 | |||
155 | $this->factory->expects($this->once()) | ||
156 | ->method('createNamed') | ||
157 | ->with('foo', 'text', null, array( | ||
158 | 'bar' => 'baz', | ||
159 | 'auto_initialize' => false, | ||
160 | )) | ||
161 | ->will($this->returnValue($child)); | ||
162 | |||
163 | $this->form->add('foo', 'text', array('bar' => 'baz')); | ||
164 | |||
165 | $this->assertTrue($this->form->has('foo')); | ||
166 | $this->assertSame($this->form, $child->getParent()); | ||
167 | $this->assertSame(array('foo' => $child), $this->form->all()); | ||
168 | } | ||
169 | |||
170 | public function testAddUsingIntegerNameAndType() | ||
171 | { | ||
172 | $child = $this->getBuilder(0)->getForm(); | ||
173 | |||
174 | $this->factory->expects($this->once()) | ||
175 | ->method('createNamed') | ||
176 | ->with('0', 'text', null, array( | ||
177 | 'bar' => 'baz', | ||
178 | 'auto_initialize' => false, | ||
179 | )) | ||
180 | ->will($this->returnValue($child)); | ||
181 | |||
182 | // in order to make casting unnecessary | ||
183 | $this->form->add(0, 'text', array('bar' => 'baz')); | ||
184 | |||
185 | $this->assertTrue($this->form->has(0)); | ||
186 | $this->assertSame($this->form, $child->getParent()); | ||
187 | $this->assertSame(array(0 => $child), $this->form->all()); | ||
188 | } | ||
189 | |||
190 | public function testAddUsingNameButNoType() | ||
191 | { | ||
192 | $this->form = $this->getBuilder('name', null, '\stdClass') | ||
193 | ->setCompound(true) | ||
194 | ->setDataMapper($this->getDataMapper()) | ||
195 | ->getForm(); | ||
196 | |||
197 | $child = $this->getBuilder('foo')->getForm(); | ||
198 | |||
199 | $this->factory->expects($this->once()) | ||
200 | ->method('createForProperty') | ||
201 | ->with('\stdClass', 'foo') | ||
202 | ->will($this->returnValue($child)); | ||
203 | |||
204 | $this->form->add('foo'); | ||
205 | |||
206 | $this->assertTrue($this->form->has('foo')); | ||
207 | $this->assertSame($this->form, $child->getParent()); | ||
208 | $this->assertSame(array('foo' => $child), $this->form->all()); | ||
209 | } | ||
210 | |||
211 | public function testAddUsingNameButNoTypeAndOptions() | ||
212 | { | ||
213 | $this->form = $this->getBuilder('name', null, '\stdClass') | ||
214 | ->setCompound(true) | ||
215 | ->setDataMapper($this->getDataMapper()) | ||
216 | ->getForm(); | ||
217 | |||
218 | $child = $this->getBuilder('foo')->getForm(); | ||
219 | |||
220 | $this->factory->expects($this->once()) | ||
221 | ->method('createForProperty') | ||
222 | ->with('\stdClass', 'foo', null, array( | ||
223 | 'bar' => 'baz', | ||
224 | 'auto_initialize' => false, | ||
225 | )) | ||
226 | ->will($this->returnValue($child)); | ||
227 | |||
228 | $this->form->add('foo', null, array('bar' => 'baz')); | ||
229 | |||
230 | $this->assertTrue($this->form->has('foo')); | ||
231 | $this->assertSame($this->form, $child->getParent()); | ||
232 | $this->assertSame(array('foo' => $child), $this->form->all()); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException | ||
237 | */ | ||
238 | public function testAddThrowsExceptionIfAlreadySubmitted() | ||
239 | { | ||
240 | $this->form->submit(array()); | ||
241 | $this->form->add($this->getBuilder('foo')->getForm()); | ||
242 | } | ||
243 | |||
244 | public function testRemove() | ||
245 | { | ||
246 | $child = $this->getBuilder('foo')->getForm(); | ||
247 | $this->form->add($child); | ||
248 | $this->form->remove('foo'); | ||
249 | |||
250 | $this->assertNull($child->getParent()); | ||
251 | $this->assertCount(0, $this->form); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException | ||
256 | */ | ||
257 | public function testRemoveThrowsExceptionIfAlreadySubmitted() | ||
258 | { | ||
259 | $this->form->add($this->getBuilder('foo')->setCompound(false)->getForm()); | ||
260 | $this->form->submit(array('foo' => 'bar')); | ||
261 | $this->form->remove('foo'); | ||
262 | } | ||
263 | |||
264 | public function testRemoveIgnoresUnknownName() | ||
265 | { | ||
266 | $this->form->remove('notexisting'); | ||
267 | } | ||
268 | |||
269 | public function testArrayAccess() | ||
270 | { | ||
271 | $child = $this->getBuilder('foo')->getForm(); | ||
272 | |||
273 | $this->form[] = $child; | ||
274 | |||
275 | $this->assertTrue(isset($this->form['foo'])); | ||
276 | $this->assertSame($child, $this->form['foo']); | ||
277 | |||
278 | unset($this->form['foo']); | ||
279 | |||
280 | $this->assertFalse(isset($this->form['foo'])); | ||
281 | } | ||
282 | |||
283 | public function testCountable() | ||
284 | { | ||
285 | $this->form->add($this->getBuilder('foo')->getForm()); | ||
286 | $this->form->add($this->getBuilder('bar')->getForm()); | ||
287 | |||
288 | $this->assertCount(2, $this->form); | ||
289 | } | ||
290 | |||
291 | public function testIterator() | ||
292 | { | ||
293 | $this->form->add($this->getBuilder('foo')->getForm()); | ||
294 | $this->form->add($this->getBuilder('bar')->getForm()); | ||
295 | |||
296 | $this->assertSame($this->form->all(), iterator_to_array($this->form)); | ||
297 | } | ||
298 | |||
299 | public function testAddMapsViewDataToFormIfInitialized() | ||
300 | { | ||
301 | $test = $this; | ||
302 | $mapper = $this->getDataMapper(); | ||
303 | $form = $this->getBuilder() | ||
304 | ->setCompound(true) | ||
305 | ->setDataMapper($mapper) | ||
306 | ->addViewTransformer(new FixedDataTransformer(array( | ||
307 | '' => '', | ||
308 | 'foo' => 'bar', | ||
309 | ))) | ||
310 | ->setData('foo') | ||
311 | ->getForm(); | ||
312 | |||
313 | $child = $this->getBuilder()->getForm(); | ||
314 | $mapper->expects($this->once()) | ||
315 | ->method('mapDataToForms') | ||
316 | ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) | ||
317 | ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child, $test) { | ||
318 | $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); | ||
319 | $test->assertSame(array($child), iterator_to_array($iterator)); | ||
320 | })); | ||
321 | |||
322 | $form->initialize(); | ||
323 | $form->add($child); | ||
324 | } | ||
325 | |||
326 | public function testAddDoesNotMapViewDataToFormIfNotInitialized() | ||
327 | { | ||
328 | $mapper = $this->getDataMapper(); | ||
329 | $form = $this->getBuilder() | ||
330 | ->setCompound(true) | ||
331 | ->setDataMapper($mapper) | ||
332 | ->getForm(); | ||
333 | |||
334 | $child = $this->getBuilder()->getForm(); | ||
335 | $mapper->expects($this->never()) | ||
336 | ->method('mapDataToForms'); | ||
337 | |||
338 | $form->add($child); | ||
339 | } | ||
340 | |||
341 | public function testAddDoesNotMapViewDataToFormIfInheritData() | ||
342 | { | ||
343 | $mapper = $this->getDataMapper(); | ||
344 | $form = $this->getBuilder() | ||
345 | ->setCompound(true) | ||
346 | ->setDataMapper($mapper) | ||
347 | ->setInheritData(true) | ||
348 | ->getForm(); | ||
349 | |||
350 | $child = $this->getBuilder()->getForm(); | ||
351 | $mapper->expects($this->never()) | ||
352 | ->method('mapDataToForms'); | ||
353 | |||
354 | $form->initialize(); | ||
355 | $form->add($child); | ||
356 | } | ||
357 | |||
358 | public function testSetDataMapsViewDataToChildren() | ||
359 | { | ||
360 | $test = $this; | ||
361 | $mapper = $this->getDataMapper(); | ||
362 | $form = $this->getBuilder() | ||
363 | ->setCompound(true) | ||
364 | ->setDataMapper($mapper) | ||
365 | ->addViewTransformer(new FixedDataTransformer(array( | ||
366 | '' => '', | ||
367 | 'foo' => 'bar', | ||
368 | ))) | ||
369 | ->getForm(); | ||
370 | |||
371 | $form->add($child1 = $this->getBuilder('firstName')->getForm()); | ||
372 | $form->add($child2 = $this->getBuilder('lastName')->getForm()); | ||
373 | |||
374 | $mapper->expects($this->once()) | ||
375 | ->method('mapDataToForms') | ||
376 | ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) | ||
377 | ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { | ||
378 | $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); | ||
379 | $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); | ||
380 | })); | ||
381 | |||
382 | $form->setData('foo'); | ||
383 | } | ||
384 | |||
385 | public function testSubmitMapsSubmittedChildrenOntoExistingViewData() | ||
386 | { | ||
387 | $test = $this; | ||
388 | $mapper = $this->getDataMapper(); | ||
389 | $form = $this->getBuilder() | ||
390 | ->setCompound(true) | ||
391 | ->setDataMapper($mapper) | ||
392 | ->addViewTransformer(new FixedDataTransformer(array( | ||
393 | '' => '', | ||
394 | 'foo' => 'bar', | ||
395 | ))) | ||
396 | ->setData('foo') | ||
397 | ->getForm(); | ||
398 | |||
399 | $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); | ||
400 | $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); | ||
401 | |||
402 | $mapper->expects($this->once()) | ||
403 | ->method('mapFormsToData') | ||
404 | ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') | ||
405 | ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { | ||
406 | $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); | ||
407 | $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); | ||
408 | $test->assertEquals('Bernhard', $child1->getData()); | ||
409 | $test->assertEquals('Schussek', $child2->getData()); | ||
410 | })); | ||
411 | |||
412 | $form->submit(array( | ||
413 | 'firstName' => 'Bernhard', | ||
414 | 'lastName' => 'Schussek', | ||
415 | )); | ||
416 | } | ||
417 | |||
418 | public function testMapFormsToDataIsNotInvokedIfInheritData() | ||
419 | { | ||
420 | $mapper = $this->getDataMapper(); | ||
421 | $form = $this->getBuilder() | ||
422 | ->setCompound(true) | ||
423 | ->setDataMapper($mapper) | ||
424 | ->setInheritData(true) | ||
425 | ->addViewTransformer(new FixedDataTransformer(array( | ||
426 | '' => '', | ||
427 | 'foo' => 'bar', | ||
428 | ))) | ||
429 | ->getForm(); | ||
430 | |||
431 | $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); | ||
432 | $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); | ||
433 | |||
434 | $mapper->expects($this->never()) | ||
435 | ->method('mapFormsToData'); | ||
436 | |||
437 | $form->submit(array( | ||
438 | 'firstName' => 'Bernhard', | ||
439 | 'lastName' => 'Schussek', | ||
440 | )); | ||
441 | } | ||
442 | |||
443 | /* | ||
444 | * https://github.com/symfony/symfony/issues/4480 | ||
445 | */ | ||
446 | public function testSubmitRestoresViewDataIfCompoundAndEmpty() | ||
447 | { | ||
448 | $mapper = $this->getDataMapper(); | ||
449 | $object = new \stdClass(); | ||
450 | $form = $this->getBuilder('name', null, 'stdClass') | ||
451 | ->setCompound(true) | ||
452 | ->setDataMapper($mapper) | ||
453 | ->setData($object) | ||
454 | ->getForm(); | ||
455 | |||
456 | $form->submit(array()); | ||
457 | |||
458 | $this->assertSame($object, $form->getData()); | ||
459 | } | ||
460 | |||
461 | public function testSubmitMapsSubmittedChildrenOntoEmptyData() | ||
462 | { | ||
463 | $test = $this; | ||
464 | $mapper = $this->getDataMapper(); | ||
465 | $object = new \stdClass(); | ||
466 | $form = $this->getBuilder() | ||
467 | ->setCompound(true) | ||
468 | ->setDataMapper($mapper) | ||
469 | ->setEmptyData($object) | ||
470 | ->setData(null) | ||
471 | ->getForm(); | ||
472 | |||
473 | $form->add($child = $this->getBuilder('name')->setCompound(false)->getForm()); | ||
474 | |||
475 | $mapper->expects($this->once()) | ||
476 | ->method('mapFormsToData') | ||
477 | ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) | ||
478 | ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child, $test) { | ||
479 | $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); | ||
480 | $test->assertSame(array('name' => $child), iterator_to_array($iterator)); | ||
481 | })); | ||
482 | |||
483 | $form->submit(array( | ||
484 | 'name' => 'Bernhard', | ||
485 | )); | ||
486 | } | ||
487 | |||
488 | public function requestMethodProvider() | ||
489 | { | ||
490 | return array( | ||
491 | array('POST'), | ||
492 | array('PUT'), | ||
493 | array('DELETE'), | ||
494 | array('PATCH'), | ||
495 | ); | ||
496 | } | ||
497 | |||
498 | /** | ||
499 | * @dataProvider requestMethodProvider | ||
500 | */ | ||
501 | public function testSubmitPostOrPutRequest($method) | ||
502 | { | ||
503 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
504 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
505 | } | ||
506 | |||
507 | $path = tempnam(sys_get_temp_dir(), 'sf2'); | ||
508 | touch($path); | ||
509 | |||
510 | $values = array( | ||
511 | 'author' => array( | ||
512 | 'name' => 'Bernhard', | ||
513 | 'image' => array('filename' => 'foobar.png'), | ||
514 | ), | ||
515 | ); | ||
516 | |||
517 | $files = array( | ||
518 | 'author' => array( | ||
519 | 'error' => array('image' => UPLOAD_ERR_OK), | ||
520 | 'name' => array('image' => 'upload.png'), | ||
521 | 'size' => array('image' => 123), | ||
522 | 'tmp_name' => array('image' => $path), | ||
523 | 'type' => array('image' => 'image/png'), | ||
524 | ), | ||
525 | ); | ||
526 | |||
527 | $request = new Request(array(), $values, array(), array(), $files, array( | ||
528 | 'REQUEST_METHOD' => $method, | ||
529 | )); | ||
530 | |||
531 | $form = $this->getBuilder('author') | ||
532 | ->setMethod($method) | ||
533 | ->setCompound(true) | ||
534 | ->setDataMapper($this->getDataMapper()) | ||
535 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
536 | ->getForm(); | ||
537 | $form->add($this->getBuilder('name')->getForm()); | ||
538 | $form->add($this->getBuilder('image')->getForm()); | ||
539 | |||
540 | $form->handleRequest($request); | ||
541 | |||
542 | $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); | ||
543 | |||
544 | $this->assertEquals('Bernhard', $form['name']->getData()); | ||
545 | $this->assertEquals($file, $form['image']->getData()); | ||
546 | |||
547 | unlink($path); | ||
548 | } | ||
549 | |||
550 | /** | ||
551 | * @dataProvider requestMethodProvider | ||
552 | */ | ||
553 | public function testSubmitPostOrPutRequestWithEmptyRootFormName($method) | ||
554 | { | ||
555 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
556 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
557 | } | ||
558 | |||
559 | $path = tempnam(sys_get_temp_dir(), 'sf2'); | ||
560 | touch($path); | ||
561 | |||
562 | $values = array( | ||
563 | 'name' => 'Bernhard', | ||
564 | 'extra' => 'data', | ||
565 | ); | ||
566 | |||
567 | $files = array( | ||
568 | 'image' => array( | ||
569 | 'error' => UPLOAD_ERR_OK, | ||
570 | 'name' => 'upload.png', | ||
571 | 'size' => 123, | ||
572 | 'tmp_name' => $path, | ||
573 | 'type' => 'image/png', | ||
574 | ), | ||
575 | ); | ||
576 | |||
577 | $request = new Request(array(), $values, array(), array(), $files, array( | ||
578 | 'REQUEST_METHOD' => $method, | ||
579 | )); | ||
580 | |||
581 | $form = $this->getBuilder('') | ||
582 | ->setMethod($method) | ||
583 | ->setCompound(true) | ||
584 | ->setDataMapper($this->getDataMapper()) | ||
585 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
586 | ->getForm(); | ||
587 | $form->add($this->getBuilder('name')->getForm()); | ||
588 | $form->add($this->getBuilder('image')->getForm()); | ||
589 | |||
590 | $form->handleRequest($request); | ||
591 | |||
592 | $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); | ||
593 | |||
594 | $this->assertEquals('Bernhard', $form['name']->getData()); | ||
595 | $this->assertEquals($file, $form['image']->getData()); | ||
596 | $this->assertEquals(array('extra' => 'data'), $form->getExtraData()); | ||
597 | |||
598 | unlink($path); | ||
599 | } | ||
600 | |||
601 | /** | ||
602 | * @dataProvider requestMethodProvider | ||
603 | */ | ||
604 | public function testSubmitPostOrPutRequestWithSingleChildForm($method) | ||
605 | { | ||
606 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
607 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
608 | } | ||
609 | |||
610 | $path = tempnam(sys_get_temp_dir(), 'sf2'); | ||
611 | touch($path); | ||
612 | |||
613 | $files = array( | ||
614 | 'image' => array( | ||
615 | 'error' => UPLOAD_ERR_OK, | ||
616 | 'name' => 'upload.png', | ||
617 | 'size' => 123, | ||
618 | 'tmp_name' => $path, | ||
619 | 'type' => 'image/png', | ||
620 | ), | ||
621 | ); | ||
622 | |||
623 | $request = new Request(array(), array(), array(), array(), $files, array( | ||
624 | 'REQUEST_METHOD' => $method, | ||
625 | )); | ||
626 | |||
627 | $form = $this->getBuilder('image') | ||
628 | ->setMethod($method) | ||
629 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
630 | ->getForm(); | ||
631 | |||
632 | $form->handleRequest($request); | ||
633 | |||
634 | $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); | ||
635 | |||
636 | $this->assertEquals($file, $form->getData()); | ||
637 | |||
638 | unlink($path); | ||
639 | } | ||
640 | |||
641 | /** | ||
642 | * @dataProvider requestMethodProvider | ||
643 | */ | ||
644 | public function testSubmitPostOrPutRequestWithSingleChildFormUploadedFile($method) | ||
645 | { | ||
646 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
647 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
648 | } | ||
649 | |||
650 | $path = tempnam(sys_get_temp_dir(), 'sf2'); | ||
651 | touch($path); | ||
652 | |||
653 | $values = array( | ||
654 | 'name' => 'Bernhard', | ||
655 | ); | ||
656 | |||
657 | $request = new Request(array(), $values, array(), array(), array(), array( | ||
658 | 'REQUEST_METHOD' => $method, | ||
659 | )); | ||
660 | |||
661 | $form = $this->getBuilder('name') | ||
662 | ->setMethod($method) | ||
663 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
664 | ->getForm(); | ||
665 | |||
666 | $form->handleRequest($request); | ||
667 | |||
668 | $this->assertEquals('Bernhard', $form->getData()); | ||
669 | |||
670 | unlink($path); | ||
671 | } | ||
672 | |||
673 | public function testSubmitGetRequest() | ||
674 | { | ||
675 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
676 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
677 | } | ||
678 | |||
679 | $values = array( | ||
680 | 'author' => array( | ||
681 | 'firstName' => 'Bernhard', | ||
682 | 'lastName' => 'Schussek', | ||
683 | ), | ||
684 | ); | ||
685 | |||
686 | $request = new Request($values, array(), array(), array(), array(), array( | ||
687 | 'REQUEST_METHOD' => 'GET', | ||
688 | )); | ||
689 | |||
690 | $form = $this->getBuilder('author') | ||
691 | ->setMethod('GET') | ||
692 | ->setCompound(true) | ||
693 | ->setDataMapper($this->getDataMapper()) | ||
694 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
695 | ->getForm(); | ||
696 | $form->add($this->getBuilder('firstName')->getForm()); | ||
697 | $form->add($this->getBuilder('lastName')->getForm()); | ||
698 | |||
699 | $form->handleRequest($request); | ||
700 | |||
701 | $this->assertEquals('Bernhard', $form['firstName']->getData()); | ||
702 | $this->assertEquals('Schussek', $form['lastName']->getData()); | ||
703 | } | ||
704 | |||
705 | public function testSubmitGetRequestWithEmptyRootFormName() | ||
706 | { | ||
707 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
708 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
709 | } | ||
710 | |||
711 | $values = array( | ||
712 | 'firstName' => 'Bernhard', | ||
713 | 'lastName' => 'Schussek', | ||
714 | 'extra' => 'data' | ||
715 | ); | ||
716 | |||
717 | $request = new Request($values, array(), array(), array(), array(), array( | ||
718 | 'REQUEST_METHOD' => 'GET', | ||
719 | )); | ||
720 | |||
721 | $form = $this->getBuilder('') | ||
722 | ->setMethod('GET') | ||
723 | ->setCompound(true) | ||
724 | ->setDataMapper($this->getDataMapper()) | ||
725 | ->setRequestHandler(new HttpFoundationRequestHandler()) | ||
726 | ->getForm(); | ||
727 | $form->add($this->getBuilder('firstName')->getForm()); | ||
728 | $form->add($this->getBuilder('lastName')->getForm()); | ||
729 | |||
730 | $form->handleRequest($request); | ||
731 | |||
732 | $this->assertEquals('Bernhard', $form['firstName']->getData()); | ||
733 | $this->assertEquals('Schussek', $form['lastName']->getData()); | ||
734 | $this->assertEquals(array('extra' => 'data'), $form->getExtraData()); | ||
735 | } | ||
736 | |||
737 | public function testGetErrorsAsStringDeep() | ||
738 | { | ||
739 | $parent = $this->getBuilder() | ||
740 | ->setCompound(true) | ||
741 | ->setDataMapper($this->getDataMapper()) | ||
742 | ->getForm(); | ||
743 | |||
744 | $this->form->addError(new FormError('Error!')); | ||
745 | |||
746 | $parent->add($this->form); | ||
747 | $parent->add($this->getBuilder('foo')->getForm()); | ||
748 | |||
749 | $this->assertEquals("name:\n ERROR: Error!\nfoo:\n No errors\n", $parent->getErrorsAsString()); | ||
750 | } | ||
751 | |||
752 | protected function createForm() | ||
753 | { | ||
754 | return $this->getBuilder() | ||
755 | ->setCompound(true) | ||
756 | ->setDataMapper($this->getDataMapper()) | ||
757 | ->getForm(); | ||
758 | } | ||
759 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php deleted file mode 100644 index 63eae9bf..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
16 | |||
17 | class ChoiceListTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | private $obj1; | ||
20 | |||
21 | private $obj2; | ||
22 | |||
23 | private $obj3; | ||
24 | |||
25 | private $obj4; | ||
26 | |||
27 | private $list; | ||
28 | |||
29 | protected function setUp() | ||
30 | { | ||
31 | parent::setUp(); | ||
32 | |||
33 | $this->obj1 = new \stdClass(); | ||
34 | $this->obj2 = new \stdClass(); | ||
35 | $this->obj3 = new \stdClass(); | ||
36 | $this->obj4 = new \stdClass(); | ||
37 | |||
38 | $this->list = new ChoiceList( | ||
39 | array( | ||
40 | 'Group 1' => array($this->obj1, $this->obj2), | ||
41 | 'Group 2' => array($this->obj3, $this->obj4), | ||
42 | ), | ||
43 | array( | ||
44 | 'Group 1' => array('A', 'B'), | ||
45 | 'Group 2' => array('C', 'D'), | ||
46 | ), | ||
47 | array($this->obj2, $this->obj3) | ||
48 | ); | ||
49 | } | ||
50 | |||
51 | protected function tearDown() | ||
52 | { | ||
53 | parent::tearDown(); | ||
54 | |||
55 | $this->obj1 = null; | ||
56 | $this->obj2 = null; | ||
57 | $this->obj3 = null; | ||
58 | $this->obj4 = null; | ||
59 | $this->list = null; | ||
60 | } | ||
61 | |||
62 | public function testInitArray() | ||
63 | { | ||
64 | $this->list = new ChoiceList( | ||
65 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4), | ||
66 | array('A', 'B', 'C', 'D'), | ||
67 | array($this->obj2) | ||
68 | ); | ||
69 | |||
70 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
71 | $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); | ||
72 | $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews()); | ||
73 | $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Necessary for interoperability with MongoDB cursors or ORM relations as | ||
78 | * choices parameter. A choice itself that is an object implementing \Traversable | ||
79 | * is not treated as hierarchical structure, but as-is. | ||
80 | */ | ||
81 | public function testInitNestedTraversable() | ||
82 | { | ||
83 | $traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4)); | ||
84 | |||
85 | $this->list = new ChoiceList( | ||
86 | new \ArrayIterator(array( | ||
87 | 'Group' => array($this->obj1, $this->obj2), | ||
88 | 'Not a Group' => $traversableChoice | ||
89 | )), | ||
90 | array( | ||
91 | 'Group' => array('A', 'B'), | ||
92 | 'Not a Group' => 'C', | ||
93 | ), | ||
94 | array($this->obj2) | ||
95 | ); | ||
96 | |||
97 | $this->assertSame(array($this->obj1, $this->obj2, $traversableChoice), $this->list->getChoices()); | ||
98 | $this->assertSame(array('0', '1', '2'), $this->list->getValues()); | ||
99 | $this->assertEquals(array( | ||
100 | 'Group' => array(1 => new ChoiceView($this->obj2, '1', 'B')) | ||
101 | ), $this->list->getPreferredViews()); | ||
102 | $this->assertEquals(array( | ||
103 | 'Group' => array(0 => new ChoiceView($this->obj1, '0', 'A')), | ||
104 | 2 => new ChoiceView($traversableChoice, '2', 'C') | ||
105 | ), $this->list->getRemainingViews()); | ||
106 | } | ||
107 | |||
108 | public function testInitNestedArray() | ||
109 | { | ||
110 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
111 | $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); | ||
112 | $this->assertEquals(array( | ||
113 | 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), | ||
114 | 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) | ||
115 | ), $this->list->getPreferredViews()); | ||
116 | $this->assertEquals(array( | ||
117 | 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), | ||
118 | 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')) | ||
119 | ), $this->list->getRemainingViews()); | ||
120 | } | ||
121 | |||
122 | public function testGetIndicesForChoices() | ||
123 | { | ||
124 | $choices = array($this->obj2, $this->obj3); | ||
125 | $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); | ||
126 | } | ||
127 | |||
128 | public function testGetIndicesForChoicesIgnoresNonExistingChoices() | ||
129 | { | ||
130 | $choices = array($this->obj2, $this->obj3, 'foobar'); | ||
131 | $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); | ||
132 | } | ||
133 | |||
134 | public function testGetIndicesForValues() | ||
135 | { | ||
136 | // values and indices are always the same | ||
137 | $values = array('1', '2'); | ||
138 | $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); | ||
139 | } | ||
140 | |||
141 | public function testGetIndicesForValuesIgnoresNonExistingValues() | ||
142 | { | ||
143 | $values = array('1', '2', '5'); | ||
144 | $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); | ||
145 | } | ||
146 | |||
147 | public function testGetChoicesForValues() | ||
148 | { | ||
149 | $values = array('1', '2'); | ||
150 | $this->assertSame(array($this->obj2, $this->obj3), $this->list->getChoicesForValues($values)); | ||
151 | } | ||
152 | |||
153 | public function testGetChoicesForValuesCorrectOrderingOfResult() | ||
154 | { | ||
155 | $values = array('2', '1'); | ||
156 | $this->assertSame(array($this->obj3, $this->obj2), $this->list->getChoicesForValues($values)); | ||
157 | } | ||
158 | |||
159 | public function testGetChoicesForValuesIgnoresNonExistingValues() | ||
160 | { | ||
161 | $values = array('1', '2', '5'); | ||
162 | $this->assertSame(array($this->obj2, $this->obj3), $this->list->getChoicesForValues($values)); | ||
163 | } | ||
164 | |||
165 | public function testGetValuesForChoices() | ||
166 | { | ||
167 | $choices = array($this->obj2, $this->obj3); | ||
168 | $this->assertSame(array('1', '2'), $this->list->getValuesForChoices($choices)); | ||
169 | } | ||
170 | |||
171 | public function testGetValuesForChoicesIgnoresNonExistingChoices() | ||
172 | { | ||
173 | $choices = array($this->obj2, $this->obj3, 'foobar'); | ||
174 | $this->assertSame(array('1', '2'), $this->list->getValuesForChoices($choices)); | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * @expectedException \InvalidArgumentException | ||
179 | */ | ||
180 | public function testNonMatchingLabels() | ||
181 | { | ||
182 | $this->list = new ChoiceList( | ||
183 | array($this->obj1, $this->obj2), | ||
184 | array('A') | ||
185 | ); | ||
186 | } | ||
187 | |||
188 | public function testLabelsContainingNull() | ||
189 | { | ||
190 | $this->list = new ChoiceList( | ||
191 | array($this->obj1, $this->obj2), | ||
192 | array('A', null) | ||
193 | ); | ||
194 | |||
195 | $this->assertEquals( | ||
196 | array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)), | ||
197 | $this->list->getRemainingViews() | ||
198 | ); | ||
199 | } | ||
200 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php deleted file mode 100644 index bcd309e0..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList; | ||
16 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
17 | |||
18 | class LazyChoiceListTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | private $list; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | parent::setUp(); | ||
25 | |||
26 | $this->list = new LazyChoiceListTest_Impl(new SimpleChoiceList(array( | ||
27 | 'a' => 'A', | ||
28 | 'b' => 'B', | ||
29 | 'c' => 'C', | ||
30 | ), array('b'))); | ||
31 | } | ||
32 | |||
33 | protected function tearDown() | ||
34 | { | ||
35 | parent::tearDown(); | ||
36 | |||
37 | $this->list = null; | ||
38 | } | ||
39 | |||
40 | public function testGetChoices() | ||
41 | { | ||
42 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices()); | ||
43 | } | ||
44 | |||
45 | public function testGetValues() | ||
46 | { | ||
47 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues()); | ||
48 | } | ||
49 | |||
50 | public function testGetPreferredViews() | ||
51 | { | ||
52 | $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews()); | ||
53 | } | ||
54 | |||
55 | public function testGetRemainingViews() | ||
56 | { | ||
57 | $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews()); | ||
58 | } | ||
59 | |||
60 | public function testGetIndicesForChoices() | ||
61 | { | ||
62 | $choices = array('b', 'c'); | ||
63 | $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); | ||
64 | } | ||
65 | |||
66 | public function testGetIndicesForValues() | ||
67 | { | ||
68 | $values = array('b', 'c'); | ||
69 | $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); | ||
70 | } | ||
71 | |||
72 | public function testGetChoicesForValues() | ||
73 | { | ||
74 | $values = array('b', 'c'); | ||
75 | $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values)); | ||
76 | } | ||
77 | |||
78 | public function testGetValuesForChoices() | ||
79 | { | ||
80 | $choices = array('b', 'c'); | ||
81 | $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices)); | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException | ||
86 | */ | ||
87 | public function testLoadChoiceListShouldReturnChoiceList() | ||
88 | { | ||
89 | $list = new LazyChoiceListTest_InvalidImpl(); | ||
90 | |||
91 | $list->getChoices(); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | class LazyChoiceListTest_Impl extends LazyChoiceList | ||
96 | { | ||
97 | private $choiceList; | ||
98 | |||
99 | public function __construct($choiceList) | ||
100 | { | ||
101 | $this->choiceList = $choiceList; | ||
102 | } | ||
103 | |||
104 | protected function loadChoiceList() | ||
105 | { | ||
106 | return $this->choiceList; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | class LazyChoiceListTest_InvalidImpl extends LazyChoiceList | ||
111 | { | ||
112 | protected function loadChoiceList() | ||
113 | { | ||
114 | return new \stdClass(); | ||
115 | } | ||
116 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php deleted file mode 100644 index 69c5aa0f..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php +++ /dev/null | |||
@@ -1,212 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
16 | |||
17 | class ObjectChoiceListTest_EntityWithToString | ||
18 | { | ||
19 | private $property; | ||
20 | |||
21 | public function __construct($property) | ||
22 | { | ||
23 | $this->property = $property; | ||
24 | } | ||
25 | |||
26 | public function __toString() | ||
27 | { | ||
28 | return $this->property; | ||
29 | } | ||
30 | } | ||
31 | |||
32 | class ObjectChoiceListTest extends \PHPUnit_Framework_TestCase | ||
33 | { | ||
34 | private $obj1; | ||
35 | |||
36 | private $obj2; | ||
37 | |||
38 | private $obj3; | ||
39 | |||
40 | private $obj4; | ||
41 | |||
42 | /** | ||
43 | * @var ObjectChoiceList | ||
44 | */ | ||
45 | private $list; | ||
46 | |||
47 | protected function setUp() | ||
48 | { | ||
49 | parent::setUp(); | ||
50 | |||
51 | $this->obj1 = (object) array('name' => 'A'); | ||
52 | $this->obj2 = (object) array('name' => 'B'); | ||
53 | $this->obj3 = (object) array('name' => 'C'); | ||
54 | $this->obj4 = (object) array('name' => 'D'); | ||
55 | |||
56 | $this->list = new ObjectChoiceList( | ||
57 | array( | ||
58 | 'Group 1' => array($this->obj1, $this->obj2), | ||
59 | 'Group 2' => array($this->obj3, $this->obj4), | ||
60 | ), | ||
61 | 'name', | ||
62 | array($this->obj2, $this->obj3) | ||
63 | ); | ||
64 | } | ||
65 | |||
66 | protected function tearDown() | ||
67 | { | ||
68 | parent::tearDown(); | ||
69 | |||
70 | $this->obj1 = null; | ||
71 | $this->obj2 = null; | ||
72 | $this->obj3 = null; | ||
73 | $this->obj4 = null; | ||
74 | $this->list = null; | ||
75 | } | ||
76 | |||
77 | public function testInitArray() | ||
78 | { | ||
79 | $this->list = new ObjectChoiceList( | ||
80 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4), | ||
81 | 'name', | ||
82 | array($this->obj2) | ||
83 | ); | ||
84 | |||
85 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
86 | $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); | ||
87 | $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews()); | ||
88 | $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); | ||
89 | } | ||
90 | |||
91 | public function testInitNestedArray() | ||
92 | { | ||
93 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
94 | $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); | ||
95 | $this->assertEquals(array( | ||
96 | 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), | ||
97 | 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) | ||
98 | ), $this->list->getPreferredViews()); | ||
99 | $this->assertEquals(array( | ||
100 | 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), | ||
101 | 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')) | ||
102 | ), $this->list->getRemainingViews()); | ||
103 | } | ||
104 | |||
105 | public function testInitArrayWithGroupPath() | ||
106 | { | ||
107 | $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); | ||
108 | $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); | ||
109 | $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2'); | ||
110 | $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2'); | ||
111 | |||
112 | // Objects with NULL groups are not grouped | ||
113 | $obj5 = (object) array('name' => 'E', 'category' => null); | ||
114 | |||
115 | // Objects without the group property are not grouped either | ||
116 | // see https://github.com/symfony/symfony/commit/d9b7abb7c7a0f28e0ce970afc5e305dce5dccddf | ||
117 | $obj6 = (object) array('name' => 'F'); | ||
118 | |||
119 | $this->list = new ObjectChoiceList( | ||
120 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6), | ||
121 | 'name', | ||
122 | array($this->obj2, $this->obj3), | ||
123 | 'category' | ||
124 | ); | ||
125 | |||
126 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6), $this->list->getChoices()); | ||
127 | $this->assertSame(array('0', '1', '2', '3', '4', '5'), $this->list->getValues()); | ||
128 | $this->assertEquals(array( | ||
129 | 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), | ||
130 | 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) | ||
131 | ), $this->list->getPreferredViews()); | ||
132 | $this->assertEquals(array( | ||
133 | 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), | ||
134 | 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), | ||
135 | 4 => new ChoiceView($obj5, '4', 'E'), | ||
136 | 5 => new ChoiceView($obj6, '5', 'F'), | ||
137 | ), $this->list->getRemainingViews()); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @expectedException \InvalidArgumentException | ||
142 | */ | ||
143 | public function testInitArrayWithGroupPathThrowsExceptionIfNestedArray() | ||
144 | { | ||
145 | $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); | ||
146 | $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); | ||
147 | $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2'); | ||
148 | $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2'); | ||
149 | |||
150 | new ObjectChoiceList( | ||
151 | array( | ||
152 | 'Group 1' => array($this->obj1, $this->obj2), | ||
153 | 'Group 2' => array($this->obj3, $this->obj4), | ||
154 | ), | ||
155 | 'name', | ||
156 | array($this->obj2, $this->obj3), | ||
157 | 'category' | ||
158 | ); | ||
159 | } | ||
160 | |||
161 | public function testInitArrayWithValuePath() | ||
162 | { | ||
163 | $this->obj1 = (object) array('name' => 'A', 'id' => 10); | ||
164 | $this->obj2 = (object) array('name' => 'B', 'id' => 20); | ||
165 | $this->obj3 = (object) array('name' => 'C', 'id' => 30); | ||
166 | $this->obj4 = (object) array('name' => 'D', 'id' => 40); | ||
167 | |||
168 | $this->list = new ObjectChoiceList( | ||
169 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4), | ||
170 | 'name', | ||
171 | array($this->obj2, $this->obj3), | ||
172 | null, | ||
173 | 'id' | ||
174 | ); | ||
175 | |||
176 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
177 | $this->assertSame(array('10', '20', '30', '40'), $this->list->getValues()); | ||
178 | $this->assertEquals(array(1 => new ChoiceView($this->obj2, '20', 'B'), 2 => new ChoiceView($this->obj3, '30', 'C')), $this->list->getPreferredViews()); | ||
179 | $this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews()); | ||
180 | } | ||
181 | |||
182 | public function testInitArrayUsesToString() | ||
183 | { | ||
184 | $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); | ||
185 | $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); | ||
186 | $this->obj3 = new ObjectChoiceListTest_EntityWithToString('C'); | ||
187 | $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D'); | ||
188 | |||
189 | $this->list = new ObjectChoiceList( | ||
190 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4) | ||
191 | ); | ||
192 | |||
193 | $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); | ||
194 | $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); | ||
195 | $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * @expectedException \Symfony\Component\Form\Exception\StringCastException | ||
200 | */ | ||
201 | public function testInitArrayThrowsExceptionIfToStringNotFound() | ||
202 | { | ||
203 | $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); | ||
204 | $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); | ||
205 | $this->obj3 = (object) array('name' => 'C'); | ||
206 | $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D'); | ||
207 | |||
208 | new ObjectChoiceList( | ||
209 | array($this->obj1, $this->obj2, $this->obj3, $this->obj4) | ||
210 | ); | ||
211 | } | ||
212 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php deleted file mode 100644 index 69d27a18..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
16 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
17 | |||
18 | class SimpleChoiceListTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | private $list; | ||
21 | |||
22 | private $numericList; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | parent::setUp(); | ||
27 | |||
28 | $choices = array( | ||
29 | 'Group 1' => array('a' => 'A', 'b' => 'B'), | ||
30 | 'Group 2' => array('c' => 'C', 'd' => 'D'), | ||
31 | ); | ||
32 | $numericChoices = array( | ||
33 | 'Group 1' => array(0 => 'A', 1 => 'B'), | ||
34 | 'Group 2' => array(2 => 'C', 3 => 'D'), | ||
35 | ); | ||
36 | |||
37 | $this->list = new SimpleChoiceList($choices, array('b', 'c')); | ||
38 | |||
39 | // Use COPY_CHOICE strategy to test for the various associated problems | ||
40 | $this->numericList = new SimpleChoiceList($numericChoices, array(1, 2)); | ||
41 | } | ||
42 | |||
43 | protected function tearDown() | ||
44 | { | ||
45 | parent::tearDown(); | ||
46 | |||
47 | $this->list = null; | ||
48 | $this->numericList = null; | ||
49 | } | ||
50 | |||
51 | public function testInitArray() | ||
52 | { | ||
53 | $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C'); | ||
54 | $this->list = new SimpleChoiceList($choices, array('b')); | ||
55 | |||
56 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices()); | ||
57 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues()); | ||
58 | $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews()); | ||
59 | $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews()); | ||
60 | } | ||
61 | |||
62 | public function testInitNestedArray() | ||
63 | { | ||
64 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices()); | ||
65 | $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues()); | ||
66 | $this->assertEquals(array( | ||
67 | 'Group 1' => array(1 => new ChoiceView('b', 'b', 'B')), | ||
68 | 'Group 2' => array(2 => new ChoiceView('c', 'c', 'C')) | ||
69 | ), $this->list->getPreferredViews()); | ||
70 | $this->assertEquals(array( | ||
71 | 'Group 1' => array(0 => new ChoiceView('a', 'a', 'A')), | ||
72 | 'Group 2' => array(3 => new ChoiceView('d', 'd', 'D')) | ||
73 | ), $this->list->getRemainingViews()); | ||
74 | } | ||
75 | |||
76 | public function testGetIndicesForChoices() | ||
77 | { | ||
78 | $choices = array('b', 'c'); | ||
79 | $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); | ||
80 | } | ||
81 | |||
82 | public function testGetIndicesForChoicesIgnoresNonExistingChoices() | ||
83 | { | ||
84 | $choices = array('b', 'c', 'foobar'); | ||
85 | $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); | ||
86 | } | ||
87 | |||
88 | public function testGetIndicesForChoicesDealsWithNumericChoices() | ||
89 | { | ||
90 | // Pass choices as strings although they are integers | ||
91 | $choices = array('0', '1'); | ||
92 | $this->assertSame(array(0, 1), $this->numericList->getIndicesForChoices($choices)); | ||
93 | } | ||
94 | |||
95 | public function testGetIndicesForValues() | ||
96 | { | ||
97 | $values = array('b', 'c'); | ||
98 | $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); | ||
99 | } | ||
100 | |||
101 | public function testGetIndicesForValuesIgnoresNonExistingValues() | ||
102 | { | ||
103 | $values = array('b', 'c', '100'); | ||
104 | $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); | ||
105 | } | ||
106 | |||
107 | public function testGetIndicesForValuesDealsWithNumericValues() | ||
108 | { | ||
109 | // Pass values as strings although they are integers | ||
110 | $values = array('0', '1'); | ||
111 | $this->assertSame(array(0, 1), $this->numericList->getIndicesForValues($values)); | ||
112 | } | ||
113 | |||
114 | public function testGetChoicesForValues() | ||
115 | { | ||
116 | $values = array('b', 'c'); | ||
117 | $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values)); | ||
118 | } | ||
119 | |||
120 | public function testGetChoicesForValuesIgnoresNonExistingValues() | ||
121 | { | ||
122 | $values = array('b', 'c', '100'); | ||
123 | $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values)); | ||
124 | } | ||
125 | |||
126 | public function testGetChoicesForValuesDealsWithNumericValues() | ||
127 | { | ||
128 | // Pass values as strings although they are integers | ||
129 | $values = array('0', '1'); | ||
130 | $this->assertSame(array(0, 1), $this->numericList->getChoicesForValues($values)); | ||
131 | } | ||
132 | |||
133 | public function testGetValuesForChoices() | ||
134 | { | ||
135 | $choices = array('b', 'c'); | ||
136 | $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices)); | ||
137 | } | ||
138 | |||
139 | public function testGetValuesForChoicesIgnoresNonExistingValues() | ||
140 | { | ||
141 | $choices = array('b', 'c', 'foobar'); | ||
142 | $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices)); | ||
143 | } | ||
144 | |||
145 | public function testGetValuesForChoicesDealsWithNumericValues() | ||
146 | { | ||
147 | // Pass values as strings although they are integers | ||
148 | $values = array('0', '1'); | ||
149 | |||
150 | $this->assertSame(array('0', '1'), $this->numericList->getValuesForChoices($values)); | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * @dataProvider dirtyValuesProvider | ||
155 | */ | ||
156 | public function testGetValuesForChoicesDealsWithDirtyValues($choice, $value) | ||
157 | { | ||
158 | $choices = array( | ||
159 | '0' => 'Zero', | ||
160 | '1' => 'One', | ||
161 | '' => 'Empty', | ||
162 | '1.23' => 'Float', | ||
163 | 'foo' => 'Foo', | ||
164 | 'foo10' => 'Foo 10', | ||
165 | ); | ||
166 | |||
167 | // use COPY_CHOICE strategy to test the problems | ||
168 | $this->list = new SimpleChoiceList($choices, array()); | ||
169 | |||
170 | $this->assertSame(array($value), $this->list->getValuesForChoices(array($choice))); | ||
171 | } | ||
172 | |||
173 | public function dirtyValuesProvider() | ||
174 | { | ||
175 | return array( | ||
176 | array(0, '0'), | ||
177 | array('0', '0'), | ||
178 | array('1', '1'), | ||
179 | array(false, '0'), | ||
180 | array(true, '1'), | ||
181 | array('', ''), | ||
182 | array(null, ''), | ||
183 | array('1.23', '1.23'), | ||
184 | array('foo', 'foo'), | ||
185 | array('foo10', 'foo10'), | ||
186 | ); | ||
187 | } | ||
188 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php deleted file mode 100644 index ee2e3351..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ /dev/null | |||
@@ -1,319 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataMapper; | ||
13 | |||
14 | use Symfony\Component\Form\FormConfigBuilder; | ||
15 | use Symfony\Component\Form\FormConfigInterface; | ||
16 | use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; | ||
17 | |||
18 | class PropertyPathMapperTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | /** | ||
21 | * @var PropertyPathMapper | ||
22 | */ | ||
23 | private $mapper; | ||
24 | |||
25 | /** | ||
26 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
27 | */ | ||
28 | private $dispatcher; | ||
29 | |||
30 | /** | ||
31 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
32 | */ | ||
33 | private $propertyAccessor; | ||
34 | |||
35 | protected function setUp() | ||
36 | { | ||
37 | if (!class_exists('Symfony\Component\EventDispatcher\Event')) { | ||
38 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
39 | } | ||
40 | |||
41 | if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) { | ||
42 | $this->markTestSkipped('The "PropertyAccess" component is not available'); | ||
43 | } | ||
44 | |||
45 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
46 | $this->propertyAccessor = $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface'); | ||
47 | $this->mapper = new PropertyPathMapper($this->propertyAccessor); | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * @param $path | ||
52 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
53 | */ | ||
54 | private function getPropertyPath($path) | ||
55 | { | ||
56 | return $this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyPath') | ||
57 | ->setConstructorArgs(array($path)) | ||
58 | ->setMethods(array('getValue', 'setValue')) | ||
59 | ->getMock(); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * @param FormConfigInterface $config | ||
64 | * @param Boolean $synchronized | ||
65 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
66 | */ | ||
67 | private function getForm(FormConfigInterface $config, $synchronized = true) | ||
68 | { | ||
69 | $form = $this->getMockBuilder('Symfony\Component\Form\Form') | ||
70 | ->setConstructorArgs(array($config)) | ||
71 | ->setMethods(array('isSynchronized')) | ||
72 | ->getMock(); | ||
73 | |||
74 | $form->expects($this->any()) | ||
75 | ->method('isSynchronized') | ||
76 | ->will($this->returnValue($synchronized)); | ||
77 | |||
78 | return $form; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
83 | */ | ||
84 | private function getDataMapper() | ||
85 | { | ||
86 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
87 | } | ||
88 | |||
89 | public function testMapDataToFormsPassesObjectRefIfByReference() | ||
90 | { | ||
91 | $car = new \stdClass(); | ||
92 | $engine = new \stdClass(); | ||
93 | $propertyPath = $this->getPropertyPath('engine'); | ||
94 | |||
95 | $this->propertyAccessor->expects($this->once()) | ||
96 | ->method('getValue') | ||
97 | ->with($car, $propertyPath) | ||
98 | ->will($this->returnValue($engine)); | ||
99 | |||
100 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
101 | $config->setByReference(true); | ||
102 | $config->setPropertyPath($propertyPath); | ||
103 | $form = $this->getForm($config); | ||
104 | |||
105 | $this->mapper->mapDataToForms($car, array($form)); | ||
106 | |||
107 | // Can't use isIdentical() above because mocks always clone their | ||
108 | // arguments which can't be disabled in PHPUnit 3.6 | ||
109 | $this->assertSame($engine, $form->getData()); | ||
110 | } | ||
111 | |||
112 | public function testMapDataToFormsPassesObjectCloneIfNotByReference() | ||
113 | { | ||
114 | $car = new \stdClass(); | ||
115 | $engine = new \stdClass(); | ||
116 | $propertyPath = $this->getPropertyPath('engine'); | ||
117 | |||
118 | $this->propertyAccessor->expects($this->once()) | ||
119 | ->method('getValue') | ||
120 | ->with($car, $propertyPath) | ||
121 | ->will($this->returnValue($engine)); | ||
122 | |||
123 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
124 | $config->setByReference(false); | ||
125 | $config->setPropertyPath($propertyPath); | ||
126 | $form = $this->getForm($config); | ||
127 | |||
128 | $this->mapper->mapDataToForms($car, array($form)); | ||
129 | |||
130 | $this->assertNotSame($engine, $form->getData()); | ||
131 | $this->assertEquals($engine, $form->getData()); | ||
132 | } | ||
133 | |||
134 | public function testMapDataToFormsIgnoresEmptyPropertyPath() | ||
135 | { | ||
136 | $car = new \stdClass(); | ||
137 | |||
138 | $config = new FormConfigBuilder(null, '\stdClass', $this->dispatcher); | ||
139 | $config->setByReference(true); | ||
140 | $form = $this->getForm($config); | ||
141 | |||
142 | $this->assertNull($form->getPropertyPath()); | ||
143 | |||
144 | $this->mapper->mapDataToForms($car, array($form)); | ||
145 | |||
146 | $this->assertNull($form->getData()); | ||
147 | } | ||
148 | |||
149 | public function testMapDataToFormsIgnoresUnmapped() | ||
150 | { | ||
151 | $car = new \stdClass(); | ||
152 | $propertyPath = $this->getPropertyPath('engine'); | ||
153 | |||
154 | $this->propertyAccessor->expects($this->never()) | ||
155 | ->method('getValue'); | ||
156 | |||
157 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
158 | $config->setByReference(true); | ||
159 | $config->setMapped(false); | ||
160 | $config->setPropertyPath($propertyPath); | ||
161 | $form = $this->getForm($config); | ||
162 | |||
163 | $this->mapper->mapDataToForms($car, array($form)); | ||
164 | |||
165 | $this->assertNull($form->getData()); | ||
166 | } | ||
167 | |||
168 | public function testMapDataToFormsIgnoresEmptyData() | ||
169 | { | ||
170 | $propertyPath = $this->getPropertyPath('engine'); | ||
171 | |||
172 | $this->propertyAccessor->expects($this->never()) | ||
173 | ->method('getValue'); | ||
174 | |||
175 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
176 | $config->setByReference(true); | ||
177 | $config->setPropertyPath($propertyPath); | ||
178 | $form = $this->getForm($config); | ||
179 | |||
180 | $this->mapper->mapDataToForms(null, array($form)); | ||
181 | |||
182 | $this->assertNull($form->getData()); | ||
183 | } | ||
184 | |||
185 | public function testMapFormsToDataWritesBackIfNotByReference() | ||
186 | { | ||
187 | $car = new \stdClass(); | ||
188 | $engine = new \stdClass(); | ||
189 | $propertyPath = $this->getPropertyPath('engine'); | ||
190 | |||
191 | $this->propertyAccessor->expects($this->once()) | ||
192 | ->method('setValue') | ||
193 | ->with($car, $propertyPath, $engine); | ||
194 | |||
195 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
196 | $config->setByReference(false); | ||
197 | $config->setPropertyPath($propertyPath); | ||
198 | $config->setData($engine); | ||
199 | $form = $this->getForm($config); | ||
200 | |||
201 | $this->mapper->mapFormsToData(array($form), $car); | ||
202 | } | ||
203 | |||
204 | public function testMapFormsToDataWritesBackIfByReferenceButNoReference() | ||
205 | { | ||
206 | $car = new \stdClass(); | ||
207 | $engine = new \stdClass(); | ||
208 | $propertyPath = $this->getPropertyPath('engine'); | ||
209 | |||
210 | $this->propertyAccessor->expects($this->once()) | ||
211 | ->method('setValue') | ||
212 | ->with($car, $propertyPath, $engine); | ||
213 | |||
214 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
215 | $config->setByReference(true); | ||
216 | $config->setPropertyPath($propertyPath); | ||
217 | $config->setData($engine); | ||
218 | $form = $this->getForm($config); | ||
219 | |||
220 | $this->mapper->mapFormsToData(array($form), $car); | ||
221 | } | ||
222 | |||
223 | public function testMapFormsToDataWritesBackIfByReferenceAndReference() | ||
224 | { | ||
225 | $car = new \stdClass(); | ||
226 | $engine = new \stdClass(); | ||
227 | $propertyPath = $this->getPropertyPath('engine'); | ||
228 | |||
229 | // $car already contains the reference of $engine | ||
230 | $this->propertyAccessor->expects($this->once()) | ||
231 | ->method('getValue') | ||
232 | ->with($car, $propertyPath) | ||
233 | ->will($this->returnValue($engine)); | ||
234 | |||
235 | $this->propertyAccessor->expects($this->never()) | ||
236 | ->method('setValue'); | ||
237 | |||
238 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
239 | $config->setByReference(true); | ||
240 | $config->setPropertyPath($propertyPath); | ||
241 | $config->setData($engine); | ||
242 | $form = $this->getForm($config); | ||
243 | |||
244 | $this->mapper->mapFormsToData(array($form), $car); | ||
245 | } | ||
246 | |||
247 | public function testMapFormsToDataIgnoresUnmapped() | ||
248 | { | ||
249 | $car = new \stdClass(); | ||
250 | $engine = new \stdClass(); | ||
251 | $propertyPath = $this->getPropertyPath('engine'); | ||
252 | |||
253 | $this->propertyAccessor->expects($this->never()) | ||
254 | ->method('setValue'); | ||
255 | |||
256 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
257 | $config->setByReference(true); | ||
258 | $config->setPropertyPath($propertyPath); | ||
259 | $config->setData($engine); | ||
260 | $config->setMapped(false); | ||
261 | $form = $this->getForm($config); | ||
262 | |||
263 | $this->mapper->mapFormsToData(array($form), $car); | ||
264 | } | ||
265 | |||
266 | public function testMapFormsToDataIgnoresEmptyData() | ||
267 | { | ||
268 | $car = new \stdClass(); | ||
269 | $propertyPath = $this->getPropertyPath('engine'); | ||
270 | |||
271 | $this->propertyAccessor->expects($this->never()) | ||
272 | ->method('setValue'); | ||
273 | |||
274 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
275 | $config->setByReference(true); | ||
276 | $config->setPropertyPath($propertyPath); | ||
277 | $config->setData(null); | ||
278 | $form = $this->getForm($config); | ||
279 | |||
280 | $this->mapper->mapFormsToData(array($form), $car); | ||
281 | } | ||
282 | |||
283 | public function testMapFormsToDataIgnoresUnsynchronized() | ||
284 | { | ||
285 | $car = new \stdClass(); | ||
286 | $engine = new \stdClass(); | ||
287 | $propertyPath = $this->getPropertyPath('engine'); | ||
288 | |||
289 | $this->propertyAccessor->expects($this->never()) | ||
290 | ->method('setValue'); | ||
291 | |||
292 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
293 | $config->setByReference(true); | ||
294 | $config->setPropertyPath($propertyPath); | ||
295 | $config->setData($engine); | ||
296 | $form = $this->getForm($config, false); | ||
297 | |||
298 | $this->mapper->mapFormsToData(array($form), $car); | ||
299 | } | ||
300 | |||
301 | public function testMapFormsToDataIgnoresDisabled() | ||
302 | { | ||
303 | $car = new \stdClass(); | ||
304 | $engine = new \stdClass(); | ||
305 | $propertyPath = $this->getPropertyPath('engine'); | ||
306 | |||
307 | $this->propertyAccessor->expects($this->never()) | ||
308 | ->method('setValue'); | ||
309 | |||
310 | $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); | ||
311 | $config->setByReference(true); | ||
312 | $config->setPropertyPath($propertyPath); | ||
313 | $config->setData($engine); | ||
314 | $config->setDisabled(true); | ||
315 | $form = $this->getForm($config); | ||
316 | |||
317 | $this->mapper->mapFormsToData(array($form), $car); | ||
318 | } | ||
319 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php deleted file mode 100644 index bafe5c09..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; | ||
15 | |||
16 | class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | private $transformer; | ||
19 | |||
20 | protected function setUp() | ||
21 | { | ||
22 | $this->transformer = new ArrayToPartsTransformer(array( | ||
23 | 'first' => array('a', 'b', 'c'), | ||
24 | 'second' => array('d', 'e', 'f'), | ||
25 | )); | ||
26 | } | ||
27 | |||
28 | protected function tearDown() | ||
29 | { | ||
30 | $this->transformer = null; | ||
31 | } | ||
32 | |||
33 | public function testTransform() | ||
34 | { | ||
35 | $input = array( | ||
36 | 'a' => '1', | ||
37 | 'b' => '2', | ||
38 | 'c' => '3', | ||
39 | 'd' => '4', | ||
40 | 'e' => '5', | ||
41 | 'f' => '6', | ||
42 | ); | ||
43 | |||
44 | $output = array( | ||
45 | 'first' => array( | ||
46 | 'a' => '1', | ||
47 | 'b' => '2', | ||
48 | 'c' => '3', | ||
49 | ), | ||
50 | 'second' => array( | ||
51 | 'd' => '4', | ||
52 | 'e' => '5', | ||
53 | 'f' => '6', | ||
54 | ), | ||
55 | ); | ||
56 | |||
57 | $this->assertSame($output, $this->transformer->transform($input)); | ||
58 | } | ||
59 | |||
60 | public function testTransformEmpty() | ||
61 | { | ||
62 | $output = array( | ||
63 | 'first' => null, | ||
64 | 'second' => null, | ||
65 | ); | ||
66 | |||
67 | $this->assertSame($output, $this->transformer->transform(null)); | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
72 | */ | ||
73 | public function testTransformRequiresArray() | ||
74 | { | ||
75 | $this->transformer->transform('12345'); | ||
76 | } | ||
77 | |||
78 | public function testReverseTransform() | ||
79 | { | ||
80 | $input = array( | ||
81 | 'first' => array( | ||
82 | 'a' => '1', | ||
83 | 'b' => '2', | ||
84 | 'c' => '3', | ||
85 | ), | ||
86 | 'second' => array( | ||
87 | 'd' => '4', | ||
88 | 'e' => '5', | ||
89 | 'f' => '6', | ||
90 | ), | ||
91 | ); | ||
92 | |||
93 | $output = array( | ||
94 | 'a' => '1', | ||
95 | 'b' => '2', | ||
96 | 'c' => '3', | ||
97 | 'd' => '4', | ||
98 | 'e' => '5', | ||
99 | 'f' => '6', | ||
100 | ); | ||
101 | |||
102 | $this->assertSame($output, $this->transformer->reverseTransform($input)); | ||
103 | } | ||
104 | |||
105 | public function testReverseTransformCompletelyEmpty() | ||
106 | { | ||
107 | $input = array( | ||
108 | 'first' => '', | ||
109 | 'second' => '', | ||
110 | ); | ||
111 | |||
112 | $this->assertNull($this->transformer->reverseTransform($input)); | ||
113 | } | ||
114 | |||
115 | public function testReverseTransformCompletelyNull() | ||
116 | { | ||
117 | $input = array( | ||
118 | 'first' => null, | ||
119 | 'second' => null, | ||
120 | ); | ||
121 | |||
122 | $this->assertNull($this->transformer->reverseTransform($input)); | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
127 | */ | ||
128 | public function testReverseTransformPartiallyNull() | ||
129 | { | ||
130 | $input = array( | ||
131 | 'first' => array( | ||
132 | 'a' => '1', | ||
133 | 'b' => '2', | ||
134 | 'c' => '3', | ||
135 | ), | ||
136 | 'second' => null, | ||
137 | ); | ||
138 | |||
139 | $this->transformer->reverseTransform($input); | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
144 | */ | ||
145 | public function testReverseTransformRequiresArray() | ||
146 | { | ||
147 | $this->transformer->reverseTransform('12345'); | ||
148 | } | ||
149 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php deleted file mode 100644 index 41f8f956..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer; | ||
15 | |||
16 | class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | const TRUE_VALUE = '1'; | ||
19 | |||
20 | protected $transformer; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | $this->transformer = new BooleanToStringTransformer(self::TRUE_VALUE); | ||
25 | } | ||
26 | |||
27 | protected function tearDown() | ||
28 | { | ||
29 | $this->transformer = null; | ||
30 | } | ||
31 | |||
32 | public function testTransform() | ||
33 | { | ||
34 | $this->assertEquals(self::TRUE_VALUE, $this->transformer->transform(true)); | ||
35 | $this->assertNull($this->transformer->transform(false)); | ||
36 | $this->assertNull($this->transformer->transform(null)); | ||
37 | } | ||
38 | |||
39 | public function testTransformExpectsBoolean() | ||
40 | { | ||
41 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
42 | |||
43 | $this->transformer->transform('1'); | ||
44 | } | ||
45 | |||
46 | public function testReverseTransformExpectsString() | ||
47 | { | ||
48 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
49 | |||
50 | $this->transformer->reverseTransform(1); | ||
51 | } | ||
52 | |||
53 | public function testReverseTransform() | ||
54 | { | ||
55 | $this->assertTrue($this->transformer->reverseTransform(self::TRUE_VALUE)); | ||
56 | $this->assertTrue($this->transformer->reverseTransform('foobar')); | ||
57 | $this->assertTrue($this->transformer->reverseTransform('')); | ||
58 | $this->assertFalse($this->transformer->reverseTransform(null)); | ||
59 | } | ||
60 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php deleted file mode 100644 index bbae0621..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer; | ||
16 | |||
17 | class ChoiceToValueTransformerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected $transformer; | ||
20 | |||
21 | protected function setUp() | ||
22 | { | ||
23 | $list = new SimpleChoiceList(array('' => 'A', 0 => 'B', 1 => 'C')); | ||
24 | $this->transformer = new ChoiceToValueTransformer($list); | ||
25 | } | ||
26 | |||
27 | protected function tearDown() | ||
28 | { | ||
29 | $this->transformer = null; | ||
30 | } | ||
31 | |||
32 | public function transformProvider() | ||
33 | { | ||
34 | return array( | ||
35 | // more extensive test set can be found in FormUtilTest | ||
36 | array(0, '0'), | ||
37 | array(false, '0'), | ||
38 | array('', ''), | ||
39 | ); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @dataProvider transformProvider | ||
44 | */ | ||
45 | public function testTransform($in, $out) | ||
46 | { | ||
47 | $this->assertSame($out, $this->transformer->transform($in)); | ||
48 | } | ||
49 | |||
50 | public function reverseTransformProvider() | ||
51 | { | ||
52 | return array( | ||
53 | // values are expected to be valid choice keys already and stay | ||
54 | // the same | ||
55 | array('0', 0), | ||
56 | array('', null), | ||
57 | array(null, null), | ||
58 | ); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * @dataProvider reverseTransformProvider | ||
63 | */ | ||
64 | public function testReverseTransform($in, $out) | ||
65 | { | ||
66 | $this->assertSame($out, $this->transformer->reverseTransform($in)); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
71 | */ | ||
72 | public function testReverseTransformExpectsScalar() | ||
73 | { | ||
74 | $this->transformer->reverseTransform(array()); | ||
75 | } | ||
76 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php deleted file mode 100644 index 57297193..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
15 | |||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; | ||
17 | |||
18 | class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | protected $transformer; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B', 2 => 'C')); | ||
25 | $this->transformer = new ChoicesToValuesTransformer($list); | ||
26 | } | ||
27 | |||
28 | protected function tearDown() | ||
29 | { | ||
30 | $this->transformer = null; | ||
31 | } | ||
32 | |||
33 | public function testTransform() | ||
34 | { | ||
35 | // Value strategy in SimpleChoiceList is to copy and convert to string | ||
36 | $in = array(0, 1, 2); | ||
37 | $out = array('0', '1', '2'); | ||
38 | |||
39 | $this->assertSame($out, $this->transformer->transform($in)); | ||
40 | } | ||
41 | |||
42 | public function testTransformNull() | ||
43 | { | ||
44 | $this->assertSame(array(), $this->transformer->transform(null)); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
49 | */ | ||
50 | public function testTransformExpectsArray() | ||
51 | { | ||
52 | $this->transformer->transform('foobar'); | ||
53 | } | ||
54 | |||
55 | public function testReverseTransform() | ||
56 | { | ||
57 | // values are expected to be valid choices and stay the same | ||
58 | $in = array('0', '1', '2'); | ||
59 | $out = array(0, 1, 2); | ||
60 | |||
61 | $this->assertSame($out, $this->transformer->reverseTransform($in)); | ||
62 | } | ||
63 | |||
64 | public function testReverseTransformNull() | ||
65 | { | ||
66 | $this->assertSame(array(), $this->transformer->reverseTransform(null)); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
71 | */ | ||
72 | public function testReverseTransformExpectsArray() | ||
73 | { | ||
74 | $this->transformer->reverseTransform('foobar'); | ||
75 | } | ||
76 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php deleted file mode 100644 index 2ee2f22d..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; | ||
15 | |||
16 | class DataTransformerChainTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | public function testTransform() | ||
19 | { | ||
20 | $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | ||
21 | $transformer1->expects($this->once()) | ||
22 | ->method('transform') | ||
23 | ->with($this->identicalTo('foo')) | ||
24 | ->will($this->returnValue('bar')); | ||
25 | $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | ||
26 | $transformer2->expects($this->once()) | ||
27 | ->method('transform') | ||
28 | ->with($this->identicalTo('bar')) | ||
29 | ->will($this->returnValue('baz')); | ||
30 | |||
31 | $chain = new DataTransformerChain(array($transformer1, $transformer2)); | ||
32 | |||
33 | $this->assertEquals('baz', $chain->transform('foo')); | ||
34 | } | ||
35 | |||
36 | public function testReverseTransform() | ||
37 | { | ||
38 | $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | ||
39 | $transformer2->expects($this->once()) | ||
40 | ->method('reverseTransform') | ||
41 | ->with($this->identicalTo('foo')) | ||
42 | ->will($this->returnValue('bar')); | ||
43 | $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | ||
44 | $transformer1->expects($this->once()) | ||
45 | ->method('reverseTransform') | ||
46 | ->with($this->identicalTo('bar')) | ||
47 | ->will($this->returnValue('baz')); | ||
48 | |||
49 | $chain = new DataTransformerChain(array($transformer1, $transformer2)); | ||
50 | |||
51 | $this->assertEquals('baz', $chain->reverseTransform('foo')); | ||
52 | } | ||
53 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php deleted file mode 100644 index f7722c49..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase | ||
15 | { | ||
16 | public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual) | ||
17 | { | ||
18 | self::assertEquals($expected->format('c'), $actual->format('c')); | ||
19 | } | ||
20 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php deleted file mode 100644 index 4898b88d..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ /dev/null | |||
@@ -1,512 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; | ||
15 | |||
16 | class DateTimeToArrayTransformerTest extends DateTimeTestCase | ||
17 | { | ||
18 | public function testTransform() | ||
19 | { | ||
20 | $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); | ||
21 | |||
22 | $input = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
23 | |||
24 | $output = array( | ||
25 | 'year' => '2010', | ||
26 | 'month' => '2', | ||
27 | 'day' => '3', | ||
28 | 'hour' => '4', | ||
29 | 'minute' => '5', | ||
30 | 'second' => '6', | ||
31 | ); | ||
32 | |||
33 | $this->assertSame($output, $transformer->transform($input)); | ||
34 | } | ||
35 | |||
36 | public function testTransformEmpty() | ||
37 | { | ||
38 | $transformer = new DateTimeToArrayTransformer(); | ||
39 | |||
40 | $output = array( | ||
41 | 'year' => '', | ||
42 | 'month' => '', | ||
43 | 'day' => '', | ||
44 | 'hour' => '', | ||
45 | 'minute' => '', | ||
46 | 'second' => '', | ||
47 | ); | ||
48 | |||
49 | $this->assertSame($output, $transformer->transform(null)); | ||
50 | } | ||
51 | |||
52 | public function testTransformEmptyWithFields() | ||
53 | { | ||
54 | $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second')); | ||
55 | |||
56 | $output = array( | ||
57 | 'year' => '', | ||
58 | 'minute' => '', | ||
59 | 'second' => '', | ||
60 | ); | ||
61 | |||
62 | $this->assertSame($output, $transformer->transform(null)); | ||
63 | } | ||
64 | |||
65 | public function testTransformWithFields() | ||
66 | { | ||
67 | $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second')); | ||
68 | |||
69 | $input = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
70 | |||
71 | $output = array( | ||
72 | 'year' => '2010', | ||
73 | 'month' => '2', | ||
74 | 'minute' => '5', | ||
75 | 'second' => '6', | ||
76 | ); | ||
77 | |||
78 | $this->assertSame($output, $transformer->transform($input)); | ||
79 | } | ||
80 | |||
81 | public function testTransformWithPadding() | ||
82 | { | ||
83 | $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true); | ||
84 | |||
85 | $input = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
86 | |||
87 | $output = array( | ||
88 | 'year' => '2010', | ||
89 | 'month' => '02', | ||
90 | 'day' => '03', | ||
91 | 'hour' => '04', | ||
92 | 'minute' => '05', | ||
93 | 'second' => '06', | ||
94 | ); | ||
95 | |||
96 | $this->assertSame($output, $transformer->transform($input)); | ||
97 | } | ||
98 | |||
99 | public function testTransformDifferentTimezones() | ||
100 | { | ||
101 | $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); | ||
102 | |||
103 | $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); | ||
104 | |||
105 | $dateTime = new \DateTime('2010-02-03 04:05:06 America/New_York'); | ||
106 | $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
107 | $output = array( | ||
108 | 'year' => (string) (int) $dateTime->format('Y'), | ||
109 | 'month' => (string) (int) $dateTime->format('m'), | ||
110 | 'day' => (string) (int) $dateTime->format('d'), | ||
111 | 'hour' => (string) (int) $dateTime->format('H'), | ||
112 | 'minute' => (string) (int) $dateTime->format('i'), | ||
113 | 'second' => (string) (int) $dateTime->format('s'), | ||
114 | ); | ||
115 | |||
116 | $this->assertSame($output, $transformer->transform($input)); | ||
117 | } | ||
118 | |||
119 | /** | ||
120 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
121 | */ | ||
122 | public function testTransformRequiresDateTime() | ||
123 | { | ||
124 | $transformer = new DateTimeToArrayTransformer(); | ||
125 | $transformer->reverseTransform('12345'); | ||
126 | } | ||
127 | |||
128 | public function testReverseTransform() | ||
129 | { | ||
130 | $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); | ||
131 | |||
132 | $input = array( | ||
133 | 'year' => '2010', | ||
134 | 'month' => '2', | ||
135 | 'day' => '3', | ||
136 | 'hour' => '4', | ||
137 | 'minute' => '5', | ||
138 | 'second' => '6', | ||
139 | ); | ||
140 | |||
141 | $output = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
142 | |||
143 | $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); | ||
144 | } | ||
145 | |||
146 | public function testReverseTransformWithSomeZero() | ||
147 | { | ||
148 | $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); | ||
149 | |||
150 | $input = array( | ||
151 | 'year' => '2010', | ||
152 | 'month' => '2', | ||
153 | 'day' => '3', | ||
154 | 'hour' => '4', | ||
155 | 'minute' => '0', | ||
156 | 'second' => '0', | ||
157 | ); | ||
158 | |||
159 | $output = new \DateTime('2010-02-03 04:00:00 UTC'); | ||
160 | |||
161 | $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); | ||
162 | } | ||
163 | |||
164 | public function testReverseTransformCompletelyEmpty() | ||
165 | { | ||
166 | $transformer = new DateTimeToArrayTransformer(); | ||
167 | |||
168 | $input = array( | ||
169 | 'year' => '', | ||
170 | 'month' => '', | ||
171 | 'day' => '', | ||
172 | 'hour' => '', | ||
173 | 'minute' => '', | ||
174 | 'second' => '', | ||
175 | ); | ||
176 | |||
177 | $this->assertNull($transformer->reverseTransform($input)); | ||
178 | } | ||
179 | |||
180 | public function testReverseTransformCompletelyEmptySubsetOfFields() | ||
181 | { | ||
182 | $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day')); | ||
183 | |||
184 | $input = array( | ||
185 | 'year' => '', | ||
186 | 'month' => '', | ||
187 | 'day' => '', | ||
188 | ); | ||
189 | |||
190 | $this->assertNull($transformer->reverseTransform($input)); | ||
191 | } | ||
192 | |||
193 | /** | ||
194 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
195 | */ | ||
196 | public function testReverseTransformPartiallyEmptyYear() | ||
197 | { | ||
198 | $transformer = new DateTimeToArrayTransformer(); | ||
199 | $transformer->reverseTransform(array( | ||
200 | 'month' => '2', | ||
201 | 'day' => '3', | ||
202 | 'hour' => '4', | ||
203 | 'minute' => '5', | ||
204 | 'second' => '6', | ||
205 | )); | ||
206 | } | ||
207 | |||
208 | /** | ||
209 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
210 | */ | ||
211 | public function testReverseTransformPartiallyEmptyMonth() | ||
212 | { | ||
213 | $transformer = new DateTimeToArrayTransformer(); | ||
214 | $transformer->reverseTransform(array( | ||
215 | 'year' => '2010', | ||
216 | 'day' => '3', | ||
217 | 'hour' => '4', | ||
218 | 'minute' => '5', | ||
219 | 'second' => '6', | ||
220 | )); | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
225 | */ | ||
226 | public function testReverseTransformPartiallyEmptyDay() | ||
227 | { | ||
228 | $transformer = new DateTimeToArrayTransformer(); | ||
229 | $transformer->reverseTransform(array( | ||
230 | 'year' => '2010', | ||
231 | 'month' => '2', | ||
232 | 'hour' => '4', | ||
233 | 'minute' => '5', | ||
234 | 'second' => '6', | ||
235 | )); | ||
236 | } | ||
237 | |||
238 | /** | ||
239 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
240 | */ | ||
241 | public function testReverseTransformPartiallyEmptyHour() | ||
242 | { | ||
243 | $transformer = new DateTimeToArrayTransformer(); | ||
244 | $transformer->reverseTransform(array( | ||
245 | 'year' => '2010', | ||
246 | 'month' => '2', | ||
247 | 'day' => '3', | ||
248 | 'minute' => '5', | ||
249 | 'second' => '6', | ||
250 | )); | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
255 | */ | ||
256 | public function testReverseTransformPartiallyEmptyMinute() | ||
257 | { | ||
258 | $transformer = new DateTimeToArrayTransformer(); | ||
259 | $transformer->reverseTransform(array( | ||
260 | 'year' => '2010', | ||
261 | 'month' => '2', | ||
262 | 'day' => '3', | ||
263 | 'hour' => '4', | ||
264 | 'second' => '6', | ||
265 | )); | ||
266 | } | ||
267 | |||
268 | /** | ||
269 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
270 | */ | ||
271 | public function testReverseTransformPartiallyEmptySecond() | ||
272 | { | ||
273 | $transformer = new DateTimeToArrayTransformer(); | ||
274 | $transformer->reverseTransform(array( | ||
275 | 'year' => '2010', | ||
276 | 'month' => '2', | ||
277 | 'day' => '3', | ||
278 | 'hour' => '4', | ||
279 | 'minute' => '5', | ||
280 | )); | ||
281 | } | ||
282 | |||
283 | public function testReverseTransformNull() | ||
284 | { | ||
285 | $transformer = new DateTimeToArrayTransformer(); | ||
286 | |||
287 | $this->assertNull($transformer->reverseTransform(null)); | ||
288 | } | ||
289 | |||
290 | public function testReverseTransformDifferentTimezones() | ||
291 | { | ||
292 | $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); | ||
293 | |||
294 | $input = array( | ||
295 | 'year' => '2010', | ||
296 | 'month' => '2', | ||
297 | 'day' => '3', | ||
298 | 'hour' => '4', | ||
299 | 'minute' => '5', | ||
300 | 'second' => '6', | ||
301 | ); | ||
302 | |||
303 | $output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong'); | ||
304 | $output->setTimezone(new \DateTimeZone('America/New_York')); | ||
305 | |||
306 | $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); | ||
307 | } | ||
308 | |||
309 | public function testReverseTransformToDifferentTimezone() | ||
310 | { | ||
311 | $transformer = new DateTimeToArrayTransformer('Asia/Hong_Kong', 'UTC'); | ||
312 | |||
313 | $input = array( | ||
314 | 'year' => '2010', | ||
315 | 'month' => '2', | ||
316 | 'day' => '3', | ||
317 | 'hour' => '4', | ||
318 | 'minute' => '5', | ||
319 | 'second' => '6', | ||
320 | ); | ||
321 | |||
322 | $output = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
323 | $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
324 | |||
325 | $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
330 | */ | ||
331 | public function testReverseTransformRequiresArray() | ||
332 | { | ||
333 | $transformer = new DateTimeToArrayTransformer(); | ||
334 | $transformer->reverseTransform('12345'); | ||
335 | } | ||
336 | |||
337 | /** | ||
338 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
339 | */ | ||
340 | public function testReverseTransformWithNegativeYear() | ||
341 | { | ||
342 | $transformer = new DateTimeToArrayTransformer(); | ||
343 | $transformer->reverseTransform(array( | ||
344 | 'year' => '-1', | ||
345 | 'month' => '2', | ||
346 | 'day' => '3', | ||
347 | 'hour' => '4', | ||
348 | 'minute' => '5', | ||
349 | 'second' => '6', | ||
350 | )); | ||
351 | } | ||
352 | |||
353 | /** | ||
354 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
355 | */ | ||
356 | public function testReverseTransformWithNegativeMonth() | ||
357 | { | ||
358 | $transformer = new DateTimeToArrayTransformer(); | ||
359 | $transformer->reverseTransform(array( | ||
360 | 'year' => '2010', | ||
361 | 'month' => '-1', | ||
362 | 'day' => '3', | ||
363 | 'hour' => '4', | ||
364 | 'minute' => '5', | ||
365 | 'second' => '6', | ||
366 | )); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
371 | */ | ||
372 | public function testReverseTransformWithNegativeDay() | ||
373 | { | ||
374 | $transformer = new DateTimeToArrayTransformer(); | ||
375 | $transformer->reverseTransform(array( | ||
376 | 'year' => '2010', | ||
377 | 'month' => '2', | ||
378 | 'day' => '-1', | ||
379 | 'hour' => '4', | ||
380 | 'minute' => '5', | ||
381 | 'second' => '6', | ||
382 | )); | ||
383 | } | ||
384 | |||
385 | /** | ||
386 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
387 | */ | ||
388 | public function testReverseTransformWithNegativeHour() | ||
389 | { | ||
390 | $transformer = new DateTimeToArrayTransformer(); | ||
391 | $transformer->reverseTransform(array( | ||
392 | 'year' => '2010', | ||
393 | 'month' => '2', | ||
394 | 'day' => '3', | ||
395 | 'hour' => '-1', | ||
396 | 'minute' => '5', | ||
397 | 'second' => '6', | ||
398 | )); | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
403 | */ | ||
404 | public function testReverseTransformWithNegativeMinute() | ||
405 | { | ||
406 | $transformer = new DateTimeToArrayTransformer(); | ||
407 | $transformer->reverseTransform(array( | ||
408 | 'year' => '2010', | ||
409 | 'month' => '2', | ||
410 | 'day' => '3', | ||
411 | 'hour' => '4', | ||
412 | 'minute' => '-1', | ||
413 | 'second' => '6', | ||
414 | )); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
419 | */ | ||
420 | public function testReverseTransformWithNegativeSecond() | ||
421 | { | ||
422 | $transformer = new DateTimeToArrayTransformer(); | ||
423 | $transformer->reverseTransform(array( | ||
424 | 'year' => '2010', | ||
425 | 'month' => '2', | ||
426 | 'day' => '3', | ||
427 | 'hour' => '4', | ||
428 | 'minute' => '5', | ||
429 | 'second' => '-1', | ||
430 | )); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
435 | */ | ||
436 | public function testReverseTransformWithInvalidMonth() | ||
437 | { | ||
438 | $transformer = new DateTimeToArrayTransformer(); | ||
439 | $transformer->reverseTransform(array( | ||
440 | 'year' => '2010', | ||
441 | 'month' => '13', | ||
442 | 'day' => '3', | ||
443 | 'hour' => '4', | ||
444 | 'minute' => '5', | ||
445 | 'second' => '6', | ||
446 | )); | ||
447 | } | ||
448 | |||
449 | /** | ||
450 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
451 | */ | ||
452 | public function testReverseTransformWithInvalidDay() | ||
453 | { | ||
454 | $transformer = new DateTimeToArrayTransformer(); | ||
455 | $transformer->reverseTransform(array( | ||
456 | 'year' => '2010', | ||
457 | 'month' => '2', | ||
458 | 'day' => '31', | ||
459 | 'hour' => '4', | ||
460 | 'minute' => '5', | ||
461 | 'second' => '6', | ||
462 | )); | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
467 | */ | ||
468 | public function testReverseTransformWithStringDay() | ||
469 | { | ||
470 | $transformer = new DateTimeToArrayTransformer(); | ||
471 | $transformer->reverseTransform(array( | ||
472 | 'year' => '2010', | ||
473 | 'month' => '2', | ||
474 | 'day' => 'bazinga', | ||
475 | 'hour' => '4', | ||
476 | 'minute' => '5', | ||
477 | 'second' => '6', | ||
478 | )); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
483 | */ | ||
484 | public function testReverseTransformWithStringMonth() | ||
485 | { | ||
486 | $transformer = new DateTimeToArrayTransformer(); | ||
487 | $transformer->reverseTransform(array( | ||
488 | 'year' => '2010', | ||
489 | 'month' => 'bazinga', | ||
490 | 'day' => '31', | ||
491 | 'hour' => '4', | ||
492 | 'minute' => '5', | ||
493 | 'second' => '6', | ||
494 | )); | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
499 | */ | ||
500 | public function testReverseTransformWithStringYear() | ||
501 | { | ||
502 | $transformer = new DateTimeToArrayTransformer(); | ||
503 | $transformer->reverseTransform(array( | ||
504 | 'year' => 'bazinga', | ||
505 | 'month' => '2', | ||
506 | 'day' => '31', | ||
507 | 'hour' => '4', | ||
508 | 'minute' => '5', | ||
509 | 'second' => '6', | ||
510 | )); | ||
511 | } | ||
512 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php deleted file mode 100644 index cb50fc36..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ /dev/null | |||
@@ -1,275 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase | ||
18 | { | ||
19 | protected $dateTime; | ||
20 | protected $dateTimeWithoutSeconds; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | parent::setUp(); | ||
25 | |||
26 | // Since we test against "de_AT", we need the full implementation | ||
27 | IntlTestHelper::requireFullIntl($this); | ||
28 | |||
29 | \Locale::setDefault('de_AT'); | ||
30 | |||
31 | $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
32 | $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC'); | ||
33 | } | ||
34 | |||
35 | protected function tearDown() | ||
36 | { | ||
37 | $this->dateTime = null; | ||
38 | $this->dateTimeWithoutSeconds = null; | ||
39 | } | ||
40 | |||
41 | public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) | ||
42 | { | ||
43 | if ($expected instanceof \DateTime && $actual instanceof \DateTime) { | ||
44 | $expected = $expected->format('c'); | ||
45 | $actual = $actual->format('c'); | ||
46 | } | ||
47 | |||
48 | parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); | ||
49 | } | ||
50 | |||
51 | public function dataProvider() | ||
52 | { | ||
53 | return array( | ||
54 | array(\IntlDateFormatter::SHORT, null, null, '03.02.10 04:05', '2010-02-03 04:05:00 UTC'), | ||
55 | array(\IntlDateFormatter::MEDIUM, null, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'), | ||
56 | array(\IntlDateFormatter::LONG, null, null, '03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'), | ||
57 | array(\IntlDateFormatter::FULL, null, null, 'Mittwoch, 03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'), | ||
58 | array(\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, null, '03.02.10', '2010-02-03 00:00:00 UTC'), | ||
59 | array(\IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE, null, '03.02.2010', '2010-02-03 00:00:00 UTC'), | ||
60 | array(\IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, '03. Februar 2010', '2010-02-03 00:00:00 UTC'), | ||
61 | array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 03. Februar 2010', '2010-02-03 00:00:00 UTC'), | ||
62 | array(null, \IntlDateFormatter::SHORT, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'), | ||
63 | array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010 04:05:06', '2010-02-03 04:05:06 UTC'), | ||
64 | array(null, \IntlDateFormatter::LONG, null, '03.02.2010 04:05:06 GMT', '2010-02-03 04:05:06 UTC'), | ||
65 | // see below for extra test case for time format FULL | ||
66 | array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'), | ||
67 | array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'), | ||
68 | array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'), | ||
69 | array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'), | ||
70 | array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'), | ||
71 | array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'), | ||
72 | array(null, null, 'yyyy-MM-dd', '2010-02-03', '2010-02-03 00:00:00 UTC'), | ||
73 | array(null, null, 'yyyy-MM', '2010-02', '2010-02-01 00:00:00 UTC'), | ||
74 | array(null, null, 'yyyy', '2010', '2010-01-01 00:00:00 UTC'), | ||
75 | array(null, null, 'dd-MM-yyyy', '03-02-2010', '2010-02-03 00:00:00 UTC'), | ||
76 | array(null, null, 'HH:mm:ss', '04:05:06', '1970-01-01 04:05:06 UTC'), | ||
77 | array(null, null, 'HH:mm:00', '04:05:00', '1970-01-01 04:05:00 UTC'), | ||
78 | array(null, null, 'HH:mm', '04:05', '1970-01-01 04:05:00 UTC'), | ||
79 | array(null, null, 'HH', '04', '1970-01-01 04:00:00 UTC'), | ||
80 | ); | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * @dataProvider dataProvider | ||
85 | */ | ||
86 | public function testTransform($dateFormat, $timeFormat, $pattern, $output, $input) | ||
87 | { | ||
88 | $transformer = new DateTimeToLocalizedStringTransformer( | ||
89 | 'UTC', | ||
90 | 'UTC', | ||
91 | $dateFormat, | ||
92 | $timeFormat, | ||
93 | \IntlDateFormatter::GREGORIAN, | ||
94 | $pattern | ||
95 | ); | ||
96 | |||
97 | $input = new \DateTime($input); | ||
98 | |||
99 | $this->assertEquals($output, $transformer->transform($input)); | ||
100 | } | ||
101 | |||
102 | public function testTransformFullTime() | ||
103 | { | ||
104 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); | ||
105 | |||
106 | $this->assertEquals('03.02.2010 04:05:06 GMT', $transformer->transform($this->dateTime)); | ||
107 | } | ||
108 | |||
109 | public function testTransformToDifferentLocale() | ||
110 | { | ||
111 | \Locale::setDefault('en_US'); | ||
112 | |||
113 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); | ||
114 | |||
115 | $this->assertEquals('Feb 3, 2010, 4:05 AM', $transformer->transform($this->dateTime)); | ||
116 | } | ||
117 | |||
118 | public function testTransformEmpty() | ||
119 | { | ||
120 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
121 | |||
122 | $this->assertSame('', $transformer->transform(null)); | ||
123 | } | ||
124 | |||
125 | public function testTransformWithDifferentTimezones() | ||
126 | { | ||
127 | $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); | ||
128 | |||
129 | $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); | ||
130 | |||
131 | $dateTime = clone $input; | ||
132 | $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
133 | |||
134 | $this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input)); | ||
135 | } | ||
136 | |||
137 | public function testTransformWithDifferentPatterns() | ||
138 | { | ||
139 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); | ||
140 | |||
141 | $this->assertEquals('02*2010*03 04|05|06', $transformer->transform($this->dateTime)); | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
146 | */ | ||
147 | public function testTransformRequiresValidDateTime() | ||
148 | { | ||
149 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
150 | $transformer->transform('2010-01-01'); | ||
151 | } | ||
152 | |||
153 | public function testTransformWrapsIntlErrors() | ||
154 | { | ||
155 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
156 | |||
157 | // HOW TO REPRODUCE? | ||
158 | |||
159 | //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException'); | ||
160 | |||
161 | //$transformer->transform(1.5); | ||
162 | } | ||
163 | |||
164 | /** | ||
165 | * @dataProvider dataProvider | ||
166 | */ | ||
167 | public function testReverseTransform($dateFormat, $timeFormat, $pattern, $input, $output) | ||
168 | { | ||
169 | $transformer = new DateTimeToLocalizedStringTransformer( | ||
170 | 'UTC', | ||
171 | 'UTC', | ||
172 | $dateFormat, | ||
173 | $timeFormat, | ||
174 | \IntlDateFormatter::GREGORIAN, | ||
175 | $pattern | ||
176 | ); | ||
177 | |||
178 | $output = new \DateTime($output); | ||
179 | |||
180 | $this->assertEquals($output, $transformer->reverseTransform($input)); | ||
181 | } | ||
182 | |||
183 | public function testReverseTransformFullTime() | ||
184 | { | ||
185 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); | ||
186 | |||
187 | $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010 04:05:06 GMT+00:00')); | ||
188 | } | ||
189 | |||
190 | public function testReverseTransformFromDifferentLocale() | ||
191 | { | ||
192 | \Locale::setDefault('en_US'); | ||
193 | |||
194 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); | ||
195 | |||
196 | $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM')); | ||
197 | } | ||
198 | |||
199 | public function testReverseTransformWithDifferentTimezones() | ||
200 | { | ||
201 | $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); | ||
202 | |||
203 | $dateTime = new \DateTime('2010-02-03 04:05:00 Asia/Hong_Kong'); | ||
204 | $dateTime->setTimezone(new \DateTimeZone('America/New_York')); | ||
205 | |||
206 | $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010 04:05')); | ||
207 | } | ||
208 | |||
209 | public function testReverseTransformWithDifferentPatterns() | ||
210 | { | ||
211 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); | ||
212 | |||
213 | $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06')); | ||
214 | } | ||
215 | |||
216 | public function testReverseTransformEmpty() | ||
217 | { | ||
218 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
219 | |||
220 | $this->assertNull($transformer->reverseTransform('')); | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
225 | */ | ||
226 | public function testReverseTransformRequiresString() | ||
227 | { | ||
228 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
229 | $transformer->reverseTransform(12345); | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
234 | */ | ||
235 | public function testReverseTransformWrapsIntlErrors() | ||
236 | { | ||
237 | $transformer = new DateTimeToLocalizedStringTransformer(); | ||
238 | $transformer->reverseTransform('12345'); | ||
239 | } | ||
240 | |||
241 | /** | ||
242 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
243 | */ | ||
244 | public function testValidateDateFormatOption() | ||
245 | { | ||
246 | new DateTimeToLocalizedStringTransformer(null, null, 'foobar'); | ||
247 | } | ||
248 | |||
249 | /** | ||
250 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
251 | */ | ||
252 | public function testValidateTimeFormatOption() | ||
253 | { | ||
254 | new DateTimeToLocalizedStringTransformer(null, null, null, 'foobar'); | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
259 | */ | ||
260 | public function testReverseTransformWithNonExistingDate() | ||
261 | { | ||
262 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT); | ||
263 | |||
264 | $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05')); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
269 | */ | ||
270 | public function testReverseTransformOutOfTimestampRange() | ||
271 | { | ||
272 | $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); | ||
273 | $transformer->reverseTransform('1789-07-14'); | ||
274 | } | ||
275 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php deleted file mode 100644 index 98aeb772..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; | ||
15 | |||
16 | class DateTimeToRfc3339TransformerTest extends DateTimeTestCase | ||
17 | { | ||
18 | protected $dateTime; | ||
19 | protected $dateTimeWithoutSeconds; | ||
20 | |||
21 | protected function setUp() | ||
22 | { | ||
23 | parent::setUp(); | ||
24 | |||
25 | $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
26 | $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC'); | ||
27 | } | ||
28 | |||
29 | protected function tearDown() | ||
30 | { | ||
31 | $this->dateTime = null; | ||
32 | $this->dateTimeWithoutSeconds = null; | ||
33 | } | ||
34 | |||
35 | public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) | ||
36 | { | ||
37 | if ($expected instanceof \DateTime && $actual instanceof \DateTime) { | ||
38 | $expected = $expected->format('c'); | ||
39 | $actual = $actual->format('c'); | ||
40 | } | ||
41 | |||
42 | parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); | ||
43 | } | ||
44 | |||
45 | public function allProvider() | ||
46 | { | ||
47 | return array( | ||
48 | array('UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06Z'), | ||
49 | array('UTC', 'UTC', null, ''), | ||
50 | array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:06 America/New_York', '2010-02-03T17:05:06+08:00'), | ||
51 | array('America/New_York', 'Asia/Hong_Kong', null, ''), | ||
52 | array('UTC', 'Asia/Hong_Kong', '2010-02-03 04:05:06 UTC', '2010-02-03T12:05:06+08:00'), | ||
53 | array('America/New_York', 'UTC', '2010-02-03 04:05:06 America/New_York', '2010-02-03T09:05:06Z'), | ||
54 | ); | ||
55 | } | ||
56 | |||
57 | public function transformProvider() | ||
58 | { | ||
59 | return $this->allProvider(); | ||
60 | } | ||
61 | |||
62 | public function reverseTransformProvider() | ||
63 | { | ||
64 | return array_merge($this->allProvider(), array( | ||
65 | // format without seconds, as appears in some browsers | ||
66 | array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'), | ||
67 | array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'), | ||
68 | )); | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * @dataProvider transformProvider | ||
73 | */ | ||
74 | public function testTransform($fromTz, $toTz, $from, $to) | ||
75 | { | ||
76 | $transformer = new DateTimeToRfc3339Transformer($fromTz, $toTz); | ||
77 | |||
78 | $this->assertSame($to, $transformer->transform(null !== $from ? new \DateTime($from) : null)); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
83 | */ | ||
84 | public function testTransformRequiresValidDateTime() | ||
85 | { | ||
86 | $transformer = new DateTimeToRfc3339Transformer(); | ||
87 | $transformer->transform('2010-01-01'); | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @dataProvider reverseTransformProvider | ||
92 | */ | ||
93 | public function testReverseTransform($toTz, $fromTz, $to, $from) | ||
94 | { | ||
95 | $transformer = new DateTimeToRfc3339Transformer($toTz, $fromTz); | ||
96 | |||
97 | if (null !== $to) { | ||
98 | $this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from)); | ||
99 | } else { | ||
100 | $this->assertSame($to, $transformer->reverseTransform($from)); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /** | ||
105 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
106 | */ | ||
107 | public function testReverseTransformRequiresString() | ||
108 | { | ||
109 | $transformer = new DateTimeToRfc3339Transformer(); | ||
110 | $transformer->reverseTransform(12345); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
115 | */ | ||
116 | public function testReverseTransformWithNonExistingDate() | ||
117 | { | ||
118 | $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); | ||
119 | |||
120 | $transformer->reverseTransform('2010-04-31T04:05Z'); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
125 | */ | ||
126 | public function testReverseTransformExpectsValidDateString() | ||
127 | { | ||
128 | $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); | ||
129 | |||
130 | $transformer->reverseTransform('2010-2010-2010'); | ||
131 | } | ||
132 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php deleted file mode 100644 index 987df1d8..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; | ||
15 | |||
16 | class DateTimeToStringTransformerTest extends DateTimeTestCase | ||
17 | { | ||
18 | public function dataProvider() | ||
19 | { | ||
20 | $data = array( | ||
21 | array('Y-m-d H:i:s', '2010-02-03 16:05:06', '2010-02-03 16:05:06 UTC'), | ||
22 | array('Y-m-d H:i:00', '2010-02-03 16:05:00', '2010-02-03 16:05:00 UTC'), | ||
23 | array('Y-m-d H:i', '2010-02-03 16:05', '2010-02-03 16:05:00 UTC'), | ||
24 | array('Y-m-d H', '2010-02-03 16', '2010-02-03 16:00:00 UTC'), | ||
25 | array('Y-m-d', '2010-02-03', '2010-02-03 00:00:00 UTC'), | ||
26 | array('Y-m', '2010-12', '2010-12-01 00:00:00 UTC'), | ||
27 | array('Y', '2010', '2010-01-01 00:00:00 UTC'), | ||
28 | array('d-m-Y', '03-02-2010', '2010-02-03 00:00:00 UTC'), | ||
29 | array('H:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'), | ||
30 | array('H:i:00', '16:05:00', '1970-01-01 16:05:00 UTC'), | ||
31 | array('H:i', '16:05', '1970-01-01 16:05:00 UTC'), | ||
32 | array('H', '16', '1970-01-01 16:00:00 UTC'), | ||
33 | |||
34 | // different day representations | ||
35 | array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'), | ||
36 | array('z', '33', '1970-02-03 00:00:00 UTC'), | ||
37 | |||
38 | // not bijective | ||
39 | // this will not work as php will use actual date to replace missing info | ||
40 | // and after change of date will lookup for closest Wednesday | ||
41 | // i.e. value: 2010-02, php value: 2010-02-(today i.e. 20), parsed date: 2010-02-24 | ||
42 | //array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'), | ||
43 | //array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'), | ||
44 | |||
45 | // different month representations | ||
46 | array('Y-n-d', '2010-2-03', '2010-02-03 00:00:00 UTC'), | ||
47 | array('Y-M-d', '2010-Feb-03', '2010-02-03 00:00:00 UTC'), | ||
48 | array('Y-F-d', '2010-February-03', '2010-02-03 00:00:00 UTC'), | ||
49 | |||
50 | // different year representations | ||
51 | array('y-m-d', '10-02-03', '2010-02-03 00:00:00 UTC'), | ||
52 | |||
53 | // different time representations | ||
54 | array('G:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'), | ||
55 | array('g:i:s a', '4:05:06 pm', '1970-01-01 16:05:06 UTC'), | ||
56 | array('h:i:s a', '04:05:06 pm', '1970-01-01 16:05:06 UTC'), | ||
57 | |||
58 | // seconds since unix | ||
59 | array('U', '1265213106', '2010-02-03 16:05:06 UTC'), | ||
60 | ); | ||
61 | |||
62 | // This test will fail < 5.3.9 - see https://bugs.php.net/51994 | ||
63 | if (version_compare(phpversion(), '5.3.9', '>=')) { | ||
64 | $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); | ||
65 | } | ||
66 | |||
67 | return $data; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * @dataProvider dataProvider | ||
72 | */ | ||
73 | public function testTransform($format, $output, $input) | ||
74 | { | ||
75 | $transformer = new DateTimeToStringTransformer('UTC', 'UTC', $format); | ||
76 | |||
77 | $input = new \DateTime($input); | ||
78 | |||
79 | $this->assertEquals($output, $transformer->transform($input)); | ||
80 | } | ||
81 | |||
82 | public function testTransformEmpty() | ||
83 | { | ||
84 | $transformer = new DateTimeToStringTransformer(); | ||
85 | |||
86 | $this->assertSame('', $transformer->transform(null)); | ||
87 | } | ||
88 | |||
89 | public function testTransformWithDifferentTimezones() | ||
90 | { | ||
91 | $transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s'); | ||
92 | |||
93 | $input = new \DateTime('2010-02-03 12:05:06 America/New_York'); | ||
94 | $output = $input->format('Y-m-d H:i:s'); | ||
95 | $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
96 | |||
97 | $this->assertEquals($output, $transformer->transform($input)); | ||
98 | } | ||
99 | |||
100 | public function testTransformExpectsDateTime() | ||
101 | { | ||
102 | $transformer = new DateTimeToStringTransformer(); | ||
103 | |||
104 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
105 | |||
106 | $transformer->transform('1234'); | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * @dataProvider dataProvider | ||
111 | */ | ||
112 | public function testReverseTransformUsingPipe($format, $input, $output) | ||
113 | { | ||
114 | if (version_compare(phpversion(), '5.3.7', '<')) { | ||
115 | $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); | ||
116 | } | ||
117 | |||
118 | $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); | ||
119 | |||
120 | $output = new \DateTime($output); | ||
121 | |||
122 | $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * @dataProvider dataProvider | ||
127 | */ | ||
128 | public function testReverseTransformWithoutUsingPipe($format, $input, $output) | ||
129 | { | ||
130 | $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, false); | ||
131 | |||
132 | $output = new \DateTime($output); | ||
133 | |||
134 | $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); | ||
135 | } | ||
136 | |||
137 | public function testReverseTransformEmpty() | ||
138 | { | ||
139 | $reverseTransformer = new DateTimeToStringTransformer(); | ||
140 | |||
141 | $this->assertNull($reverseTransformer->reverseTransform('')); | ||
142 | } | ||
143 | |||
144 | public function testReverseTransformWithDifferentTimezones() | ||
145 | { | ||
146 | $reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s'); | ||
147 | |||
148 | $output = new \DateTime('2010-02-03 16:05:06 Asia/Hong_Kong'); | ||
149 | $input = $output->format('Y-m-d H:i:s'); | ||
150 | $output->setTimeZone(new \DateTimeZone('America/New_York')); | ||
151 | |||
152 | $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); | ||
153 | } | ||
154 | |||
155 | public function testReverseTransformExpectsString() | ||
156 | { | ||
157 | $reverseTransformer = new DateTimeToStringTransformer(); | ||
158 | |||
159 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
160 | |||
161 | $reverseTransformer->reverseTransform(1234); | ||
162 | } | ||
163 | |||
164 | public function testReverseTransformExpectsValidDateString() | ||
165 | { | ||
166 | $reverseTransformer = new DateTimeToStringTransformer(); | ||
167 | |||
168 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
169 | |||
170 | $reverseTransformer->reverseTransform('2010-2010-2010'); | ||
171 | } | ||
172 | |||
173 | public function testReverseTransformWithNonExistingDate() | ||
174 | { | ||
175 | $reverseTransformer = new DateTimeToStringTransformer(); | ||
176 | |||
177 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
178 | |||
179 | $reverseTransformer->reverseTransform('2010-04-31'); | ||
180 | } | ||
181 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php deleted file mode 100644 index b54f0c4c..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; | ||
15 | |||
16 | class DateTimeToTimestampTransformerTest extends DateTimeTestCase | ||
17 | { | ||
18 | public function testTransform() | ||
19 | { | ||
20 | $transformer = new DateTimeToTimestampTransformer('UTC', 'UTC'); | ||
21 | |||
22 | $input = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
23 | $output = $input->format('U'); | ||
24 | |||
25 | $this->assertEquals($output, $transformer->transform($input)); | ||
26 | } | ||
27 | |||
28 | public function testTransformEmpty() | ||
29 | { | ||
30 | $transformer = new DateTimeToTimestampTransformer(); | ||
31 | |||
32 | $this->assertNull($transformer->transform(null)); | ||
33 | } | ||
34 | |||
35 | public function testTransformWithDifferentTimezones() | ||
36 | { | ||
37 | $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); | ||
38 | |||
39 | $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); | ||
40 | $output = $input->format('U'); | ||
41 | $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
42 | |||
43 | $this->assertEquals($output, $transformer->transform($input)); | ||
44 | } | ||
45 | |||
46 | public function testTransformFromDifferentTimezone() | ||
47 | { | ||
48 | $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'UTC'); | ||
49 | |||
50 | $input = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong'); | ||
51 | |||
52 | $dateTime = clone $input; | ||
53 | $dateTime->setTimezone(new \DateTimeZone('UTC')); | ||
54 | $output = $dateTime->format('U'); | ||
55 | |||
56 | $this->assertEquals($output, $transformer->transform($input)); | ||
57 | } | ||
58 | |||
59 | public function testTransformExpectsDateTime() | ||
60 | { | ||
61 | $transformer = new DateTimeToTimestampTransformer(); | ||
62 | |||
63 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
64 | |||
65 | $transformer->transform('1234'); | ||
66 | } | ||
67 | |||
68 | public function testReverseTransform() | ||
69 | { | ||
70 | $reverseTransformer = new DateTimeToTimestampTransformer('UTC', 'UTC'); | ||
71 | |||
72 | $output = new \DateTime('2010-02-03 04:05:06 UTC'); | ||
73 | $input = $output->format('U'); | ||
74 | |||
75 | $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); | ||
76 | } | ||
77 | |||
78 | public function testReverseTransformEmpty() | ||
79 | { | ||
80 | $reverseTransformer = new DateTimeToTimestampTransformer(); | ||
81 | |||
82 | $this->assertNull($reverseTransformer->reverseTransform(null)); | ||
83 | } | ||
84 | |||
85 | public function testReverseTransformWithDifferentTimezones() | ||
86 | { | ||
87 | $reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); | ||
88 | |||
89 | $output = new \DateTime('2010-02-03 04:05:06 America/New_York'); | ||
90 | $input = $output->format('U'); | ||
91 | $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
92 | |||
93 | $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); | ||
94 | } | ||
95 | |||
96 | public function testReverseTransformExpectsValidTimestamp() | ||
97 | { | ||
98 | $reverseTransformer = new DateTimeToTimestampTransformer(); | ||
99 | |||
100 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
101 | |||
102 | $reverseTransformer->reverseTransform('2010-2010-2010'); | ||
103 | } | ||
104 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php deleted file mode 100644 index a90fa91b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | parent::setUp(); | ||
22 | |||
23 | // Since we test against "de_AT", we need the full implementation | ||
24 | IntlTestHelper::requireFullIntl($this); | ||
25 | |||
26 | \Locale::setDefault('de_AT'); | ||
27 | } | ||
28 | |||
29 | public function testReverseTransform() | ||
30 | { | ||
31 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
32 | |||
33 | $this->assertEquals(1, $transformer->reverseTransform('1')); | ||
34 | $this->assertEquals(1, $transformer->reverseTransform('1,5')); | ||
35 | $this->assertEquals(1234, $transformer->reverseTransform('1234,5')); | ||
36 | $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); | ||
37 | } | ||
38 | |||
39 | public function testReverseTransformEmpty() | ||
40 | { | ||
41 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
42 | |||
43 | $this->assertNull($transformer->reverseTransform('')); | ||
44 | } | ||
45 | |||
46 | public function testReverseTransformWithGrouping() | ||
47 | { | ||
48 | $transformer = new IntegerToLocalizedStringTransformer(null, true); | ||
49 | |||
50 | $this->assertEquals(1234, $transformer->reverseTransform('1.234,5')); | ||
51 | $this->assertEquals(12345, $transformer->reverseTransform('12.345,912')); | ||
52 | $this->assertEquals(1234, $transformer->reverseTransform('1234,5')); | ||
53 | $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
58 | */ | ||
59 | public function testReverseTransformExpectsString() | ||
60 | { | ||
61 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
62 | |||
63 | $transformer->reverseTransform(1); | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
68 | */ | ||
69 | public function testReverseTransformExpectsValidNumber() | ||
70 | { | ||
71 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
72 | |||
73 | $transformer->reverseTransform('foo'); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
78 | */ | ||
79 | public function testReverseTransformDisallowsNaN() | ||
80 | { | ||
81 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
82 | |||
83 | $transformer->reverseTransform('NaN'); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
88 | */ | ||
89 | public function testReverseTransformDisallowsNaN2() | ||
90 | { | ||
91 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
92 | |||
93 | $transformer->reverseTransform('nan'); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
98 | */ | ||
99 | public function testReverseTransformDisallowsInfinity() | ||
100 | { | ||
101 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
102 | |||
103 | $transformer->reverseTransform('∞'); | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
108 | */ | ||
109 | public function testReverseTransformDisallowsNegativeInfinity() | ||
110 | { | ||
111 | $transformer = new IntegerToLocalizedStringTransformer(); | ||
112 | |||
113 | $transformer->reverseTransform('-∞'); | ||
114 | } | ||
115 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php deleted file mode 100644 index 8b91fe10..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | parent::setUp(); | ||
22 | |||
23 | // Since we test against "de_AT", we need the full implementation | ||
24 | IntlTestHelper::requireFullIntl($this); | ||
25 | |||
26 | \Locale::setDefault('de_AT'); | ||
27 | } | ||
28 | |||
29 | public function testTransform() | ||
30 | { | ||
31 | $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); | ||
32 | |||
33 | $this->assertEquals('1,23', $transformer->transform(123)); | ||
34 | } | ||
35 | |||
36 | public function testTransformExpectsNumeric() | ||
37 | { | ||
38 | $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); | ||
39 | |||
40 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
41 | |||
42 | $transformer->transform('abcd'); | ||
43 | } | ||
44 | |||
45 | public function testTransformEmpty() | ||
46 | { | ||
47 | $transformer = new MoneyToLocalizedStringTransformer(); | ||
48 | |||
49 | $this->assertSame('', $transformer->transform(null)); | ||
50 | } | ||
51 | |||
52 | public function testReverseTransform() | ||
53 | { | ||
54 | $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); | ||
55 | |||
56 | $this->assertEquals(123, $transformer->reverseTransform('1,23')); | ||
57 | } | ||
58 | |||
59 | public function testReverseTransformExpectsString() | ||
60 | { | ||
61 | $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); | ||
62 | |||
63 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
64 | |||
65 | $transformer->reverseTransform(12345); | ||
66 | } | ||
67 | |||
68 | public function testReverseTransformEmpty() | ||
69 | { | ||
70 | $transformer = new MoneyToLocalizedStringTransformer(); | ||
71 | |||
72 | $this->assertNull($transformer->reverseTransform('')); | ||
73 | } | ||
74 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php deleted file mode 100644 index c58e3f60..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ /dev/null | |||
@@ -1,393 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | parent::setUp(); | ||
22 | |||
23 | // Since we test against "de_AT", we need the full implementation | ||
24 | IntlTestHelper::requireFullIntl($this); | ||
25 | |||
26 | \Locale::setDefault('de_AT'); | ||
27 | } | ||
28 | |||
29 | public function provideTransformations() | ||
30 | { | ||
31 | return array( | ||
32 | array(null, '', 'de_AT'), | ||
33 | array(1, '1', 'de_AT'), | ||
34 | array(1.5, '1,5', 'de_AT'), | ||
35 | array(1234.5, '1234,5', 'de_AT'), | ||
36 | array(12345.912, '12345,912', 'de_AT'), | ||
37 | array(1234.5, '1234,5', 'ru'), | ||
38 | array(1234.5, '1234,5', 'fi'), | ||
39 | ); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @dataProvider provideTransformations | ||
44 | */ | ||
45 | public function testTransform($from, $to, $locale) | ||
46 | { | ||
47 | \Locale::setDefault($locale); | ||
48 | |||
49 | $transformer = new NumberToLocalizedStringTransformer(); | ||
50 | |||
51 | $this->assertSame($to, $transformer->transform($from)); | ||
52 | } | ||
53 | |||
54 | public function provideTransformationsWithGrouping() | ||
55 | { | ||
56 | return array( | ||
57 | array(1234.5, '1.234,5', 'de_AT'), | ||
58 | array(12345.912, '12.345,912', 'de_AT'), | ||
59 | array(1234.5, '1 234,5', 'fr'), | ||
60 | array(1234.5, '1 234,5', 'ru'), | ||
61 | array(1234.5, '1 234,5', 'fi'), | ||
62 | ); | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @dataProvider provideTransformationsWithGrouping | ||
67 | */ | ||
68 | public function testTransformWithGrouping($from, $to, $locale) | ||
69 | { | ||
70 | \Locale::setDefault($locale); | ||
71 | |||
72 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
73 | |||
74 | $this->assertSame($to, $transformer->transform($from)); | ||
75 | } | ||
76 | |||
77 | public function testTransformWithPrecision() | ||
78 | { | ||
79 | $transformer = new NumberToLocalizedStringTransformer(2); | ||
80 | |||
81 | $this->assertEquals('1234,50', $transformer->transform(1234.5)); | ||
82 | $this->assertEquals('678,92', $transformer->transform(678.916)); | ||
83 | } | ||
84 | |||
85 | public function testTransformWithRoundingMode() | ||
86 | { | ||
87 | $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN); | ||
88 | $this->assertEquals('1234,547', $transformer->transform(1234.547), '->transform() only applies rounding mode if precision set'); | ||
89 | |||
90 | $transformer = new NumberToLocalizedStringTransformer(2, null, NumberToLocalizedStringTransformer::ROUND_DOWN); | ||
91 | $this->assertEquals('1234,54', $transformer->transform(1234.547), '->transform() rounding-mode works'); | ||
92 | |||
93 | } | ||
94 | |||
95 | /** | ||
96 | * @dataProvider provideTransformations | ||
97 | */ | ||
98 | public function testReverseTransform($to, $from, $locale) | ||
99 | { | ||
100 | \Locale::setDefault($locale); | ||
101 | |||
102 | $transformer = new NumberToLocalizedStringTransformer(); | ||
103 | |||
104 | $this->assertEquals($to, $transformer->reverseTransform($from)); | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * @dataProvider provideTransformationsWithGrouping | ||
109 | */ | ||
110 | public function testReverseTransformWithGrouping($to, $from, $locale) | ||
111 | { | ||
112 | \Locale::setDefault($locale); | ||
113 | |||
114 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
115 | |||
116 | $this->assertEquals($to, $transformer->reverseTransform($from)); | ||
117 | } | ||
118 | |||
119 | // https://github.com/symfony/symfony/issues/7609 | ||
120 | public function testReverseTransformWithGroupingAndFixedSpaces() | ||
121 | { | ||
122 | if (!extension_loaded('mbstring')) { | ||
123 | $this->markTestSkipped('The "mbstring" extension is required for this test.'); | ||
124 | } | ||
125 | |||
126 | \Locale::setDefault('ru'); | ||
127 | |||
128 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
129 | |||
130 | $this->assertEquals(1234.5, $transformer->reverseTransform("1\xc2\xa0234,5")); | ||
131 | } | ||
132 | |||
133 | public function testReverseTransformWithGroupingButWithoutGroupSeparator() | ||
134 | { | ||
135 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
136 | |||
137 | // omit group separator | ||
138 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); | ||
139 | $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912')); | ||
140 | } | ||
141 | |||
142 | public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() | ||
143 | { | ||
144 | \Locale::setDefault('fr'); | ||
145 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
146 | |||
147 | // completely valid format | ||
148 | $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5')); | ||
149 | // accept dots | ||
150 | $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5')); | ||
151 | // omit group separator | ||
152 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); | ||
153 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
158 | */ | ||
159 | public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() | ||
160 | { | ||
161 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
162 | |||
163 | $transformer->reverseTransform('1.234.5'); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
168 | */ | ||
169 | public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() | ||
170 | { | ||
171 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
172 | |||
173 | $transformer->reverseTransform('1234.5'); | ||
174 | } | ||
175 | |||
176 | public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed() | ||
177 | { | ||
178 | \Locale::setDefault('fr'); | ||
179 | $transformer = new NumberToLocalizedStringTransformer(); | ||
180 | |||
181 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); | ||
182 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); | ||
183 | } | ||
184 | |||
185 | public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() | ||
186 | { | ||
187 | \Locale::setDefault('bg'); | ||
188 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
189 | |||
190 | // completely valid format | ||
191 | $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5')); | ||
192 | // accept commas | ||
193 | $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5')); | ||
194 | // omit group separator | ||
195 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); | ||
196 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
201 | */ | ||
202 | public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() | ||
203 | { | ||
204 | \Locale::setDefault('en'); | ||
205 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
206 | |||
207 | $transformer->reverseTransform('1,234,5'); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
212 | */ | ||
213 | public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() | ||
214 | { | ||
215 | \Locale::setDefault('en'); | ||
216 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
217 | |||
218 | $transformer->reverseTransform('1234,5'); | ||
219 | } | ||
220 | |||
221 | public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed() | ||
222 | { | ||
223 | \Locale::setDefault('en'); | ||
224 | $transformer = new NumberToLocalizedStringTransformer(); | ||
225 | |||
226 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); | ||
227 | $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
232 | */ | ||
233 | public function testTransformExpectsNumeric() | ||
234 | { | ||
235 | $transformer = new NumberToLocalizedStringTransformer(); | ||
236 | |||
237 | $transformer->transform('foo'); | ||
238 | } | ||
239 | |||
240 | /** | ||
241 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
242 | */ | ||
243 | public function testReverseTransformExpectsString() | ||
244 | { | ||
245 | $transformer = new NumberToLocalizedStringTransformer(); | ||
246 | |||
247 | $transformer->reverseTransform(1); | ||
248 | } | ||
249 | |||
250 | /** | ||
251 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
252 | */ | ||
253 | public function testReverseTransformExpectsValidNumber() | ||
254 | { | ||
255 | $transformer = new NumberToLocalizedStringTransformer(); | ||
256 | |||
257 | $transformer->reverseTransform('foo'); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
262 | * @link https://github.com/symfony/symfony/issues/3161 | ||
263 | */ | ||
264 | public function testReverseTransformDisallowsNaN() | ||
265 | { | ||
266 | $transformer = new NumberToLocalizedStringTransformer(); | ||
267 | |||
268 | $transformer->reverseTransform('NaN'); | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
273 | */ | ||
274 | public function testReverseTransformDisallowsNaN2() | ||
275 | { | ||
276 | $transformer = new NumberToLocalizedStringTransformer(); | ||
277 | |||
278 | $transformer->reverseTransform('nan'); | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
283 | */ | ||
284 | public function testReverseTransformDisallowsInfinity() | ||
285 | { | ||
286 | $transformer = new NumberToLocalizedStringTransformer(); | ||
287 | |||
288 | $transformer->reverseTransform('∞'); | ||
289 | } | ||
290 | |||
291 | /** | ||
292 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
293 | */ | ||
294 | public function testReverseTransformDisallowsInfinity2() | ||
295 | { | ||
296 | $transformer = new NumberToLocalizedStringTransformer(); | ||
297 | |||
298 | $transformer->reverseTransform('∞,123'); | ||
299 | } | ||
300 | |||
301 | /** | ||
302 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
303 | */ | ||
304 | public function testReverseTransformDisallowsNegativeInfinity() | ||
305 | { | ||
306 | $transformer = new NumberToLocalizedStringTransformer(); | ||
307 | |||
308 | $transformer->reverseTransform('-∞'); | ||
309 | } | ||
310 | |||
311 | /** | ||
312 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
313 | */ | ||
314 | public function testReverseTransformDisallowsLeadingExtraCharacters() | ||
315 | { | ||
316 | $transformer = new NumberToLocalizedStringTransformer(); | ||
317 | |||
318 | $transformer->reverseTransform('foo123'); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
323 | * @expectedExceptionMessage The number contains unrecognized characters: "foo3" | ||
324 | */ | ||
325 | public function testReverseTransformDisallowsCenteredExtraCharacters() | ||
326 | { | ||
327 | $transformer = new NumberToLocalizedStringTransformer(); | ||
328 | |||
329 | $transformer->reverseTransform('12foo3'); | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
334 | * @expectedExceptionMessage The number contains unrecognized characters: "foo8" | ||
335 | */ | ||
336 | public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() | ||
337 | { | ||
338 | if (!extension_loaded('mbstring')) { | ||
339 | $this->markTestSkipped('The "mbstring" extension is required for this test.'); | ||
340 | } | ||
341 | |||
342 | \Locale::setDefault('ru'); | ||
343 | |||
344 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
345 | |||
346 | $transformer->reverseTransform("12\xc2\xa0345,67foo8"); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
351 | * @expectedExceptionMessage The number contains unrecognized characters: "foo8" | ||
352 | */ | ||
353 | public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() | ||
354 | { | ||
355 | if (!extension_loaded('mbstring')) { | ||
356 | $this->markTestSkipped('The "mbstring" extension is required for this test.'); | ||
357 | } | ||
358 | |||
359 | \Locale::setDefault('ru'); | ||
360 | |||
361 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
362 | |||
363 | $transformer->reverseTransform("12\xc2\xa0345,67foo8 \xc2\xa0\t"); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
368 | * @expectedExceptionMessage The number contains unrecognized characters: "foo" | ||
369 | */ | ||
370 | public function testReverseTransformDisallowsTrailingExtraCharacters() | ||
371 | { | ||
372 | $transformer = new NumberToLocalizedStringTransformer(); | ||
373 | |||
374 | $transformer->reverseTransform('123foo'); | ||
375 | } | ||
376 | |||
377 | /** | ||
378 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
379 | * @expectedExceptionMessage The number contains unrecognized characters: "foo" | ||
380 | */ | ||
381 | public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() | ||
382 | { | ||
383 | if (!extension_loaded('mbstring')) { | ||
384 | $this->markTestSkipped('The "mbstring" extension is required for this test.'); | ||
385 | } | ||
386 | |||
387 | \Locale::setDefault('ru'); | ||
388 | |||
389 | $transformer = new NumberToLocalizedStringTransformer(null, true); | ||
390 | |||
391 | $transformer->reverseTransform("12\xc2\xa0345,678foo"); | ||
392 | } | ||
393 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php deleted file mode 100644 index 104941c9..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | parent::setUp(); | ||
22 | |||
23 | // Since we test against "de_AT", we need the full implementation | ||
24 | IntlTestHelper::requireFullIntl($this); | ||
25 | |||
26 | \Locale::setDefault('de_AT'); | ||
27 | } | ||
28 | |||
29 | public function testTransform() | ||
30 | { | ||
31 | $transformer = new PercentToLocalizedStringTransformer(); | ||
32 | |||
33 | $this->assertEquals('10', $transformer->transform(0.1)); | ||
34 | $this->assertEquals('15', $transformer->transform(0.15)); | ||
35 | $this->assertEquals('12', $transformer->transform(0.1234)); | ||
36 | $this->assertEquals('200', $transformer->transform(2)); | ||
37 | } | ||
38 | |||
39 | public function testTransformEmpty() | ||
40 | { | ||
41 | $transformer = new PercentToLocalizedStringTransformer(); | ||
42 | |||
43 | $this->assertEquals('', $transformer->transform(null)); | ||
44 | } | ||
45 | |||
46 | public function testTransformWithInteger() | ||
47 | { | ||
48 | $transformer = new PercentToLocalizedStringTransformer(null, 'integer'); | ||
49 | |||
50 | $this->assertEquals('0', $transformer->transform(0.1)); | ||
51 | $this->assertEquals('1', $transformer->transform(1)); | ||
52 | $this->assertEquals('15', $transformer->transform(15)); | ||
53 | $this->assertEquals('16', $transformer->transform(15.9)); | ||
54 | } | ||
55 | |||
56 | public function testTransformWithPrecision() | ||
57 | { | ||
58 | $transformer = new PercentToLocalizedStringTransformer(2); | ||
59 | |||
60 | $this->assertEquals('12,34', $transformer->transform(0.1234)); | ||
61 | } | ||
62 | |||
63 | public function testReverseTransform() | ||
64 | { | ||
65 | $transformer = new PercentToLocalizedStringTransformer(); | ||
66 | |||
67 | $this->assertEquals(0.1, $transformer->reverseTransform('10')); | ||
68 | $this->assertEquals(0.15, $transformer->reverseTransform('15')); | ||
69 | $this->assertEquals(0.12, $transformer->reverseTransform('12')); | ||
70 | $this->assertEquals(2, $transformer->reverseTransform('200')); | ||
71 | } | ||
72 | |||
73 | public function testReverseTransformEmpty() | ||
74 | { | ||
75 | $transformer = new PercentToLocalizedStringTransformer(); | ||
76 | |||
77 | $this->assertNull($transformer->reverseTransform('')); | ||
78 | } | ||
79 | |||
80 | public function testReverseTransformWithInteger() | ||
81 | { | ||
82 | $transformer = new PercentToLocalizedStringTransformer(null, 'integer'); | ||
83 | |||
84 | $this->assertEquals(10, $transformer->reverseTransform('10')); | ||
85 | $this->assertEquals(15, $transformer->reverseTransform('15')); | ||
86 | $this->assertEquals(12, $transformer->reverseTransform('12')); | ||
87 | $this->assertEquals(200, $transformer->reverseTransform('200')); | ||
88 | } | ||
89 | |||
90 | public function testReverseTransformWithPrecision() | ||
91 | { | ||
92 | $transformer = new PercentToLocalizedStringTransformer(2); | ||
93 | |||
94 | $this->assertEquals(0.1234, $transformer->reverseTransform('12,34')); | ||
95 | } | ||
96 | |||
97 | public function testTransformExpectsNumeric() | ||
98 | { | ||
99 | $transformer = new PercentToLocalizedStringTransformer(); | ||
100 | |||
101 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
102 | |||
103 | $transformer->transform('foo'); | ||
104 | } | ||
105 | |||
106 | public function testReverseTransformExpectsString() | ||
107 | { | ||
108 | $transformer = new PercentToLocalizedStringTransformer(); | ||
109 | |||
110 | $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); | ||
111 | |||
112 | $transformer->reverseTransform(1); | ||
113 | } | ||
114 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php deleted file mode 100644 index 2c5298da..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer; | ||
15 | |||
16 | class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | private $transformer; | ||
19 | |||
20 | protected function setUp() | ||
21 | { | ||
22 | $this->transformer = new ValueToDuplicatesTransformer(array('a', 'b', 'c')); | ||
23 | } | ||
24 | |||
25 | protected function tearDown() | ||
26 | { | ||
27 | $this->transformer = null; | ||
28 | } | ||
29 | |||
30 | public function testTransform() | ||
31 | { | ||
32 | $output = array( | ||
33 | 'a' => 'Foo', | ||
34 | 'b' => 'Foo', | ||
35 | 'c' => 'Foo', | ||
36 | ); | ||
37 | |||
38 | $this->assertSame($output, $this->transformer->transform('Foo')); | ||
39 | } | ||
40 | |||
41 | public function testTransformEmpty() | ||
42 | { | ||
43 | $output = array( | ||
44 | 'a' => null, | ||
45 | 'b' => null, | ||
46 | 'c' => null, | ||
47 | ); | ||
48 | |||
49 | $this->assertSame($output, $this->transformer->transform(null)); | ||
50 | } | ||
51 | |||
52 | public function testReverseTransform() | ||
53 | { | ||
54 | $input = array( | ||
55 | 'a' => 'Foo', | ||
56 | 'b' => 'Foo', | ||
57 | 'c' => 'Foo', | ||
58 | ); | ||
59 | |||
60 | $this->assertSame('Foo', $this->transformer->reverseTransform($input)); | ||
61 | } | ||
62 | |||
63 | public function testReverseTransformCompletelyEmpty() | ||
64 | { | ||
65 | $input = array( | ||
66 | 'a' => '', | ||
67 | 'b' => '', | ||
68 | 'c' => '', | ||
69 | ); | ||
70 | |||
71 | $this->assertNull($this->transformer->reverseTransform($input)); | ||
72 | } | ||
73 | |||
74 | public function testReverseTransformCompletelyNull() | ||
75 | { | ||
76 | $input = array( | ||
77 | 'a' => null, | ||
78 | 'b' => null, | ||
79 | 'c' => null, | ||
80 | ); | ||
81 | |||
82 | $this->assertNull($this->transformer->reverseTransform($input)); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
87 | */ | ||
88 | public function testReverseTransformPartiallyNull() | ||
89 | { | ||
90 | $input = array( | ||
91 | 'a' => 'Foo', | ||
92 | 'b' => 'Foo', | ||
93 | 'c' => null, | ||
94 | ); | ||
95 | |||
96 | $this->transformer->reverseTransform($input); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
101 | */ | ||
102 | public function testReverseTransformDifferences() | ||
103 | { | ||
104 | $input = array( | ||
105 | 'a' => 'Foo', | ||
106 | 'b' => 'Bar', | ||
107 | 'c' => 'Foo', | ||
108 | ); | ||
109 | |||
110 | $this->transformer->reverseTransform($input); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
115 | */ | ||
116 | public function testReverseTransformRequiresArray() | ||
117 | { | ||
118 | $this->transformer->reverseTransform('12345'); | ||
119 | } | ||
120 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php deleted file mode 100644 index a5d5c78a..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php +++ /dev/null | |||
@@ -1,106 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvent; | ||
15 | use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener; | ||
16 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
17 | |||
18 | class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | private $choiceList; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
25 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
26 | } | ||
27 | |||
28 | parent::setUp(); | ||
29 | |||
30 | $this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B')); | ||
31 | } | ||
32 | |||
33 | protected function tearDown() | ||
34 | { | ||
35 | parent::tearDown(); | ||
36 | |||
37 | $listener = null; | ||
38 | } | ||
39 | |||
40 | public function testFixRadio() | ||
41 | { | ||
42 | $data = '1'; | ||
43 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
44 | $event = new FormEvent($form, $data); | ||
45 | |||
46 | $listener = new FixRadioInputListener($this->choiceList, true); | ||
47 | $listener->preSubmit($event); | ||
48 | |||
49 | // Indices in SimpleChoiceList are zero-based generated integers | ||
50 | $this->assertEquals(array(2 => '1'), $event->getData()); | ||
51 | } | ||
52 | |||
53 | public function testFixZero() | ||
54 | { | ||
55 | $data = '0'; | ||
56 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
57 | $event = new FormEvent($form, $data); | ||
58 | |||
59 | $listener = new FixRadioInputListener($this->choiceList, true); | ||
60 | $listener->preSubmit($event); | ||
61 | |||
62 | // Indices in SimpleChoiceList are zero-based generated integers | ||
63 | $this->assertEquals(array(1 => '0'), $event->getData()); | ||
64 | } | ||
65 | |||
66 | public function testFixEmptyString() | ||
67 | { | ||
68 | $data = ''; | ||
69 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
70 | $event = new FormEvent($form, $data); | ||
71 | |||
72 | $listener = new FixRadioInputListener($this->choiceList, true); | ||
73 | $listener->preSubmit($event); | ||
74 | |||
75 | // Indices in SimpleChoiceList are zero-based generated integers | ||
76 | $this->assertEquals(array(0 => ''), $event->getData()); | ||
77 | } | ||
78 | |||
79 | public function testConvertEmptyStringToPlaceholderIfNotFound() | ||
80 | { | ||
81 | $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); | ||
82 | |||
83 | $data = ''; | ||
84 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
85 | $event = new FormEvent($form, $data); | ||
86 | |||
87 | $listener = new FixRadioInputListener($list, true); | ||
88 | $listener->preSubmit($event); | ||
89 | |||
90 | $this->assertEquals(array('placeholder' => ''), $event->getData()); | ||
91 | } | ||
92 | |||
93 | public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed() | ||
94 | { | ||
95 | $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); | ||
96 | |||
97 | $data = ''; | ||
98 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
99 | $event = new FormEvent($form, $data); | ||
100 | |||
101 | $listener = new FixRadioInputListener($list, false); | ||
102 | $listener->preSubmit($event); | ||
103 | |||
104 | $this->assertEquals(array(), $event->getData()); | ||
105 | } | ||
106 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php deleted file mode 100644 index 2b84e4fd..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvent; | ||
15 | use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener; | ||
16 | |||
17 | class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
22 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | public function testFixHttpUrl() | ||
27 | { | ||
28 | $data = "www.symfony.com"; | ||
29 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
30 | $event = new FormEvent($form, $data); | ||
31 | |||
32 | $filter = new FixUrlProtocolListener('http'); | ||
33 | $filter->onSubmit($event); | ||
34 | |||
35 | $this->assertEquals('http://www.symfony.com', $event->getData()); | ||
36 | } | ||
37 | |||
38 | public function testSkipKnownUrl() | ||
39 | { | ||
40 | $data = "http://www.symfony.com"; | ||
41 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
42 | $event = new FormEvent($form, $data); | ||
43 | |||
44 | $filter = new FixUrlProtocolListener('http'); | ||
45 | $filter->onSubmit($event); | ||
46 | |||
47 | $this->assertEquals('http://www.symfony.com', $event->getData()); | ||
48 | } | ||
49 | |||
50 | public function testSkipOtherProtocol() | ||
51 | { | ||
52 | $data = "ftp://www.symfony.com"; | ||
53 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
54 | $event = new FormEvent($form, $data); | ||
55 | |||
56 | $filter = new FixUrlProtocolListener('http'); | ||
57 | $filter->onSubmit($event); | ||
58 | |||
59 | $this->assertEquals('ftp://www.symfony.com', $event->getData()); | ||
60 | } | ||
61 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash deleted file mode 100644 index b636f4b8..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash +++ /dev/null | |||
Binary files differ | |||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php deleted file mode 100644 index 6f46c9d7..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | |||
16 | class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest | ||
17 | { | ||
18 | protected function getData(array $data) | ||
19 | { | ||
20 | return new \ArrayObject($data); | ||
21 | } | ||
22 | |||
23 | protected function getBuilder($name = 'name') | ||
24 | { | ||
25 | return new FormBuilder($name, '\ArrayObject', $this->dispatcher, $this->factory); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php deleted file mode 100644 index c0f3d597..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | |||
16 | class MergeCollectionListenerArrayTest extends MergeCollectionListenerTest | ||
17 | { | ||
18 | protected function getData(array $data) | ||
19 | { | ||
20 | return $data; | ||
21 | } | ||
22 | |||
23 | protected function getBuilder($name = 'name') | ||
24 | { | ||
25 | return new FormBuilder($name, null, $this->dispatcher, $this->factory); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php deleted file mode 100644 index 5eb6c7b9..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\Tests\Fixtures\CustomArrayObject; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | |||
17 | class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTest | ||
18 | { | ||
19 | protected function getData(array $data) | ||
20 | { | ||
21 | return new CustomArrayObject($data); | ||
22 | } | ||
23 | |||
24 | protected function getBuilder($name = 'name') | ||
25 | { | ||
26 | return new FormBuilder($name, 'Symfony\Component\Form\Tests\Fixtures\CustomArrayObject', $this->dispatcher, $this->factory); | ||
27 | } | ||
28 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php deleted file mode 100644 index dbd28c6b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php +++ /dev/null | |||
@@ -1,259 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvent; | ||
15 | use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; | ||
16 | |||
17 | abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected $dispatcher; | ||
20 | protected $factory; | ||
21 | protected $form; | ||
22 | |||
23 | protected function setUp() | ||
24 | { | ||
25 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
26 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
27 | } | ||
28 | |||
29 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
30 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
31 | $this->form = $this->getForm('axes'); | ||
32 | } | ||
33 | |||
34 | protected function tearDown() | ||
35 | { | ||
36 | $this->dispatcher = null; | ||
37 | $this->factory = null; | ||
38 | $this->form = null; | ||
39 | } | ||
40 | |||
41 | abstract protected function getBuilder($name = 'name'); | ||
42 | |||
43 | protected function getForm($name = 'name', $propertyPath = null) | ||
44 | { | ||
45 | $propertyPath = $propertyPath ?: $name; | ||
46 | |||
47 | return $this->getBuilder($name)->setAttribute('property_path', $propertyPath)->getForm(); | ||
48 | } | ||
49 | |||
50 | protected function getMockForm() | ||
51 | { | ||
52 | return $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
53 | } | ||
54 | |||
55 | public function getBooleanMatrix1() | ||
56 | { | ||
57 | return array( | ||
58 | array(true), | ||
59 | array(false), | ||
60 | ); | ||
61 | } | ||
62 | |||
63 | public function getBooleanMatrix2() | ||
64 | { | ||
65 | return array( | ||
66 | array(true, true), | ||
67 | array(true, false), | ||
68 | array(false, true), | ||
69 | array(false, false), | ||
70 | ); | ||
71 | } | ||
72 | |||
73 | abstract protected function getData(array $data); | ||
74 | |||
75 | /** | ||
76 | * @dataProvider getBooleanMatrix1 | ||
77 | */ | ||
78 | public function testAddExtraEntriesIfAllowAdd($allowDelete) | ||
79 | { | ||
80 | $originalData = $this->getData(array(1 => 'second')); | ||
81 | $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
82 | |||
83 | $listener = new MergeCollectionListener(true, $allowDelete); | ||
84 | |||
85 | $this->form->setData($originalData); | ||
86 | |||
87 | $event = new FormEvent($this->form, $newData); | ||
88 | $listener->onSubmit($event); | ||
89 | |||
90 | // The original object was modified | ||
91 | if (is_object($originalData)) { | ||
92 | $this->assertSame($originalData, $event->getData()); | ||
93 | } | ||
94 | |||
95 | // The original object matches the new object | ||
96 | $this->assertEquals($newData, $event->getData()); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @dataProvider getBooleanMatrix1 | ||
101 | */ | ||
102 | public function testAddExtraEntriesIfAllowAddDontOverwriteExistingIndices($allowDelete) | ||
103 | { | ||
104 | $originalData = $this->getData(array(1 => 'first')); | ||
105 | $newData = $this->getData(array(0 => 'first', 1 => 'second')); | ||
106 | |||
107 | $listener = new MergeCollectionListener(true, $allowDelete); | ||
108 | |||
109 | $this->form->setData($originalData); | ||
110 | |||
111 | $event = new FormEvent($this->form, $newData); | ||
112 | $listener->onSubmit($event); | ||
113 | |||
114 | // The original object was modified | ||
115 | if (is_object($originalData)) { | ||
116 | $this->assertSame($originalData, $event->getData()); | ||
117 | } | ||
118 | |||
119 | // The original object matches the new object | ||
120 | $this->assertEquals($this->getData(array(1 => 'first', 2 => 'second')), $event->getData()); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * @dataProvider getBooleanMatrix1 | ||
125 | */ | ||
126 | public function testDoNothingIfNotAllowAdd($allowDelete) | ||
127 | { | ||
128 | $originalDataArray = array(1 => 'second'); | ||
129 | $originalData = $this->getData($originalDataArray); | ||
130 | $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
131 | |||
132 | $listener = new MergeCollectionListener(false, $allowDelete); | ||
133 | |||
134 | $this->form->setData($originalData); | ||
135 | |||
136 | $event = new FormEvent($this->form, $newData); | ||
137 | $listener->onSubmit($event); | ||
138 | |||
139 | // We still have the original object | ||
140 | if (is_object($originalData)) { | ||
141 | $this->assertSame($originalData, $event->getData()); | ||
142 | } | ||
143 | |||
144 | // Nothing was removed | ||
145 | $this->assertEquals($this->getData($originalDataArray), $event->getData()); | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * @dataProvider getBooleanMatrix1 | ||
150 | */ | ||
151 | public function testRemoveMissingEntriesIfAllowDelete($allowAdd) | ||
152 | { | ||
153 | $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
154 | $newData = $this->getData(array(1 => 'second')); | ||
155 | |||
156 | $listener = new MergeCollectionListener($allowAdd, true); | ||
157 | |||
158 | $this->form->setData($originalData); | ||
159 | |||
160 | $event = new FormEvent($this->form, $newData); | ||
161 | $listener->onSubmit($event); | ||
162 | |||
163 | // The original object was modified | ||
164 | if (is_object($originalData)) { | ||
165 | $this->assertSame($originalData, $event->getData()); | ||
166 | } | ||
167 | |||
168 | // The original object matches the new object | ||
169 | $this->assertEquals($newData, $event->getData()); | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * @dataProvider getBooleanMatrix1 | ||
174 | */ | ||
175 | public function testDoNothingIfNotAllowDelete($allowAdd) | ||
176 | { | ||
177 | $originalDataArray = array(0 => 'first', 1 => 'second', 2 => 'third'); | ||
178 | $originalData = $this->getData($originalDataArray); | ||
179 | $newData = $this->getData(array(1 => 'second')); | ||
180 | |||
181 | $listener = new MergeCollectionListener($allowAdd, false); | ||
182 | |||
183 | $this->form->setData($originalData); | ||
184 | |||
185 | $event = new FormEvent($this->form, $newData); | ||
186 | $listener->onSubmit($event); | ||
187 | |||
188 | // We still have the original object | ||
189 | if (is_object($originalData)) { | ||
190 | $this->assertSame($originalData, $event->getData()); | ||
191 | } | ||
192 | |||
193 | // Nothing was removed | ||
194 | $this->assertEquals($this->getData($originalDataArray), $event->getData()); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * @dataProvider getBooleanMatrix2 | ||
199 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
200 | */ | ||
201 | public function testRequireArrayOrTraversable($allowAdd, $allowDelete) | ||
202 | { | ||
203 | $newData = 'no array or traversable'; | ||
204 | $event = new FormEvent($this->form, $newData); | ||
205 | $listener = new MergeCollectionListener($allowAdd, $allowDelete); | ||
206 | $listener->onSubmit($event); | ||
207 | } | ||
208 | |||
209 | public function testDealWithNullData() | ||
210 | { | ||
211 | $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
212 | $newData = null; | ||
213 | |||
214 | $listener = new MergeCollectionListener(false, false); | ||
215 | |||
216 | $this->form->setData($originalData); | ||
217 | |||
218 | $event = new FormEvent($this->form, $newData); | ||
219 | $listener->onSubmit($event); | ||
220 | |||
221 | $this->assertSame($originalData, $event->getData()); | ||
222 | } | ||
223 | |||
224 | /** | ||
225 | * @dataProvider getBooleanMatrix1 | ||
226 | */ | ||
227 | public function testDealWithNullOriginalDataIfAllowAdd($allowDelete) | ||
228 | { | ||
229 | $originalData = null; | ||
230 | $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
231 | |||
232 | $listener = new MergeCollectionListener(true, $allowDelete); | ||
233 | |||
234 | $this->form->setData($originalData); | ||
235 | |||
236 | $event = new FormEvent($this->form, $newData); | ||
237 | $listener->onSubmit($event); | ||
238 | |||
239 | $this->assertSame($newData, $event->getData()); | ||
240 | } | ||
241 | |||
242 | /** | ||
243 | * @dataProvider getBooleanMatrix1 | ||
244 | */ | ||
245 | public function testDontDealWithNullOriginalDataIfNotAllowAdd($allowDelete) | ||
246 | { | ||
247 | $originalData = null; | ||
248 | $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); | ||
249 | |||
250 | $listener = new MergeCollectionListener(false, $allowDelete); | ||
251 | |||
252 | $this->form->setData($originalData); | ||
253 | |||
254 | $event = new FormEvent($this->form, $newData); | ||
255 | $listener->onSubmit($event); | ||
256 | |||
257 | $this->assertNull($event->getData()); | ||
258 | } | ||
259 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php deleted file mode 100644 index 1367b3ef..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ /dev/null | |||
@@ -1,255 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormEvent; | ||
17 | |||
18 | class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | private $dispatcher; | ||
21 | private $factory; | ||
22 | private $form; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
27 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
28 | } | ||
29 | |||
30 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
31 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
32 | $this->form = $this->getBuilder() | ||
33 | ->setCompound(true) | ||
34 | ->setDataMapper($this->getDataMapper()) | ||
35 | ->getForm(); | ||
36 | } | ||
37 | |||
38 | protected function tearDown() | ||
39 | { | ||
40 | $this->dispatcher = null; | ||
41 | $this->factory = null; | ||
42 | $this->form = null; | ||
43 | } | ||
44 | |||
45 | protected function getBuilder($name = 'name') | ||
46 | { | ||
47 | return new FormBuilder($name, null, $this->dispatcher, $this->factory); | ||
48 | } | ||
49 | |||
50 | protected function getForm($name = 'name') | ||
51 | { | ||
52 | return $this->getBuilder($name)->getForm(); | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
57 | */ | ||
58 | private function getDataMapper() | ||
59 | { | ||
60 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
61 | } | ||
62 | |||
63 | protected function getMockForm() | ||
64 | { | ||
65 | return $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
66 | } | ||
67 | |||
68 | public function testPreSetDataResizesForm() | ||
69 | { | ||
70 | $this->form->add($this->getForm('0')); | ||
71 | $this->form->add($this->getForm('1')); | ||
72 | |||
73 | $this->factory->expects($this->at(0)) | ||
74 | ->method('createNamed') | ||
75 | ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10, 'auto_initialize' => false)) | ||
76 | ->will($this->returnValue($this->getForm('1'))); | ||
77 | $this->factory->expects($this->at(1)) | ||
78 | ->method('createNamed') | ||
79 | ->with(2, 'text', null, array('property_path' => '[2]', 'max_length' => 10, 'auto_initialize' => false)) | ||
80 | ->will($this->returnValue($this->getForm('2'))); | ||
81 | |||
82 | $data = array(1 => 'string', 2 => 'string'); | ||
83 | $event = new FormEvent($this->form, $data); | ||
84 | $listener = new ResizeFormListener('text', array('max_length' => '10'), false, false); | ||
85 | $listener->preSetData($event); | ||
86 | |||
87 | $this->assertFalse($this->form->has('0')); | ||
88 | $this->assertTrue($this->form->has('1')); | ||
89 | $this->assertTrue($this->form->has('2')); | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
94 | */ | ||
95 | public function testPreSetDataRequiresArrayOrTraversable() | ||
96 | { | ||
97 | $data = 'no array or traversable'; | ||
98 | $event = new FormEvent($this->form, $data); | ||
99 | $listener = new ResizeFormListener('text', array(), false, false); | ||
100 | $listener->preSetData($event); | ||
101 | } | ||
102 | |||
103 | public function testPreSetDataDealsWithNullData() | ||
104 | { | ||
105 | $this->factory->expects($this->never())->method('createNamed'); | ||
106 | |||
107 | $data = null; | ||
108 | $event = new FormEvent($this->form, $data); | ||
109 | $listener = new ResizeFormListener('text', array(), false, false); | ||
110 | $listener->preSetData($event); | ||
111 | } | ||
112 | |||
113 | public function testPreSubmitResizesUpIfAllowAdd() | ||
114 | { | ||
115 | $this->form->add($this->getForm('0')); | ||
116 | |||
117 | $this->factory->expects($this->once()) | ||
118 | ->method('createNamed') | ||
119 | ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10, 'auto_initialize' => false)) | ||
120 | ->will($this->returnValue($this->getForm('1'))); | ||
121 | |||
122 | $data = array(0 => 'string', 1 => 'string'); | ||
123 | $event = new FormEvent($this->form, $data); | ||
124 | $listener = new ResizeFormListener('text', array('max_length' => 10), true, false); | ||
125 | $listener->preSubmit($event); | ||
126 | |||
127 | $this->assertTrue($this->form->has('0')); | ||
128 | $this->assertTrue($this->form->has('1')); | ||
129 | } | ||
130 | |||
131 | public function testPreSubmitResizesDownIfAllowDelete() | ||
132 | { | ||
133 | $this->form->add($this->getForm('0')); | ||
134 | $this->form->add($this->getForm('1')); | ||
135 | |||
136 | $data = array(0 => 'string'); | ||
137 | $event = new FormEvent($this->form, $data); | ||
138 | $listener = new ResizeFormListener('text', array(), false, true); | ||
139 | $listener->preSubmit($event); | ||
140 | |||
141 | $this->assertTrue($this->form->has('0')); | ||
142 | $this->assertFalse($this->form->has('1')); | ||
143 | } | ||
144 | |||
145 | // fix for https://github.com/symfony/symfony/pull/493 | ||
146 | public function testPreSubmitRemovesZeroKeys() | ||
147 | { | ||
148 | $this->form->add($this->getForm('0')); | ||
149 | |||
150 | $data = array(); | ||
151 | $event = new FormEvent($this->form, $data); | ||
152 | $listener = new ResizeFormListener('text', array(), false, true); | ||
153 | $listener->preSubmit($event); | ||
154 | |||
155 | $this->assertFalse($this->form->has('0')); | ||
156 | } | ||
157 | |||
158 | public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete() | ||
159 | { | ||
160 | $this->form->add($this->getForm('0')); | ||
161 | $this->form->add($this->getForm('1')); | ||
162 | |||
163 | $data = array(0 => 'string', 2 => 'string'); | ||
164 | $event = new FormEvent($this->form, $data); | ||
165 | $listener = new ResizeFormListener('text', array(), false, false); | ||
166 | $listener->preSubmit($event); | ||
167 | |||
168 | $this->assertTrue($this->form->has('0')); | ||
169 | $this->assertTrue($this->form->has('1')); | ||
170 | $this->assertFalse($this->form->has('2')); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
175 | */ | ||
176 | public function testPreSubmitRequiresArrayOrTraversable() | ||
177 | { | ||
178 | $data = 'no array or traversable'; | ||
179 | $event = new FormEvent($this->form, $data); | ||
180 | $listener = new ResizeFormListener('text', array(), false, false); | ||
181 | $listener->preSubmit($event); | ||
182 | } | ||
183 | |||
184 | public function testPreSubmitDealsWithNullData() | ||
185 | { | ||
186 | $this->form->add($this->getForm('1')); | ||
187 | |||
188 | $data = null; | ||
189 | $event = new FormEvent($this->form, $data); | ||
190 | $listener = new ResizeFormListener('text', array(), false, true); | ||
191 | $listener->preSubmit($event); | ||
192 | |||
193 | $this->assertFalse($this->form->has('1')); | ||
194 | } | ||
195 | |||
196 | // fixes https://github.com/symfony/symfony/pull/40 | ||
197 | public function testPreSubmitDealsWithEmptyData() | ||
198 | { | ||
199 | $this->form->add($this->getForm('1')); | ||
200 | |||
201 | $data = ''; | ||
202 | $event = new FormEvent($this->form, $data); | ||
203 | $listener = new ResizeFormListener('text', array(), false, true); | ||
204 | $listener->preSubmit($event); | ||
205 | |||
206 | $this->assertFalse($this->form->has('1')); | ||
207 | } | ||
208 | |||
209 | public function testOnSubmitNormDataRemovesEntriesMissingInTheFormIfAllowDelete() | ||
210 | { | ||
211 | $this->form->add($this->getForm('1')); | ||
212 | |||
213 | $data = array(0 => 'first', 1 => 'second', 2 => 'third'); | ||
214 | $event = new FormEvent($this->form, $data); | ||
215 | $listener = new ResizeFormListener('text', array(), false, true); | ||
216 | $listener->onSubmit($event); | ||
217 | |||
218 | $this->assertEquals(array(1 => 'second'), $event->getData()); | ||
219 | } | ||
220 | |||
221 | public function testOnSubmitNormDataDoesNothingIfNotAllowDelete() | ||
222 | { | ||
223 | $this->form->add($this->getForm('1')); | ||
224 | |||
225 | $data = array(0 => 'first', 1 => 'second', 2 => 'third'); | ||
226 | $event = new FormEvent($this->form, $data); | ||
227 | $listener = new ResizeFormListener('text', array(), false, false); | ||
228 | $listener->onSubmit($event); | ||
229 | |||
230 | $this->assertEquals($data, $event->getData()); | ||
231 | } | ||
232 | |||
233 | /** | ||
234 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
235 | */ | ||
236 | public function testOnSubmitNormDataRequiresArrayOrTraversable() | ||
237 | { | ||
238 | $data = 'no array or traversable'; | ||
239 | $event = new FormEvent($this->form, $data); | ||
240 | $listener = new ResizeFormListener('text', array(), false, false); | ||
241 | $listener->onSubmit($event); | ||
242 | } | ||
243 | |||
244 | public function testOnSubmitNormDataDealsWithNullData() | ||
245 | { | ||
246 | $this->form->add($this->getForm('1')); | ||
247 | |||
248 | $data = null; | ||
249 | $event = new FormEvent($this->form, $data); | ||
250 | $listener = new ResizeFormListener('text', array(), false, true); | ||
251 | $listener->onSubmit($event); | ||
252 | |||
253 | $this->assertEquals(array(), $event->getData()); | ||
254 | } | ||
255 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php deleted file mode 100644 index 4e368933..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvent; | ||
15 | use Symfony\Component\Form\Extension\Core\EventListener\TrimListener; | ||
16 | |||
17 | class TrimListenerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
22 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | public function testTrim() | ||
27 | { | ||
28 | $data = " Foo! "; | ||
29 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
30 | $event = new FormEvent($form, $data); | ||
31 | |||
32 | $filter = new TrimListener(); | ||
33 | $filter->preSubmit($event); | ||
34 | |||
35 | $this->assertEquals('Foo!', $event->getData()); | ||
36 | } | ||
37 | |||
38 | public function testTrimSkipNonStrings() | ||
39 | { | ||
40 | $data = 1234; | ||
41 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
42 | $event = new FormEvent($form, $data); | ||
43 | |||
44 | $filter = new TrimListener(); | ||
45 | $filter->preSubmit($event); | ||
46 | |||
47 | $this->assertSame(1234, $event->getData()); | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * @dataProvider codePointProvider | ||
52 | */ | ||
53 | public function testTrimUtf8($chars) | ||
54 | { | ||
55 | if (!function_exists('mb_check_encoding')) { | ||
56 | $this->markTestSkipped('The "mb_check_encoding" function is not available'); | ||
57 | } | ||
58 | |||
59 | $data = mb_convert_encoding(pack('H*', implode('', $chars)), 'UTF-8', 'UCS-2BE'); | ||
60 | $data = $data."ab\ncd".$data; | ||
61 | |||
62 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
63 | $event = new FormEvent($form, $data); | ||
64 | |||
65 | $filter = new TrimListener(); | ||
66 | $filter->preSubmit($event); | ||
67 | |||
68 | $this->assertSame("ab\ncd", $event->getData(), 'TrimListener should trim character(s): '.implode(', ', $chars)); | ||
69 | } | ||
70 | |||
71 | public function codePointProvider() | ||
72 | { | ||
73 | return array( | ||
74 | 'General category: Separator' => array(array('0020', '00A0', '1680', '180E', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '200A', '2028', '2029', '202F', '205F', '3000')), | ||
75 | 'General category: Other, control' => array(array('0009', '000A', '000B', '000C', '000D', '0085')), | ||
76 | //'General category: Other, format. ZERO WIDTH SPACE' => array(array('200B')), | ||
77 | ); | ||
78 | } | ||
79 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php deleted file mode 100644 index bfa1e218..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
18 | { | ||
19 | public function testPassDisabledAsOption() | ||
20 | { | ||
21 | $form = $this->factory->create($this->getTestedType(), null, array('disabled' => true)); | ||
22 | |||
23 | $this->assertTrue($form->isDisabled()); | ||
24 | } | ||
25 | |||
26 | public function testPassIdAndNameToView() | ||
27 | { | ||
28 | $view = $this->factory->createNamed('name', $this->getTestedType()) | ||
29 | ->createView(); | ||
30 | |||
31 | $this->assertEquals('name', $view->vars['id']); | ||
32 | $this->assertEquals('name', $view->vars['name']); | ||
33 | $this->assertEquals('name', $view->vars['full_name']); | ||
34 | } | ||
35 | |||
36 | public function testStripLeadingUnderscoresAndDigitsFromId() | ||
37 | { | ||
38 | $view = $this->factory->createNamed('_09name', $this->getTestedType()) | ||
39 | ->createView(); | ||
40 | |||
41 | $this->assertEquals('name', $view->vars['id']); | ||
42 | $this->assertEquals('_09name', $view->vars['name']); | ||
43 | $this->assertEquals('_09name', $view->vars['full_name']); | ||
44 | } | ||
45 | |||
46 | public function testPassIdAndNameToViewWithParent() | ||
47 | { | ||
48 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
49 | ->add('child', $this->getTestedType()) | ||
50 | ->getForm() | ||
51 | ->createView(); | ||
52 | |||
53 | $this->assertEquals('parent_child', $view['child']->vars['id']); | ||
54 | $this->assertEquals('child', $view['child']->vars['name']); | ||
55 | $this->assertEquals('parent[child]', $view['child']->vars['full_name']); | ||
56 | } | ||
57 | |||
58 | public function testPassIdAndNameToViewWithGrandParent() | ||
59 | { | ||
60 | $builder = $this->factory->createNamedBuilder('parent', 'form') | ||
61 | ->add('child', 'form'); | ||
62 | $builder->get('child')->add('grand_child', $this->getTestedType()); | ||
63 | $view = $builder->getForm()->createView(); | ||
64 | |||
65 | $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); | ||
66 | $this->assertEquals('grand_child', $view['child']['grand_child']->vars['name']); | ||
67 | $this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->vars['full_name']); | ||
68 | } | ||
69 | |||
70 | public function testPassTranslationDomainToView() | ||
71 | { | ||
72 | $form = $this->factory->create($this->getTestedType(), null, array( | ||
73 | 'translation_domain' => 'domain', | ||
74 | )); | ||
75 | $view = $form->createView(); | ||
76 | |||
77 | $this->assertSame('domain', $view->vars['translation_domain']); | ||
78 | } | ||
79 | |||
80 | public function testInheritTranslationDomainFromParent() | ||
81 | { | ||
82 | $view = $this->factory | ||
83 | ->createNamedBuilder('parent', 'form', null, array( | ||
84 | 'translation_domain' => 'domain', | ||
85 | )) | ||
86 | ->add('child', $this->getTestedType()) | ||
87 | ->getForm() | ||
88 | ->createView(); | ||
89 | |||
90 | $this->assertEquals('domain', $view['child']->vars['translation_domain']); | ||
91 | } | ||
92 | |||
93 | public function testPreferOwnTranslationDomain() | ||
94 | { | ||
95 | $view = $this->factory | ||
96 | ->createNamedBuilder('parent', 'form', null, array( | ||
97 | 'translation_domain' => 'parent_domain', | ||
98 | )) | ||
99 | ->add('child', $this->getTestedType(), array( | ||
100 | 'translation_domain' => 'domain', | ||
101 | )) | ||
102 | ->getForm() | ||
103 | ->createView(); | ||
104 | |||
105 | $this->assertEquals('domain', $view['child']->vars['translation_domain']); | ||
106 | } | ||
107 | |||
108 | public function testDefaultTranslationDomain() | ||
109 | { | ||
110 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
111 | ->add('child', $this->getTestedType()) | ||
112 | ->getForm() | ||
113 | ->createView(); | ||
114 | |||
115 | $this->assertEquals('messages', $view['child']->vars['translation_domain']); | ||
116 | } | ||
117 | |||
118 | public function testPassLabelToView() | ||
119 | { | ||
120 | $form = $this->factory->createNamed('__test___field', $this->getTestedType(), null, array('label' => 'My label')); | ||
121 | $view = $form->createView(); | ||
122 | |||
123 | $this->assertSame('My label', $view->vars['label']); | ||
124 | } | ||
125 | |||
126 | public function testPassMultipartFalseToView() | ||
127 | { | ||
128 | $form = $this->factory->create($this->getTestedType()); | ||
129 | $view = $form->createView(); | ||
130 | |||
131 | $this->assertFalse($view->vars['multipart']); | ||
132 | } | ||
133 | |||
134 | abstract protected function getTestedType(); | ||
135 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php deleted file mode 100644 index 55835e77..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | class ButtonTypeTest extends BaseTypeTest | ||
18 | { | ||
19 | public function testCreateButtonInstances() | ||
20 | { | ||
21 | $this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('button')); | ||
22 | } | ||
23 | |||
24 | protected function getTestedType() | ||
25 | { | ||
26 | return 'button'; | ||
27 | } | ||
28 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php deleted file mode 100644 index c782adab..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\CallbackTransformer; | ||
15 | |||
16 | class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
17 | { | ||
18 | public function testPassValueToView() | ||
19 | { | ||
20 | $form = $this->factory->create('checkbox', null, array('value' => 'foobar')); | ||
21 | $view = $form->createView(); | ||
22 | |||
23 | $this->assertEquals('foobar', $view->vars['value']); | ||
24 | } | ||
25 | |||
26 | public function testCheckedIfDataTrue() | ||
27 | { | ||
28 | $form = $this->factory->create('checkbox'); | ||
29 | $form->setData(true); | ||
30 | $view = $form->createView(); | ||
31 | |||
32 | $this->assertTrue($view->vars['checked']); | ||
33 | } | ||
34 | |||
35 | public function testCheckedIfDataTrueWithEmptyValue() | ||
36 | { | ||
37 | $form = $this->factory->create('checkbox', null, array('value' => '')); | ||
38 | $form->setData(true); | ||
39 | $view = $form->createView(); | ||
40 | |||
41 | $this->assertTrue($view->vars['checked']); | ||
42 | } | ||
43 | |||
44 | public function testNotCheckedIfDataFalse() | ||
45 | { | ||
46 | $form = $this->factory->create('checkbox'); | ||
47 | $form->setData(false); | ||
48 | $view = $form->createView(); | ||
49 | |||
50 | $this->assertFalse($view->vars['checked']); | ||
51 | } | ||
52 | |||
53 | public function testSubmitWithValueChecked() | ||
54 | { | ||
55 | $form = $this->factory->create('checkbox', null, array( | ||
56 | 'value' => 'foobar', | ||
57 | )); | ||
58 | $form->submit('foobar'); | ||
59 | |||
60 | $this->assertTrue($form->getData()); | ||
61 | $this->assertEquals('foobar', $form->getViewData()); | ||
62 | } | ||
63 | |||
64 | public function testSubmitWithRandomValueChecked() | ||
65 | { | ||
66 | $form = $this->factory->create('checkbox', null, array( | ||
67 | 'value' => 'foobar', | ||
68 | )); | ||
69 | $form->submit('krixikraxi'); | ||
70 | |||
71 | $this->assertTrue($form->getData()); | ||
72 | $this->assertEquals('foobar', $form->getViewData()); | ||
73 | } | ||
74 | |||
75 | public function testSubmitWithValueUnchecked() | ||
76 | { | ||
77 | $form = $this->factory->create('checkbox', null, array( | ||
78 | 'value' => 'foobar', | ||
79 | )); | ||
80 | $form->submit(null); | ||
81 | |||
82 | $this->assertFalse($form->getData()); | ||
83 | $this->assertNull($form->getViewData()); | ||
84 | } | ||
85 | |||
86 | public function testSubmitWithEmptyValueChecked() | ||
87 | { | ||
88 | $form = $this->factory->create('checkbox', null, array( | ||
89 | 'value' => '', | ||
90 | )); | ||
91 | $form->submit(''); | ||
92 | |||
93 | $this->assertTrue($form->getData()); | ||
94 | $this->assertSame('', $form->getViewData()); | ||
95 | } | ||
96 | |||
97 | public function testSubmitWithEmptyValueUnchecked() | ||
98 | { | ||
99 | $form = $this->factory->create('checkbox', null, array( | ||
100 | 'value' => '', | ||
101 | )); | ||
102 | $form->submit(null); | ||
103 | |||
104 | $this->assertFalse($form->getData()); | ||
105 | $this->assertNull($form->getViewData()); | ||
106 | } | ||
107 | |||
108 | public function testBindWithEmptyValueAndFalseUnchecked() | ||
109 | { | ||
110 | $form = $this->factory->create('checkbox', null, array( | ||
111 | 'value' => '', | ||
112 | )); | ||
113 | $form->bind(false); | ||
114 | |||
115 | $this->assertFalse($form->getData()); | ||
116 | $this->assertNull($form->getViewData()); | ||
117 | } | ||
118 | |||
119 | public function testBindWithEmptyValueAndTrueChecked() | ||
120 | { | ||
121 | $form = $this->factory->create('checkbox', null, array( | ||
122 | 'value' => '', | ||
123 | )); | ||
124 | $form->bind(true); | ||
125 | |||
126 | $this->assertTrue($form->getData()); | ||
127 | $this->assertSame('', $form->getViewData()); | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * @dataProvider provideTransformedData | ||
132 | */ | ||
133 | public function testTransformedData($data, $expected) | ||
134 | { | ||
135 | // present a binary status field as a checkbox | ||
136 | $transformer = new CallbackTransformer( | ||
137 | function ($value) { | ||
138 | return 'expedited' == $value; | ||
139 | }, | ||
140 | function ($value) { | ||
141 | return $value ? 'expedited' : 'standard'; | ||
142 | } | ||
143 | ); | ||
144 | |||
145 | $form = $this->builder | ||
146 | ->create('expedited_shipping', 'checkbox') | ||
147 | ->addModelTransformer($transformer) | ||
148 | ->getForm(); | ||
149 | $form->setData($data); | ||
150 | $view = $form->createView(); | ||
151 | |||
152 | $this->assertEquals($expected, $view->vars['checked']); | ||
153 | } | ||
154 | |||
155 | public function provideTransformedData() | ||
156 | { | ||
157 | return array( | ||
158 | array('expedited', true), | ||
159 | array('standard', false), | ||
160 | ); | ||
161 | } | ||
162 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php deleted file mode 100644 index 0685946f..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Test\FormPerformanceTestCase; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class ChoiceTypePerformanceTest extends FormPerformanceTestCase | ||
20 | { | ||
21 | /** | ||
22 | * This test case is realistic in collection forms where each | ||
23 | * row contains the same choice field. | ||
24 | * | ||
25 | * @group benchmark | ||
26 | */ | ||
27 | public function testSameChoiceFieldCreatedMultipleTimes() | ||
28 | { | ||
29 | $this->setMaxRunningTime(1); | ||
30 | $choices = range(1, 300); | ||
31 | |||
32 | for ($i = 0; $i < 100; ++$i) { | ||
33 | $this->factory->create('choice', rand(1, 400), array( | ||
34 | 'choices' => $choices, | ||
35 | )); | ||
36 | } | ||
37 | } | ||
38 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php deleted file mode 100644 index 219e8181..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ /dev/null | |||
@@ -1,949 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; | ||
15 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
16 | |||
17 | class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
18 | { | ||
19 | private $choices = array( | ||
20 | 'a' => 'Bernhard', | ||
21 | 'b' => 'Fabien', | ||
22 | 'c' => 'Kris', | ||
23 | 'd' => 'Jon', | ||
24 | 'e' => 'Roman', | ||
25 | ); | ||
26 | |||
27 | private $numericChoices = array( | ||
28 | 0 => 'Bernhard', | ||
29 | 1 => 'Fabien', | ||
30 | 2 => 'Kris', | ||
31 | 3 => 'Jon', | ||
32 | 4 => 'Roman', | ||
33 | ); | ||
34 | |||
35 | private $objectChoices; | ||
36 | |||
37 | protected $groupedChoices = array( | ||
38 | 'Symfony' => array( | ||
39 | 'a' => 'Bernhard', | ||
40 | 'b' => 'Fabien', | ||
41 | 'c' => 'Kris', | ||
42 | ), | ||
43 | 'Doctrine' => array( | ||
44 | 'd' => 'Jon', | ||
45 | 'e' => 'Roman', | ||
46 | ) | ||
47 | ); | ||
48 | |||
49 | protected function setUp() | ||
50 | { | ||
51 | parent::setUp(); | ||
52 | |||
53 | $this->objectChoices = array( | ||
54 | (object) array('id' => 1, 'name' => 'Bernhard'), | ||
55 | (object) array('id' => 2, 'name' => 'Fabien'), | ||
56 | (object) array('id' => 3, 'name' => 'Kris'), | ||
57 | (object) array('id' => 4, 'name' => 'Jon'), | ||
58 | (object) array('id' => 5, 'name' => 'Roman'), | ||
59 | ); | ||
60 | } | ||
61 | |||
62 | protected function tearDown() | ||
63 | { | ||
64 | parent::tearDown(); | ||
65 | |||
66 | $this->objectChoices = null; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @expectedException \PHPUnit_Framework_Error | ||
71 | */ | ||
72 | public function testChoicesOptionExpectsArray() | ||
73 | { | ||
74 | $this->factory->create('choice', null, array( | ||
75 | 'choices' => new \ArrayObject(), | ||
76 | )); | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
81 | */ | ||
82 | public function testChoiceListOptionExpectsChoiceListInterface() | ||
83 | { | ||
84 | $this->factory->create('choice', null, array( | ||
85 | 'choice_list' => array('foo' => 'foo'), | ||
86 | )); | ||
87 | } | ||
88 | |||
89 | public function testChoiceListAndChoicesCanBeEmpty() | ||
90 | { | ||
91 | $this->factory->create('choice'); | ||
92 | } | ||
93 | |||
94 | public function testExpandedChoicesOptionsTurnIntoChildren() | ||
95 | { | ||
96 | $form = $this->factory->create('choice', null, array( | ||
97 | 'expanded' => true, | ||
98 | 'choices' => $this->choices, | ||
99 | )); | ||
100 | |||
101 | $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); | ||
102 | } | ||
103 | |||
104 | public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() | ||
105 | { | ||
106 | $form = $this->factory->create('choice', null, array( | ||
107 | 'multiple' => false, | ||
108 | 'expanded' => true, | ||
109 | 'required' => false, | ||
110 | 'choices' => $this->choices, | ||
111 | )); | ||
112 | |||
113 | $this->assertTrue(isset($form['placeholder'])); | ||
114 | $this->assertCount(count($this->choices) + 1, $form, 'Each choice should become a new field'); | ||
115 | } | ||
116 | |||
117 | public function testPlaceholderNotPresentIfRequired() | ||
118 | { | ||
119 | $form = $this->factory->create('choice', null, array( | ||
120 | 'multiple' => false, | ||
121 | 'expanded' => true, | ||
122 | 'required' => true, | ||
123 | 'choices' => $this->choices, | ||
124 | )); | ||
125 | |||
126 | $this->assertFalse(isset($form['placeholder'])); | ||
127 | $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); | ||
128 | } | ||
129 | |||
130 | public function testPlaceholderNotPresentIfMultiple() | ||
131 | { | ||
132 | $form = $this->factory->create('choice', null, array( | ||
133 | 'multiple' => true, | ||
134 | 'expanded' => true, | ||
135 | 'required' => false, | ||
136 | 'choices' => $this->choices, | ||
137 | )); | ||
138 | |||
139 | $this->assertFalse(isset($form['placeholder'])); | ||
140 | $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); | ||
141 | } | ||
142 | |||
143 | public function testPlaceholderNotPresentIfEmptyChoice() | ||
144 | { | ||
145 | $form = $this->factory->create('choice', null, array( | ||
146 | 'multiple' => false, | ||
147 | 'expanded' => true, | ||
148 | 'required' => false, | ||
149 | 'choices' => array( | ||
150 | '' => 'Empty', | ||
151 | 1 => 'Not empty', | ||
152 | ), | ||
153 | )); | ||
154 | |||
155 | $this->assertFalse(isset($form['placeholder'])); | ||
156 | $this->assertCount(2, $form, 'Each choice should become a new field'); | ||
157 | } | ||
158 | |||
159 | public function testExpandedChoicesOptionsAreFlattened() | ||
160 | { | ||
161 | $form = $this->factory->create('choice', null, array( | ||
162 | 'expanded' => true, | ||
163 | 'choices' => $this->groupedChoices, | ||
164 | )); | ||
165 | |||
166 | $flattened = array(); | ||
167 | foreach ($this->groupedChoices as $choices) { | ||
168 | $flattened = array_merge($flattened, array_keys($choices)); | ||
169 | } | ||
170 | |||
171 | $this->assertCount($form->count(), $flattened, 'Each nested choice should become a new field, not the groups'); | ||
172 | |||
173 | foreach ($flattened as $value => $choice) { | ||
174 | $this->assertTrue($form->has($value), 'Flattened choice is named after it\'s value'); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | public function testExpandedCheckboxesAreNeverRequired() | ||
179 | { | ||
180 | $form = $this->factory->create('choice', null, array( | ||
181 | 'multiple' => true, | ||
182 | 'expanded' => true, | ||
183 | 'required' => true, | ||
184 | 'choices' => $this->choices, | ||
185 | )); | ||
186 | |||
187 | foreach ($form as $child) { | ||
188 | $this->assertFalse($child->isRequired()); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() | ||
193 | { | ||
194 | $form = $this->factory->create('choice', null, array( | ||
195 | 'multiple' => false, | ||
196 | 'expanded' => true, | ||
197 | 'required' => true, | ||
198 | 'choices' => $this->choices, | ||
199 | )); | ||
200 | |||
201 | foreach ($form as $child) { | ||
202 | $this->assertTrue($child->isRequired()); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired() | ||
207 | { | ||
208 | $form = $this->factory->create('choice', null, array( | ||
209 | 'multiple' => false, | ||
210 | 'expanded' => true, | ||
211 | 'required' => false, | ||
212 | 'choices' => $this->choices, | ||
213 | )); | ||
214 | |||
215 | foreach ($form as $child) { | ||
216 | $this->assertFalse($child->isRequired()); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | public function testSubmitSingleNonExpanded() | ||
221 | { | ||
222 | $form = $this->factory->create('choice', null, array( | ||
223 | 'multiple' => false, | ||
224 | 'expanded' => false, | ||
225 | 'choices' => $this->choices, | ||
226 | )); | ||
227 | |||
228 | $form->submit('b'); | ||
229 | |||
230 | $this->assertEquals('b', $form->getData()); | ||
231 | $this->assertEquals('b', $form->getViewData()); | ||
232 | } | ||
233 | |||
234 | public function testSubmitSingleNonExpandedObjectChoices() | ||
235 | { | ||
236 | $form = $this->factory->create('choice', null, array( | ||
237 | 'multiple' => false, | ||
238 | 'expanded' => false, | ||
239 | 'choice_list' => new ObjectChoiceList( | ||
240 | $this->objectChoices, | ||
241 | // label path | ||
242 | 'name', | ||
243 | array(), | ||
244 | null, | ||
245 | // value path | ||
246 | 'id' | ||
247 | ), | ||
248 | )); | ||
249 | |||
250 | // "id" value of the second entry | ||
251 | $form->submit('2'); | ||
252 | |||
253 | $this->assertEquals($this->objectChoices[1], $form->getData()); | ||
254 | $this->assertEquals('2', $form->getViewData()); | ||
255 | } | ||
256 | |||
257 | public function testSubmitMultipleNonExpanded() | ||
258 | { | ||
259 | $form = $this->factory->create('choice', null, array( | ||
260 | 'multiple' => true, | ||
261 | 'expanded' => false, | ||
262 | 'choices' => $this->choices, | ||
263 | )); | ||
264 | |||
265 | $form->submit(array('a', 'b')); | ||
266 | |||
267 | $this->assertEquals(array('a', 'b'), $form->getData()); | ||
268 | $this->assertEquals(array('a', 'b'), $form->getViewData()); | ||
269 | } | ||
270 | |||
271 | public function testSubmitMultipleNonExpandedObjectChoices() | ||
272 | { | ||
273 | $form = $this->factory->create('choice', null, array( | ||
274 | 'multiple' => true, | ||
275 | 'expanded' => false, | ||
276 | 'choice_list' => new ObjectChoiceList( | ||
277 | $this->objectChoices, | ||
278 | // label path | ||
279 | 'name', | ||
280 | array(), | ||
281 | null, | ||
282 | // value path | ||
283 | 'id' | ||
284 | ), | ||
285 | )); | ||
286 | |||
287 | $form->submit(array('2', '3')); | ||
288 | |||
289 | $this->assertEquals(array($this->objectChoices[1], $this->objectChoices[2]), $form->getData()); | ||
290 | $this->assertEquals(array('2', '3'), $form->getViewData()); | ||
291 | } | ||
292 | |||
293 | public function testSubmitSingleExpandedRequired() | ||
294 | { | ||
295 | $form = $this->factory->create('choice', null, array( | ||
296 | 'multiple' => false, | ||
297 | 'expanded' => true, | ||
298 | 'required' => true, | ||
299 | 'choices' => $this->choices, | ||
300 | )); | ||
301 | |||
302 | $form->submit('b'); | ||
303 | |||
304 | $this->assertSame('b', $form->getData()); | ||
305 | $this->assertSame(array( | ||
306 | 0 => false, | ||
307 | 1 => true, | ||
308 | 2 => false, | ||
309 | 3 => false, | ||
310 | 4 => false, | ||
311 | ), $form->getViewData()); | ||
312 | |||
313 | $this->assertFalse($form[0]->getData()); | ||
314 | $this->assertTrue($form[1]->getData()); | ||
315 | $this->assertFalse($form[2]->getData()); | ||
316 | $this->assertFalse($form[3]->getData()); | ||
317 | $this->assertFalse($form[4]->getData()); | ||
318 | $this->assertNull($form[0]->getViewData()); | ||
319 | $this->assertSame('b', $form[1]->getViewData()); | ||
320 | $this->assertNull($form[2]->getViewData()); | ||
321 | $this->assertNull($form[3]->getViewData()); | ||
322 | $this->assertNull($form[4]->getViewData()); | ||
323 | } | ||
324 | |||
325 | public function testSubmitSingleExpandedNonRequired() | ||
326 | { | ||
327 | $form = $this->factory->create('choice', null, array( | ||
328 | 'multiple' => false, | ||
329 | 'expanded' => true, | ||
330 | 'required' => false, | ||
331 | 'choices' => $this->choices, | ||
332 | )); | ||
333 | |||
334 | $form->submit('b'); | ||
335 | |||
336 | $this->assertSame('b', $form->getData()); | ||
337 | $this->assertSame(array( | ||
338 | 0 => false, | ||
339 | 1 => true, | ||
340 | 2 => false, | ||
341 | 3 => false, | ||
342 | 4 => false, | ||
343 | 'placeholder' => false, | ||
344 | ), $form->getViewData()); | ||
345 | |||
346 | $this->assertFalse($form['placeholder']->getData()); | ||
347 | $this->assertFalse($form[0]->getData()); | ||
348 | $this->assertTrue($form[1]->getData()); | ||
349 | $this->assertFalse($form[2]->getData()); | ||
350 | $this->assertFalse($form[3]->getData()); | ||
351 | $this->assertFalse($form[4]->getData()); | ||
352 | $this->assertNull($form['placeholder']->getViewData()); | ||
353 | $this->assertNull($form[0]->getViewData()); | ||
354 | $this->assertSame('b', $form[1]->getViewData()); | ||
355 | $this->assertNull($form[2]->getViewData()); | ||
356 | $this->assertNull($form[3]->getViewData()); | ||
357 | $this->assertNull($form[4]->getViewData()); | ||
358 | } | ||
359 | |||
360 | public function testSubmitSingleExpandedRequiredNothingChecked() | ||
361 | { | ||
362 | $form = $this->factory->create('choice', null, array( | ||
363 | 'multiple' => false, | ||
364 | 'expanded' => true, | ||
365 | 'required' => true, | ||
366 | 'choices' => $this->choices, | ||
367 | )); | ||
368 | |||
369 | $form->submit(null); | ||
370 | |||
371 | $this->assertNull($form->getData()); | ||
372 | $this->assertSame(array( | ||
373 | 0 => false, | ||
374 | 1 => false, | ||
375 | 2 => false, | ||
376 | 3 => false, | ||
377 | 4 => false, | ||
378 | ), $form->getViewData()); | ||
379 | |||
380 | $this->assertFalse($form[0]->getData()); | ||
381 | $this->assertFalse($form[1]->getData()); | ||
382 | $this->assertFalse($form[2]->getData()); | ||
383 | $this->assertFalse($form[3]->getData()); | ||
384 | $this->assertFalse($form[4]->getData()); | ||
385 | $this->assertNull($form[0]->getViewData()); | ||
386 | $this->assertNull($form[1]->getViewData()); | ||
387 | $this->assertNull($form[2]->getViewData()); | ||
388 | $this->assertNull($form[3]->getViewData()); | ||
389 | $this->assertNull($form[4]->getViewData()); | ||
390 | } | ||
391 | |||
392 | public function testSubmitSingleExpandedNonRequiredNothingChecked() | ||
393 | { | ||
394 | $form = $this->factory->create('choice', null, array( | ||
395 | 'multiple' => false, | ||
396 | 'expanded' => true, | ||
397 | 'required' => false, | ||
398 | 'choices' => $this->choices, | ||
399 | )); | ||
400 | |||
401 | $form->submit(null); | ||
402 | |||
403 | $this->assertNull($form->getData()); | ||
404 | $this->assertSame(array( | ||
405 | 0 => false, | ||
406 | 1 => false, | ||
407 | 2 => false, | ||
408 | 3 => false, | ||
409 | 4 => false, | ||
410 | 'placeholder' => true, | ||
411 | ), $form->getViewData()); | ||
412 | |||
413 | $this->assertTrue($form['placeholder']->getData()); | ||
414 | $this->assertFalse($form[0]->getData()); | ||
415 | $this->assertFalse($form[1]->getData()); | ||
416 | $this->assertFalse($form[2]->getData()); | ||
417 | $this->assertFalse($form[3]->getData()); | ||
418 | $this->assertFalse($form[4]->getData()); | ||
419 | $this->assertSame('', $form['placeholder']->getViewData()); | ||
420 | $this->assertNull($form[0]->getViewData()); | ||
421 | $this->assertNull($form[1]->getViewData()); | ||
422 | $this->assertNull($form[2]->getViewData()); | ||
423 | $this->assertNull($form[3]->getViewData()); | ||
424 | $this->assertNull($form[4]->getViewData()); | ||
425 | } | ||
426 | |||
427 | public function testSubmitFalseToSingleExpandedRequiredDoesNotProduceExtraChildrenError() | ||
428 | { | ||
429 | $form = $this->factory->create('choice', null, array( | ||
430 | 'multiple' => false, | ||
431 | 'expanded' => true, | ||
432 | 'required' => true, | ||
433 | 'choices' => $this->choices, | ||
434 | )); | ||
435 | |||
436 | $form->submit(false); | ||
437 | |||
438 | $this->assertEmpty($form->getExtraData()); | ||
439 | $this->assertNull($form->getData()); | ||
440 | } | ||
441 | |||
442 | public function testSubmitFalseToSingleExpandedNonRequiredDoesNotProduceExtraChildrenError() | ||
443 | { | ||
444 | $form = $this->factory->create('choice', null, array( | ||
445 | 'multiple' => false, | ||
446 | 'expanded' => true, | ||
447 | 'required' => false, | ||
448 | 'choices' => $this->choices, | ||
449 | )); | ||
450 | |||
451 | $form->submit(false); | ||
452 | |||
453 | $this->assertEmpty($form->getExtraData()); | ||
454 | $this->assertNull($form->getData()); | ||
455 | } | ||
456 | |||
457 | public function testSubmitSingleExpandedWithEmptyChild() | ||
458 | { | ||
459 | $form = $this->factory->create('choice', null, array( | ||
460 | 'multiple' => false, | ||
461 | 'expanded' => true, | ||
462 | 'choices' => array( | ||
463 | '' => 'Empty', | ||
464 | 1 => 'Not empty', | ||
465 | ), | ||
466 | )); | ||
467 | |||
468 | $form->submit(''); | ||
469 | |||
470 | $this->assertNull($form->getData()); | ||
471 | $this->assertTrue($form[0]->getData()); | ||
472 | $this->assertFalse($form[1]->getData()); | ||
473 | $this->assertSame('', $form[0]->getViewData()); | ||
474 | $this->assertNull($form[1]->getViewData()); | ||
475 | } | ||
476 | |||
477 | public function testSubmitSingleExpandedObjectChoices() | ||
478 | { | ||
479 | $form = $this->factory->create('choice', null, array( | ||
480 | 'multiple' => false, | ||
481 | 'expanded' => true, | ||
482 | 'choice_list' => new ObjectChoiceList( | ||
483 | $this->objectChoices, | ||
484 | // label path | ||
485 | 'name', | ||
486 | array(), | ||
487 | null, | ||
488 | // value path | ||
489 | 'id' | ||
490 | ), | ||
491 | )); | ||
492 | |||
493 | $form->submit('2'); | ||
494 | |||
495 | $this->assertSame($this->objectChoices[1], $form->getData()); | ||
496 | $this->assertFalse($form[0]->getData()); | ||
497 | $this->assertTrue($form[1]->getData()); | ||
498 | $this->assertFalse($form[2]->getData()); | ||
499 | $this->assertFalse($form[3]->getData()); | ||
500 | $this->assertFalse($form[4]->getData()); | ||
501 | $this->assertNull($form[0]->getViewData()); | ||
502 | $this->assertSame('2', $form[1]->getViewData()); | ||
503 | $this->assertNull($form[2]->getViewData()); | ||
504 | $this->assertNull($form[3]->getViewData()); | ||
505 | $this->assertNull($form[4]->getViewData()); | ||
506 | } | ||
507 | |||
508 | public function testSubmitSingleExpandedNumericChoices() | ||
509 | { | ||
510 | $form = $this->factory->create('choice', null, array( | ||
511 | 'multiple' => false, | ||
512 | 'expanded' => true, | ||
513 | 'choices' => $this->numericChoices, | ||
514 | )); | ||
515 | |||
516 | $form->submit('1'); | ||
517 | |||
518 | $this->assertSame(1, $form->getData()); | ||
519 | $this->assertFalse($form[0]->getData()); | ||
520 | $this->assertTrue($form[1]->getData()); | ||
521 | $this->assertFalse($form[2]->getData()); | ||
522 | $this->assertFalse($form[3]->getData()); | ||
523 | $this->assertFalse($form[4]->getData()); | ||
524 | $this->assertNull($form[0]->getViewData()); | ||
525 | $this->assertSame('1', $form[1]->getViewData()); | ||
526 | $this->assertNull($form[2]->getViewData()); | ||
527 | $this->assertNull($form[3]->getViewData()); | ||
528 | $this->assertNull($form[4]->getViewData()); | ||
529 | } | ||
530 | |||
531 | public function testSubmitMultipleExpanded() | ||
532 | { | ||
533 | $form = $this->factory->create('choice', null, array( | ||
534 | 'multiple' => true, | ||
535 | 'expanded' => true, | ||
536 | 'choices' => $this->choices, | ||
537 | )); | ||
538 | |||
539 | $form->submit(array('a', 'c')); | ||
540 | |||
541 | $this->assertSame(array('a', 'c'), $form->getData()); | ||
542 | $this->assertTrue($form[0]->getData()); | ||
543 | $this->assertFalse($form[1]->getData()); | ||
544 | $this->assertTrue($form[2]->getData()); | ||
545 | $this->assertFalse($form[3]->getData()); | ||
546 | $this->assertFalse($form[4]->getData()); | ||
547 | $this->assertSame('a', $form[0]->getViewData()); | ||
548 | $this->assertNull($form[1]->getViewData()); | ||
549 | $this->assertSame('c', $form[2]->getViewData()); | ||
550 | $this->assertNull($form[3]->getViewData()); | ||
551 | $this->assertNull($form[4]->getViewData()); | ||
552 | } | ||
553 | |||
554 | public function testSubmitMultipleExpandedEmpty() | ||
555 | { | ||
556 | $form = $this->factory->create('choice', null, array( | ||
557 | 'multiple' => true, | ||
558 | 'expanded' => true, | ||
559 | 'choices' => $this->choices, | ||
560 | )); | ||
561 | |||
562 | $form->submit(array()); | ||
563 | |||
564 | $this->assertSame(array(), $form->getData()); | ||
565 | $this->assertFalse($form[0]->getData()); | ||
566 | $this->assertFalse($form[1]->getData()); | ||
567 | $this->assertFalse($form[2]->getData()); | ||
568 | $this->assertFalse($form[3]->getData()); | ||
569 | $this->assertFalse($form[4]->getData()); | ||
570 | $this->assertNull($form[0]->getViewData()); | ||
571 | $this->assertNull($form[1]->getViewData()); | ||
572 | $this->assertNull($form[2]->getViewData()); | ||
573 | $this->assertNull($form[3]->getViewData()); | ||
574 | $this->assertNull($form[4]->getViewData()); | ||
575 | } | ||
576 | |||
577 | public function testSubmitMultipleExpandedWithEmptyChild() | ||
578 | { | ||
579 | $form = $this->factory->create('choice', null, array( | ||
580 | 'multiple' => true, | ||
581 | 'expanded' => true, | ||
582 | 'choices' => array( | ||
583 | '' => 'Empty', | ||
584 | 1 => 'Not Empty', | ||
585 | 2 => 'Not Empty 2', | ||
586 | ) | ||
587 | )); | ||
588 | |||
589 | $form->submit(array('', '2')); | ||
590 | |||
591 | $this->assertSame(array('', 2), $form->getData()); | ||
592 | $this->assertTrue($form[0]->getData()); | ||
593 | $this->assertFalse($form[1]->getData()); | ||
594 | $this->assertTrue($form[2]->getData()); | ||
595 | $this->assertSame('', $form[0]->getViewData()); | ||
596 | $this->assertNull($form[1]->getViewData()); | ||
597 | $this->assertSame('2', $form[2]->getViewData()); | ||
598 | } | ||
599 | |||
600 | public function testSubmitMultipleExpandedObjectChoices() | ||
601 | { | ||
602 | $form = $this->factory->create('choice', null, array( | ||
603 | 'multiple' => true, | ||
604 | 'expanded' => true, | ||
605 | 'choice_list' => new ObjectChoiceList( | ||
606 | $this->objectChoices, | ||
607 | // label path | ||
608 | 'name', | ||
609 | array(), | ||
610 | null, | ||
611 | // value path | ||
612 | 'id' | ||
613 | ), | ||
614 | )); | ||
615 | |||
616 | $form->submit(array('1', '2')); | ||
617 | |||
618 | $this->assertSame(array($this->objectChoices[0], $this->objectChoices[1]), $form->getData()); | ||
619 | $this->assertTrue($form[0]->getData()); | ||
620 | $this->assertTrue($form[1]->getData()); | ||
621 | $this->assertFalse($form[2]->getData()); | ||
622 | $this->assertFalse($form[3]->getData()); | ||
623 | $this->assertFalse($form[4]->getData()); | ||
624 | $this->assertSame('1', $form[0]->getViewData()); | ||
625 | $this->assertSame('2', $form[1]->getViewData()); | ||
626 | $this->assertNull($form[2]->getViewData()); | ||
627 | $this->assertNull($form[3]->getViewData()); | ||
628 | $this->assertNull($form[4]->getViewData()); | ||
629 | } | ||
630 | |||
631 | public function testSubmitMultipleExpandedNumericChoices() | ||
632 | { | ||
633 | $form = $this->factory->create('choice', null, array( | ||
634 | 'multiple' => true, | ||
635 | 'expanded' => true, | ||
636 | 'choices' => $this->numericChoices, | ||
637 | )); | ||
638 | |||
639 | $form->submit(array('1', '2')); | ||
640 | |||
641 | $this->assertSame(array(1, 2), $form->getData()); | ||
642 | $this->assertFalse($form[0]->getData()); | ||
643 | $this->assertTrue($form[1]->getData()); | ||
644 | $this->assertTrue($form[2]->getData()); | ||
645 | $this->assertFalse($form[3]->getData()); | ||
646 | $this->assertFalse($form[4]->getData()); | ||
647 | $this->assertNull($form[0]->getViewData()); | ||
648 | $this->assertSame('1', $form[1]->getViewData()); | ||
649 | $this->assertSame('2', $form[2]->getViewData()); | ||
650 | $this->assertNull($form[3]->getViewData()); | ||
651 | $this->assertNull($form[4]->getViewData()); | ||
652 | } | ||
653 | |||
654 | /* | ||
655 | * We need this functionality to create choice fields for Boolean types, | ||
656 | * e.g. false => 'No', true => 'Yes' | ||
657 | */ | ||
658 | public function testSetDataSingleNonExpandedAcceptsBoolean() | ||
659 | { | ||
660 | $form = $this->factory->create('choice', null, array( | ||
661 | 'multiple' => false, | ||
662 | 'expanded' => false, | ||
663 | 'choices' => $this->numericChoices, | ||
664 | )); | ||
665 | |||
666 | $form->setData(false); | ||
667 | |||
668 | $this->assertFalse($form->getData()); | ||
669 | $this->assertEquals('0', $form->getViewData()); | ||
670 | } | ||
671 | |||
672 | public function testSetDataMultipleNonExpandedAcceptsBoolean() | ||
673 | { | ||
674 | $form = $this->factory->create('choice', null, array( | ||
675 | 'multiple' => true, | ||
676 | 'expanded' => false, | ||
677 | 'choices' => $this->numericChoices, | ||
678 | )); | ||
679 | |||
680 | $form->setData(array(false, true)); | ||
681 | |||
682 | $this->assertEquals(array(false, true), $form->getData()); | ||
683 | $this->assertEquals(array('0', '1'), $form->getViewData()); | ||
684 | } | ||
685 | |||
686 | public function testPassRequiredToView() | ||
687 | { | ||
688 | $form = $this->factory->create('choice', null, array( | ||
689 | 'choices' => $this->choices, | ||
690 | )); | ||
691 | $view = $form->createView(); | ||
692 | |||
693 | $this->assertTrue($view->vars['required']); | ||
694 | } | ||
695 | |||
696 | public function testPassNonRequiredToView() | ||
697 | { | ||
698 | $form = $this->factory->create('choice', null, array( | ||
699 | 'required' => false, | ||
700 | 'choices' => $this->choices, | ||
701 | )); | ||
702 | $view = $form->createView(); | ||
703 | |||
704 | $this->assertFalse($view->vars['required']); | ||
705 | } | ||
706 | |||
707 | public function testPassMultipleToView() | ||
708 | { | ||
709 | $form = $this->factory->create('choice', null, array( | ||
710 | 'multiple' => true, | ||
711 | 'choices' => $this->choices, | ||
712 | )); | ||
713 | $view = $form->createView(); | ||
714 | |||
715 | $this->assertTrue($view->vars['multiple']); | ||
716 | } | ||
717 | |||
718 | public function testPassExpandedToView() | ||
719 | { | ||
720 | $form = $this->factory->create('choice', null, array( | ||
721 | 'expanded' => true, | ||
722 | 'choices' => $this->choices, | ||
723 | )); | ||
724 | $view = $form->createView(); | ||
725 | |||
726 | $this->assertTrue($view->vars['expanded']); | ||
727 | } | ||
728 | |||
729 | public function testEmptyValueIsNullByDefaultIfRequired() | ||
730 | { | ||
731 | $form = $this->factory->create('choice', null, array( | ||
732 | 'multiple' => false, | ||
733 | 'required' => true, | ||
734 | 'choices' => $this->choices, | ||
735 | )); | ||
736 | $view = $form->createView(); | ||
737 | |||
738 | $this->assertNull($view->vars['empty_value']); | ||
739 | } | ||
740 | |||
741 | public function testEmptyValueIsEmptyStringByDefaultIfNotRequired() | ||
742 | { | ||
743 | $form = $this->factory->create('choice', null, array( | ||
744 | 'multiple' => false, | ||
745 | 'required' => false, | ||
746 | 'choices' => $this->choices, | ||
747 | )); | ||
748 | $view = $form->createView(); | ||
749 | |||
750 | $this->assertSame('', $view->vars['empty_value']); | ||
751 | } | ||
752 | |||
753 | /** | ||
754 | * @dataProvider getOptionsWithEmptyValue | ||
755 | */ | ||
756 | public function testPassEmptyValueToView($multiple, $expanded, $required, $emptyValue, $viewValue) | ||
757 | { | ||
758 | $form = $this->factory->create('choice', null, array( | ||
759 | 'multiple' => $multiple, | ||
760 | 'expanded' => $expanded, | ||
761 | 'required' => $required, | ||
762 | 'empty_value' => $emptyValue, | ||
763 | 'choices' => $this->choices, | ||
764 | )); | ||
765 | $view = $form->createView(); | ||
766 | |||
767 | $this->assertEquals($viewValue, $view->vars['empty_value']); | ||
768 | } | ||
769 | |||
770 | /** | ||
771 | * @dataProvider getOptionsWithEmptyValue | ||
772 | */ | ||
773 | public function testDontPassEmptyValueIfContainedInChoices($multiple, $expanded, $required, $emptyValue, $viewValue) | ||
774 | { | ||
775 | $form = $this->factory->create('choice', null, array( | ||
776 | 'multiple' => $multiple, | ||
777 | 'expanded' => $expanded, | ||
778 | 'required' => $required, | ||
779 | 'empty_value' => $emptyValue, | ||
780 | 'choices' => array('a' => 'A', '' => 'Empty'), | ||
781 | )); | ||
782 | $view = $form->createView(); | ||
783 | |||
784 | $this->assertNull($view->vars['empty_value']); | ||
785 | } | ||
786 | |||
787 | public function getOptionsWithEmptyValue() | ||
788 | { | ||
789 | return array( | ||
790 | // single non-expanded | ||
791 | array(false, false, false, 'foobar', 'foobar'), | ||
792 | array(false, false, false, '', ''), | ||
793 | array(false, false, false, null, null), | ||
794 | array(false, false, false, false, null), | ||
795 | array(false, false, true, 'foobar', 'foobar'), | ||
796 | array(false, false, true, '', ''), | ||
797 | array(false, false, true, null, null), | ||
798 | array(false, false, true, false, null), | ||
799 | // single expanded | ||
800 | array(false, true, false, 'foobar', 'foobar'), | ||
801 | // radios should never have an empty label | ||
802 | array(false, true, false, '', 'None'), | ||
803 | array(false, true, false, null, null), | ||
804 | array(false, true, false, false, null), | ||
805 | array(false, true, true, 'foobar', 'foobar'), | ||
806 | // radios should never have an empty label | ||
807 | array(false, true, true, '', 'None'), | ||
808 | array(false, true, true, null, null), | ||
809 | array(false, true, true, false, null), | ||
810 | // multiple non-expanded | ||
811 | array(true, false, false, 'foobar', null), | ||
812 | array(true, false, false, '', null), | ||
813 | array(true, false, false, null, null), | ||
814 | array(true, false, false, false, null), | ||
815 | array(true, false, true, 'foobar', null), | ||
816 | array(true, false, true, '', null), | ||
817 | array(true, false, true, null, null), | ||
818 | array(true, false, true, false, null), | ||
819 | // multiple expanded | ||
820 | array(true, true, false, 'foobar', null), | ||
821 | array(true, true, false, '', null), | ||
822 | array(true, true, false, null, null), | ||
823 | array(true, true, false, false, null), | ||
824 | array(true, true, true, 'foobar', null), | ||
825 | array(true, true, true, '', null), | ||
826 | array(true, true, true, null, null), | ||
827 | array(true, true, true, false, null), | ||
828 | ); | ||
829 | } | ||
830 | |||
831 | public function testPassChoicesToView() | ||
832 | { | ||
833 | $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); | ||
834 | $form = $this->factory->create('choice', null, array( | ||
835 | 'choices' => $choices, | ||
836 | )); | ||
837 | $view = $form->createView(); | ||
838 | |||
839 | $this->assertEquals(array( | ||
840 | new ChoiceView('a', 'a', 'A'), | ||
841 | new ChoiceView('b', 'b', 'B'), | ||
842 | new ChoiceView('c', 'c', 'C'), | ||
843 | new ChoiceView('d', 'd', 'D'), | ||
844 | ), $view->vars['choices']); | ||
845 | } | ||
846 | |||
847 | public function testPassPreferredChoicesToView() | ||
848 | { | ||
849 | $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); | ||
850 | $form = $this->factory->create('choice', null, array( | ||
851 | 'choices' => $choices, | ||
852 | 'preferred_choices' => array('b', 'd'), | ||
853 | )); | ||
854 | $view = $form->createView(); | ||
855 | |||
856 | $this->assertEquals(array( | ||
857 | 0 => new ChoiceView('a', 'a', 'A'), | ||
858 | 2 => new ChoiceView('c', 'c', 'C'), | ||
859 | ), $view->vars['choices']); | ||
860 | $this->assertEquals(array( | ||
861 | 1 => new ChoiceView('b', 'b', 'B'), | ||
862 | 3 => new ChoiceView('d', 'd', 'D'), | ||
863 | ), $view->vars['preferred_choices']); | ||
864 | } | ||
865 | |||
866 | public function testPassHierarchicalChoicesToView() | ||
867 | { | ||
868 | $form = $this->factory->create('choice', null, array( | ||
869 | 'choices' => $this->groupedChoices, | ||
870 | 'preferred_choices' => array('b', 'd'), | ||
871 | )); | ||
872 | $view = $form->createView(); | ||
873 | |||
874 | $this->assertEquals(array( | ||
875 | 'Symfony' => array( | ||
876 | 0 => new ChoiceView('a', 'a', 'Bernhard'), | ||
877 | 2 => new ChoiceView('c', 'c', 'Kris'), | ||
878 | ), | ||
879 | 'Doctrine' => array( | ||
880 | 4 => new ChoiceView('e', 'e', 'Roman'), | ||
881 | ), | ||
882 | ), $view->vars['choices']); | ||
883 | $this->assertEquals(array( | ||
884 | 'Symfony' => array( | ||
885 | 1 => new ChoiceView('b', 'b', 'Fabien'), | ||
886 | ), | ||
887 | 'Doctrine' => array( | ||
888 | 3 => new ChoiceView('d', 'd', 'Jon'), | ||
889 | ), | ||
890 | ), $view->vars['preferred_choices']); | ||
891 | } | ||
892 | |||
893 | public function testPassChoiceDataToView() | ||
894 | { | ||
895 | $obj1 = (object) array('value' => 'a', 'label' => 'A'); | ||
896 | $obj2 = (object) array('value' => 'b', 'label' => 'B'); | ||
897 | $obj3 = (object) array('value' => 'c', 'label' => 'C'); | ||
898 | $obj4 = (object) array('value' => 'd', 'label' => 'D'); | ||
899 | $form = $this->factory->create('choice', null, array( | ||
900 | 'choice_list' => new ObjectChoiceList(array($obj1, $obj2, $obj3, $obj4), 'label', array(), null, 'value'), | ||
901 | )); | ||
902 | $view = $form->createView(); | ||
903 | |||
904 | $this->assertEquals(array( | ||
905 | new ChoiceView($obj1, 'a', 'A'), | ||
906 | new ChoiceView($obj2, 'b', 'B'), | ||
907 | new ChoiceView($obj3, 'c', 'C'), | ||
908 | new ChoiceView($obj4, 'd', 'D'), | ||
909 | ), $view->vars['choices']); | ||
910 | } | ||
911 | |||
912 | public function testAdjustFullNameForMultipleNonExpanded() | ||
913 | { | ||
914 | $form = $this->factory->createNamed('name', 'choice', null, array( | ||
915 | 'multiple' => true, | ||
916 | 'expanded' => false, | ||
917 | 'choices' => $this->choices, | ||
918 | )); | ||
919 | $view = $form->createView(); | ||
920 | |||
921 | $this->assertSame('name[]', $view->vars['full_name']); | ||
922 | } | ||
923 | |||
924 | // https://github.com/symfony/symfony/issues/3298 | ||
925 | public function testInitializeWithEmptyChoices() | ||
926 | { | ||
927 | $this->factory->createNamed('name', 'choice', null, array( | ||
928 | 'choices' => array(), | ||
929 | )); | ||
930 | } | ||
931 | |||
932 | public function testInitializeWithDefaultObjectChoice() | ||
933 | { | ||
934 | $obj1 = (object) array('value' => 'a', 'label' => 'A'); | ||
935 | $obj2 = (object) array('value' => 'b', 'label' => 'B'); | ||
936 | $obj3 = (object) array('value' => 'c', 'label' => 'C'); | ||
937 | $obj4 = (object) array('value' => 'd', 'label' => 'D'); | ||
938 | |||
939 | $form = $this->factory->create('choice', null, array( | ||
940 | 'choice_list' => new ObjectChoiceList(array($obj1, $obj2, $obj3, $obj4), 'label', array(), null, 'value'), | ||
941 | // Used to break because "data_class" was inferred, which needs to | ||
942 | // remain null in every case (because it refers to the view format) | ||
943 | 'data' => $obj3, | ||
944 | )); | ||
945 | |||
946 | // Trigger data initialization | ||
947 | $form->getViewData(); | ||
948 | } | ||
949 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php deleted file mode 100644 index be3ad9db..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Form; | ||
15 | |||
16 | class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
17 | { | ||
18 | public function testContainsNoChildByDefault() | ||
19 | { | ||
20 | $form = $this->factory->create('collection', null, array( | ||
21 | 'type' => 'text', | ||
22 | )); | ||
23 | |||
24 | $this->assertCount(0, $form); | ||
25 | } | ||
26 | |||
27 | public function testSetDataAdjustsSize() | ||
28 | { | ||
29 | $form = $this->factory->create('collection', null, array( | ||
30 | 'type' => 'text', | ||
31 | 'options' => array( | ||
32 | 'max_length' => 20, | ||
33 | ), | ||
34 | )); | ||
35 | $form->setData(array('foo@foo.com', 'foo@bar.com')); | ||
36 | |||
37 | $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); | ||
38 | $this->assertInstanceOf('Symfony\Component\Form\Form', $form[1]); | ||
39 | $this->assertCount(2, $form); | ||
40 | $this->assertEquals('foo@foo.com', $form[0]->getData()); | ||
41 | $this->assertEquals('foo@bar.com', $form[1]->getData()); | ||
42 | $this->assertEquals(20, $form[0]->getConfig()->getOption('max_length')); | ||
43 | $this->assertEquals(20, $form[1]->getConfig()->getOption('max_length')); | ||
44 | |||
45 | $form->setData(array('foo@baz.com')); | ||
46 | $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); | ||
47 | $this->assertFalse(isset($form[1])); | ||
48 | $this->assertCount(1, $form); | ||
49 | $this->assertEquals('foo@baz.com', $form[0]->getData()); | ||
50 | $this->assertEquals(20, $form[0]->getConfig()->getOption('max_length')); | ||
51 | } | ||
52 | |||
53 | public function testThrowsExceptionIfObjectIsNotTraversable() | ||
54 | { | ||
55 | $form = $this->factory->create('collection', null, array( | ||
56 | 'type' => 'text', | ||
57 | )); | ||
58 | $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); | ||
59 | $form->setData(new \stdClass()); | ||
60 | } | ||
61 | |||
62 | public function testNotResizedIfSubmittedWithMissingData() | ||
63 | { | ||
64 | $form = $this->factory->create('collection', null, array( | ||
65 | 'type' => 'text', | ||
66 | )); | ||
67 | $form->setData(array('foo@foo.com', 'bar@bar.com')); | ||
68 | $form->submit(array('foo@bar.com')); | ||
69 | |||
70 | $this->assertTrue($form->has('0')); | ||
71 | $this->assertTrue($form->has('1')); | ||
72 | $this->assertEquals('foo@bar.com', $form[0]->getData()); | ||
73 | $this->assertEquals('', $form[1]->getData()); | ||
74 | } | ||
75 | |||
76 | public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() | ||
77 | { | ||
78 | $form = $this->factory->create('collection', null, array( | ||
79 | 'type' => 'text', | ||
80 | 'allow_delete' => true, | ||
81 | )); | ||
82 | $form->setData(array('foo@foo.com', 'bar@bar.com')); | ||
83 | $form->submit(array('foo@foo.com')); | ||
84 | |||
85 | $this->assertTrue($form->has('0')); | ||
86 | $this->assertFalse($form->has('1')); | ||
87 | $this->assertEquals('foo@foo.com', $form[0]->getData()); | ||
88 | $this->assertEquals(array('foo@foo.com'), $form->getData()); | ||
89 | } | ||
90 | |||
91 | public function testNotResizedIfSubmittedWithExtraData() | ||
92 | { | ||
93 | $form = $this->factory->create('collection', null, array( | ||
94 | 'type' => 'text', | ||
95 | )); | ||
96 | $form->setData(array('foo@bar.com')); | ||
97 | $form->submit(array('foo@foo.com', 'bar@bar.com')); | ||
98 | |||
99 | $this->assertTrue($form->has('0')); | ||
100 | $this->assertFalse($form->has('1')); | ||
101 | $this->assertEquals('foo@foo.com', $form[0]->getData()); | ||
102 | } | ||
103 | |||
104 | public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() | ||
105 | { | ||
106 | $form = $this->factory->create('collection', null, array( | ||
107 | 'type' => 'text', | ||
108 | 'allow_add' => true, | ||
109 | )); | ||
110 | $form->setData(array('foo@bar.com')); | ||
111 | $form->submit(array('foo@bar.com', 'bar@bar.com')); | ||
112 | |||
113 | $this->assertTrue($form->has('0')); | ||
114 | $this->assertTrue($form->has('1')); | ||
115 | $this->assertEquals('foo@bar.com', $form[0]->getData()); | ||
116 | $this->assertEquals('bar@bar.com', $form[1]->getData()); | ||
117 | $this->assertEquals(array('foo@bar.com', 'bar@bar.com'), $form->getData()); | ||
118 | } | ||
119 | |||
120 | public function testAllowAddButNoPrototype() | ||
121 | { | ||
122 | $form = $this->factory->create('collection', null, array( | ||
123 | 'type' => 'form', | ||
124 | 'allow_add' => true, | ||
125 | 'prototype' => false, | ||
126 | )); | ||
127 | |||
128 | $this->assertFalse($form->has('__name__')); | ||
129 | } | ||
130 | |||
131 | public function testPrototypeMultipartPropagation() | ||
132 | { | ||
133 | $form = $this->factory | ||
134 | ->create('collection', null, array( | ||
135 | 'type' => 'file', | ||
136 | 'allow_add' => true, | ||
137 | 'prototype' => true, | ||
138 | )) | ||
139 | ; | ||
140 | |||
141 | $this->assertTrue($form->createView()->vars['multipart']); | ||
142 | } | ||
143 | |||
144 | public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() | ||
145 | { | ||
146 | $form = $this->factory->create('collection', array(), array( | ||
147 | 'type' => 'file', | ||
148 | 'prototype' => true, | ||
149 | 'allow_add' => true, | ||
150 | )); | ||
151 | |||
152 | $data = $form->getData(); | ||
153 | $this->assertFalse(isset($data['__name__'])); | ||
154 | } | ||
155 | |||
156 | public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() | ||
157 | { | ||
158 | $form = $this->factory->create('collection', array(), array( | ||
159 | 'type' => 'file', | ||
160 | 'allow_add' => true, | ||
161 | 'prototype' => true, | ||
162 | )); | ||
163 | |||
164 | $form->setData(array('foobar.png')); | ||
165 | $data = $form->getData(); | ||
166 | $this->assertFalse(isset($data['__name__'])); | ||
167 | } | ||
168 | |||
169 | public function testPrototypeNameOption() | ||
170 | { | ||
171 | $form = $this->factory->create('collection', null, array( | ||
172 | 'type' => 'form', | ||
173 | 'prototype' => true, | ||
174 | 'allow_add' => true, | ||
175 | )); | ||
176 | |||
177 | $this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default'); | ||
178 | |||
179 | $form = $this->factory->create('collection', null, array( | ||
180 | 'type' => 'form', | ||
181 | 'prototype' => true, | ||
182 | 'allow_add' => true, | ||
183 | 'prototype_name' => '__test__', | ||
184 | )); | ||
185 | |||
186 | $this->assertSame('__test__', $form->getConfig()->getAttribute('prototype')->getName()); | ||
187 | } | ||
188 | |||
189 | public function testPrototypeDefaultLabel() | ||
190 | { | ||
191 | $form = $this->factory->create('collection', array(), array( | ||
192 | 'type' => 'file', | ||
193 | 'allow_add' => true, | ||
194 | 'prototype' => true, | ||
195 | 'prototype_name' => '__test__', | ||
196 | )); | ||
197 | |||
198 | $this->assertSame('__test__label__', $form->createView()->vars['prototype']->vars['label']); | ||
199 | } | ||
200 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php deleted file mode 100644 index 1d56e2a0..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class CountryTypeTest extends TypeTestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | IntlTestHelper::requireIntl($this); | ||
22 | |||
23 | parent::setUp(); | ||
24 | } | ||
25 | |||
26 | public function testCountriesAreSelectable() | ||
27 | { | ||
28 | $form = $this->factory->create('country'); | ||
29 | $view = $form->createView(); | ||
30 | $choices = $view->vars['choices']; | ||
31 | |||
32 | // Don't check objects for identity | ||
33 | $this->assertContains(new ChoiceView('DE', 'DE', 'Germany'), $choices, '', false, false); | ||
34 | $this->assertContains(new ChoiceView('GB', 'GB', 'United Kingdom'), $choices, '', false, false); | ||
35 | $this->assertContains(new ChoiceView('US', 'US', 'United States'), $choices, '', false, false); | ||
36 | $this->assertContains(new ChoiceView('FR', 'FR', 'France'), $choices, '', false, false); | ||
37 | $this->assertContains(new ChoiceView('MY', 'MY', 'Malaysia'), $choices, '', false, false); | ||
38 | } | ||
39 | |||
40 | public function testUnknownCountryIsNotIncluded() | ||
41 | { | ||
42 | $form = $this->factory->create('country', 'country'); | ||
43 | $view = $form->createView(); | ||
44 | $choices = $view->vars['choices']; | ||
45 | |||
46 | foreach ($choices as $choice) { | ||
47 | if ('ZZ' === $choice->value) { | ||
48 | $this->fail('Should not contain choice "ZZ"'); | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php deleted file mode 100644 index b0eb6dc0..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class CurrencyTypeTest extends TypeTestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | IntlTestHelper::requireIntl($this); | ||
22 | |||
23 | parent::setUp(); | ||
24 | } | ||
25 | |||
26 | public function testCurrenciesAreSelectable() | ||
27 | { | ||
28 | $form = $this->factory->create('currency'); | ||
29 | $view = $form->createView(); | ||
30 | $choices = $view->vars['choices']; | ||
31 | |||
32 | $this->assertContains(new ChoiceView('EUR', 'EUR', 'Euro'), $choices, '', false, false); | ||
33 | $this->assertContains(new ChoiceView('USD', 'USD', 'US Dollar'), $choices, '', false, false); | ||
34 | $this->assertContains(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices, '', false, false); | ||
35 | } | ||
36 | |||
37 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php deleted file mode 100644 index b9c1ebad..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ /dev/null | |||
@@ -1,477 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\FormError; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class DateTimeTypeTest extends TypeTestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | IntlTestHelper::requireIntl($this); | ||
22 | |||
23 | parent::setUp(); | ||
24 | } | ||
25 | |||
26 | public function testSubmitDateTime() | ||
27 | { | ||
28 | $form = $this->factory->create('datetime', null, array( | ||
29 | 'model_timezone' => 'UTC', | ||
30 | 'view_timezone' => 'UTC', | ||
31 | 'date_widget' => 'choice', | ||
32 | 'time_widget' => 'choice', | ||
33 | 'input' => 'datetime', | ||
34 | )); | ||
35 | |||
36 | $form->submit(array( | ||
37 | 'date' => array( | ||
38 | 'day' => '2', | ||
39 | 'month' => '6', | ||
40 | 'year' => '2010', | ||
41 | ), | ||
42 | 'time' => array( | ||
43 | 'hour' => '3', | ||
44 | 'minute' => '4', | ||
45 | ), | ||
46 | )); | ||
47 | |||
48 | $dateTime = new \DateTime('2010-06-02 03:04:00 UTC'); | ||
49 | |||
50 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
51 | } | ||
52 | |||
53 | public function testSubmitString() | ||
54 | { | ||
55 | $form = $this->factory->create('datetime', null, array( | ||
56 | 'model_timezone' => 'UTC', | ||
57 | 'view_timezone' => 'UTC', | ||
58 | 'input' => 'string', | ||
59 | 'date_widget' => 'choice', | ||
60 | 'time_widget' => 'choice', | ||
61 | )); | ||
62 | |||
63 | $form->submit(array( | ||
64 | 'date' => array( | ||
65 | 'day' => '2', | ||
66 | 'month' => '6', | ||
67 | 'year' => '2010', | ||
68 | ), | ||
69 | 'time' => array( | ||
70 | 'hour' => '3', | ||
71 | 'minute' => '4', | ||
72 | ), | ||
73 | )); | ||
74 | |||
75 | $this->assertEquals('2010-06-02 03:04:00', $form->getData()); | ||
76 | } | ||
77 | |||
78 | public function testSubmitTimestamp() | ||
79 | { | ||
80 | $form = $this->factory->create('datetime', null, array( | ||
81 | 'model_timezone' => 'UTC', | ||
82 | 'view_timezone' => 'UTC', | ||
83 | 'input' => 'timestamp', | ||
84 | 'date_widget' => 'choice', | ||
85 | 'time_widget' => 'choice', | ||
86 | )); | ||
87 | |||
88 | $form->submit(array( | ||
89 | 'date' => array( | ||
90 | 'day' => '2', | ||
91 | 'month' => '6', | ||
92 | 'year' => '2010', | ||
93 | ), | ||
94 | 'time' => array( | ||
95 | 'hour' => '3', | ||
96 | 'minute' => '4', | ||
97 | ), | ||
98 | )); | ||
99 | |||
100 | $dateTime = new \DateTime('2010-06-02 03:04:00 UTC'); | ||
101 | |||
102 | $this->assertEquals($dateTime->format('U'), $form->getData()); | ||
103 | } | ||
104 | |||
105 | public function testSubmitWithoutMinutes() | ||
106 | { | ||
107 | $form = $this->factory->create('datetime', null, array( | ||
108 | 'model_timezone' => 'UTC', | ||
109 | 'view_timezone' => 'UTC', | ||
110 | 'date_widget' => 'choice', | ||
111 | 'time_widget' => 'choice', | ||
112 | 'input' => 'datetime', | ||
113 | 'with_minutes' => false, | ||
114 | )); | ||
115 | |||
116 | $form->setData(new \DateTime('2010-06-02 03:04:05 UTC')); | ||
117 | |||
118 | $input = array( | ||
119 | 'date' => array( | ||
120 | 'day' => '2', | ||
121 | 'month' => '6', | ||
122 | 'year' => '2010', | ||
123 | ), | ||
124 | 'time' => array( | ||
125 | 'hour' => '3', | ||
126 | ), | ||
127 | ); | ||
128 | |||
129 | $form->submit($input); | ||
130 | |||
131 | $this->assertDateTimeEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData()); | ||
132 | } | ||
133 | |||
134 | public function testSubmitWithSeconds() | ||
135 | { | ||
136 | $form = $this->factory->create('datetime', null, array( | ||
137 | 'model_timezone' => 'UTC', | ||
138 | 'view_timezone' => 'UTC', | ||
139 | 'date_widget' => 'choice', | ||
140 | 'time_widget' => 'choice', | ||
141 | 'input' => 'datetime', | ||
142 | 'with_seconds' => true, | ||
143 | )); | ||
144 | |||
145 | $form->setData(new \DateTime('2010-06-02 03:04:05 UTC')); | ||
146 | |||
147 | $input = array( | ||
148 | 'date' => array( | ||
149 | 'day' => '2', | ||
150 | 'month' => '6', | ||
151 | 'year' => '2010', | ||
152 | ), | ||
153 | 'time' => array( | ||
154 | 'hour' => '3', | ||
155 | 'minute' => '4', | ||
156 | 'second' => '5', | ||
157 | ), | ||
158 | ); | ||
159 | |||
160 | $form->submit($input); | ||
161 | |||
162 | $this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData()); | ||
163 | } | ||
164 | |||
165 | public function testSubmitDifferentTimezones() | ||
166 | { | ||
167 | $form = $this->factory->create('datetime', null, array( | ||
168 | 'model_timezone' => 'America/New_York', | ||
169 | 'view_timezone' => 'Pacific/Tahiti', | ||
170 | 'date_widget' => 'choice', | ||
171 | 'time_widget' => 'choice', | ||
172 | 'input' => 'string', | ||
173 | 'with_seconds' => true, | ||
174 | )); | ||
175 | |||
176 | $dateTime = new \DateTime('2010-06-02 03:04:05 Pacific/Tahiti'); | ||
177 | |||
178 | $form->submit(array( | ||
179 | 'date' => array( | ||
180 | 'day' => (int) $dateTime->format('d'), | ||
181 | 'month' => (int) $dateTime->format('m'), | ||
182 | 'year' => (int) $dateTime->format('Y'), | ||
183 | ), | ||
184 | 'time' => array( | ||
185 | 'hour' => (int) $dateTime->format('H'), | ||
186 | 'minute' => (int) $dateTime->format('i'), | ||
187 | 'second' => (int) $dateTime->format('s'), | ||
188 | ), | ||
189 | )); | ||
190 | |||
191 | $dateTime->setTimezone(new \DateTimeZone('America/New_York')); | ||
192 | |||
193 | $this->assertEquals($dateTime->format('Y-m-d H:i:s'), $form->getData()); | ||
194 | } | ||
195 | |||
196 | public function testSubmitDifferentTimezonesDateTime() | ||
197 | { | ||
198 | $form = $this->factory->create('datetime', null, array( | ||
199 | 'model_timezone' => 'America/New_York', | ||
200 | 'view_timezone' => 'Pacific/Tahiti', | ||
201 | 'widget' => 'single_text', | ||
202 | 'input' => 'datetime', | ||
203 | )); | ||
204 | |||
205 | $outputTime = new \DateTime('2010-06-02 03:04:00 Pacific/Tahiti'); | ||
206 | |||
207 | $form->submit('2010-06-02T03:04:00-10:00'); | ||
208 | |||
209 | $outputTime->setTimezone(new \DateTimeZone('America/New_York')); | ||
210 | |||
211 | $this->assertDateTimeEquals($outputTime, $form->getData()); | ||
212 | $this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); | ||
213 | } | ||
214 | |||
215 | public function testSubmitStringSingleText() | ||
216 | { | ||
217 | $form = $this->factory->create('datetime', null, array( | ||
218 | 'model_timezone' => 'UTC', | ||
219 | 'view_timezone' => 'UTC', | ||
220 | 'input' => 'string', | ||
221 | 'widget' => 'single_text', | ||
222 | )); | ||
223 | |||
224 | $form->submit('2010-06-02T03:04:00Z'); | ||
225 | |||
226 | $this->assertEquals('2010-06-02 03:04:00', $form->getData()); | ||
227 | $this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData()); | ||
228 | } | ||
229 | |||
230 | public function testSubmitStringSingleTextWithSeconds() | ||
231 | { | ||
232 | $form = $this->factory->create('datetime', null, array( | ||
233 | 'model_timezone' => 'UTC', | ||
234 | 'view_timezone' => 'UTC', | ||
235 | 'input' => 'string', | ||
236 | 'widget' => 'single_text', | ||
237 | 'with_seconds' => true, | ||
238 | )); | ||
239 | |||
240 | $form->submit('2010-06-02T03:04:05Z'); | ||
241 | |||
242 | $this->assertEquals('2010-06-02 03:04:05', $form->getData()); | ||
243 | $this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData()); | ||
244 | } | ||
245 | |||
246 | public function testSubmitDifferentPattern() | ||
247 | { | ||
248 | $form = $this->factory->create('datetime', null, array( | ||
249 | 'date_format' => 'MM*yyyy*dd', | ||
250 | 'date_widget' => 'single_text', | ||
251 | 'time_widget' => 'single_text', | ||
252 | 'input' => 'datetime', | ||
253 | )); | ||
254 | |||
255 | $dateTime = new \DateTime('2010-06-02 03:04'); | ||
256 | |||
257 | $form->submit(array( | ||
258 | 'date' => '06*2010*02', | ||
259 | 'time' => '03:04', | ||
260 | )); | ||
261 | |||
262 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
263 | } | ||
264 | |||
265 | // Bug fix | ||
266 | public function testInitializeWithDateTime() | ||
267 | { | ||
268 | // Throws an exception if "data_class" option is not explicitly set | ||
269 | // to null in the type | ||
270 | $this->factory->create('datetime', new \DateTime()); | ||
271 | } | ||
272 | |||
273 | public function testSingleTextWidgetShouldUseTheRightInputType() | ||
274 | { | ||
275 | $form = $this->factory->create('datetime', null, array( | ||
276 | 'widget' => 'single_text', | ||
277 | )); | ||
278 | |||
279 | $view = $form->createView(); | ||
280 | $this->assertEquals('datetime', $view->vars['type']); | ||
281 | } | ||
282 | |||
283 | public function testPassDefaultEmptyValueToViewIfNotRequired() | ||
284 | { | ||
285 | $form = $this->factory->create('datetime', null, array( | ||
286 | 'required' => false, | ||
287 | 'with_seconds' => true, | ||
288 | )); | ||
289 | |||
290 | $view = $form->createView(); | ||
291 | $this->assertSame('', $view['date']['year']->vars['empty_value']); | ||
292 | $this->assertSame('', $view['date']['month']->vars['empty_value']); | ||
293 | $this->assertSame('', $view['date']['day']->vars['empty_value']); | ||
294 | $this->assertSame('', $view['time']['hour']->vars['empty_value']); | ||
295 | $this->assertSame('', $view['time']['minute']->vars['empty_value']); | ||
296 | $this->assertSame('', $view['time']['second']->vars['empty_value']); | ||
297 | } | ||
298 | |||
299 | public function testPassNoEmptyValueToViewIfRequired() | ||
300 | { | ||
301 | $form = $this->factory->create('datetime', null, array( | ||
302 | 'required' => true, | ||
303 | 'with_seconds' => true, | ||
304 | )); | ||
305 | |||
306 | $view = $form->createView(); | ||
307 | $this->assertNull($view['date']['year']->vars['empty_value']); | ||
308 | $this->assertNull($view['date']['month']->vars['empty_value']); | ||
309 | $this->assertNull($view['date']['day']->vars['empty_value']); | ||
310 | $this->assertNull($view['time']['hour']->vars['empty_value']); | ||
311 | $this->assertNull($view['time']['minute']->vars['empty_value']); | ||
312 | $this->assertNull($view['time']['second']->vars['empty_value']); | ||
313 | } | ||
314 | |||
315 | public function testPassEmptyValueAsString() | ||
316 | { | ||
317 | $form = $this->factory->create('datetime', null, array( | ||
318 | 'empty_value' => 'Empty', | ||
319 | 'with_seconds' => true, | ||
320 | )); | ||
321 | |||
322 | $view = $form->createView(); | ||
323 | $this->assertSame('Empty', $view['date']['year']->vars['empty_value']); | ||
324 | $this->assertSame('Empty', $view['date']['month']->vars['empty_value']); | ||
325 | $this->assertSame('Empty', $view['date']['day']->vars['empty_value']); | ||
326 | $this->assertSame('Empty', $view['time']['hour']->vars['empty_value']); | ||
327 | $this->assertSame('Empty', $view['time']['minute']->vars['empty_value']); | ||
328 | $this->assertSame('Empty', $view['time']['second']->vars['empty_value']); | ||
329 | } | ||
330 | |||
331 | public function testPassEmptyValueAsArray() | ||
332 | { | ||
333 | $form = $this->factory->create('datetime', null, array( | ||
334 | 'empty_value' => array( | ||
335 | 'year' => 'Empty year', | ||
336 | 'month' => 'Empty month', | ||
337 | 'day' => 'Empty day', | ||
338 | 'hour' => 'Empty hour', | ||
339 | 'minute' => 'Empty minute', | ||
340 | 'second' => 'Empty second', | ||
341 | ), | ||
342 | 'with_seconds' => true, | ||
343 | )); | ||
344 | |||
345 | $view = $form->createView(); | ||
346 | $this->assertSame('Empty year', $view['date']['year']->vars['empty_value']); | ||
347 | $this->assertSame('Empty month', $view['date']['month']->vars['empty_value']); | ||
348 | $this->assertSame('Empty day', $view['date']['day']->vars['empty_value']); | ||
349 | $this->assertSame('Empty hour', $view['time']['hour']->vars['empty_value']); | ||
350 | $this->assertSame('Empty minute', $view['time']['minute']->vars['empty_value']); | ||
351 | $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); | ||
352 | } | ||
353 | |||
354 | public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() | ||
355 | { | ||
356 | $form = $this->factory->create('datetime', null, array( | ||
357 | 'required' => false, | ||
358 | 'empty_value' => array( | ||
359 | 'year' => 'Empty year', | ||
360 | 'day' => 'Empty day', | ||
361 | 'hour' => 'Empty hour', | ||
362 | 'second' => 'Empty second', | ||
363 | ), | ||
364 | 'with_seconds' => true, | ||
365 | )); | ||
366 | |||
367 | $view = $form->createView(); | ||
368 | $this->assertSame('Empty year', $view['date']['year']->vars['empty_value']); | ||
369 | $this->assertSame('', $view['date']['month']->vars['empty_value']); | ||
370 | $this->assertSame('Empty day', $view['date']['day']->vars['empty_value']); | ||
371 | $this->assertSame('Empty hour', $view['time']['hour']->vars['empty_value']); | ||
372 | $this->assertSame('', $view['time']['minute']->vars['empty_value']); | ||
373 | $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); | ||
374 | } | ||
375 | |||
376 | public function testPassEmptyValueAsPartialArrayAddNullIfRequired() | ||
377 | { | ||
378 | $form = $this->factory->create('datetime', null, array( | ||
379 | 'required' => true, | ||
380 | 'empty_value' => array( | ||
381 | 'year' => 'Empty year', | ||
382 | 'day' => 'Empty day', | ||
383 | 'hour' => 'Empty hour', | ||
384 | 'second' => 'Empty second', | ||
385 | ), | ||
386 | 'with_seconds' => true, | ||
387 | )); | ||
388 | |||
389 | $view = $form->createView(); | ||
390 | $this->assertSame('Empty year', $view['date']['year']->vars['empty_value']); | ||
391 | $this->assertNull($view['date']['month']->vars['empty_value']); | ||
392 | $this->assertSame('Empty day', $view['date']['day']->vars['empty_value']); | ||
393 | $this->assertSame('Empty hour', $view['time']['hour']->vars['empty_value']); | ||
394 | $this->assertNull($view['time']['minute']->vars['empty_value']); | ||
395 | $this->assertSame('Empty second', $view['time']['second']->vars['empty_value']); | ||
396 | } | ||
397 | |||
398 | public function testPassHtml5TypeIfSingleTextAndHtml5Format() | ||
399 | { | ||
400 | $form = $this->factory->create('datetime', null, array( | ||
401 | 'widget' => 'single_text', | ||
402 | )); | ||
403 | |||
404 | $view = $form->createView(); | ||
405 | $this->assertSame('datetime', $view->vars['type']); | ||
406 | } | ||
407 | |||
408 | public function testDontPassHtml5TypeIfNotHtml5Format() | ||
409 | { | ||
410 | $form = $this->factory->create('datetime', null, array( | ||
411 | 'widget' => 'single_text', | ||
412 | 'format' => 'yyyy-MM-dd HH:mm', | ||
413 | )); | ||
414 | |||
415 | $view = $form->createView(); | ||
416 | $this->assertFalse(isset($view->vars['type'])); | ||
417 | } | ||
418 | |||
419 | public function testDontPassHtml5TypeIfNotSingleText() | ||
420 | { | ||
421 | $form = $this->factory->create('datetime', null, array( | ||
422 | 'widget' => 'text', | ||
423 | )); | ||
424 | |||
425 | $view = $form->createView(); | ||
426 | $this->assertFalse(isset($view->vars['type'])); | ||
427 | } | ||
428 | |||
429 | public function testDateTypeChoiceErrorsBubbleUp() | ||
430 | { | ||
431 | $error = new FormError('Invalid!'); | ||
432 | $form = $this->factory->create('datetime', null); | ||
433 | |||
434 | $form['date']->addError($error); | ||
435 | |||
436 | $this->assertSame(array(), $form['date']->getErrors()); | ||
437 | $this->assertSame(array($error), $form->getErrors()); | ||
438 | } | ||
439 | |||
440 | public function testDateTypeSingleTextErrorsBubbleUp() | ||
441 | { | ||
442 | $error = new FormError('Invalid!'); | ||
443 | $form = $this->factory->create('datetime', null, array( | ||
444 | 'date_widget' => 'single_text' | ||
445 | )); | ||
446 | |||
447 | $form['date']->addError($error); | ||
448 | |||
449 | $this->assertSame(array(), $form['date']->getErrors()); | ||
450 | $this->assertSame(array($error), $form->getErrors()); | ||
451 | } | ||
452 | |||
453 | public function testTimeTypeChoiceErrorsBubbleUp() | ||
454 | { | ||
455 | $error = new FormError('Invalid!'); | ||
456 | $form = $this->factory->create('datetime', null); | ||
457 | |||
458 | $form['time']->addError($error); | ||
459 | |||
460 | $this->assertSame(array(), $form['time']->getErrors()); | ||
461 | $this->assertSame(array($error), $form->getErrors()); | ||
462 | } | ||
463 | |||
464 | public function testTimeTypeSingleTextErrorsBubbleUp() | ||
465 | { | ||
466 | $error = new FormError('Invalid!'); | ||
467 | $form = $this->factory->create('datetime', null, array( | ||
468 | 'time_widget' => 'single_text' | ||
469 | )); | ||
470 | |||
471 | $form['time']->addError($error); | ||
472 | |||
473 | $this->assertSame(array(), $form['time']->getErrors()); | ||
474 | $this->assertSame(array($error), $form->getErrors()); | ||
475 | } | ||
476 | |||
477 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php deleted file mode 100644 index 2aa155e7..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ /dev/null | |||
@@ -1,781 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Form\FormError; | ||
16 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
17 | |||
18 | class DateTypeTest extends TypeTestCase | ||
19 | { | ||
20 | protected function setUp() | ||
21 | { | ||
22 | parent::setUp(); | ||
23 | |||
24 | // we test against "de_AT", so we need the full implementation | ||
25 | IntlTestHelper::requireFullIntl($this); | ||
26 | |||
27 | \Locale::setDefault('de_AT'); | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
32 | */ | ||
33 | public function testInvalidWidgetOption() | ||
34 | { | ||
35 | $this->factory->create('date', null, array( | ||
36 | 'widget' => 'fake_widget', | ||
37 | )); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
42 | */ | ||
43 | public function testInvalidInputOption() | ||
44 | { | ||
45 | $this->factory->create('date', null, array( | ||
46 | 'input' => 'fake_input', | ||
47 | )); | ||
48 | } | ||
49 | |||
50 | public function testSubmitFromSingleTextDateTimeWithDefaultFormat() | ||
51 | { | ||
52 | $form = $this->factory->create('date', null, array( | ||
53 | 'model_timezone' => 'UTC', | ||
54 | 'view_timezone' => 'UTC', | ||
55 | 'widget' => 'single_text', | ||
56 | 'input' => 'datetime', | ||
57 | )); | ||
58 | |||
59 | $form->submit('2010-06-02'); | ||
60 | |||
61 | $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); | ||
62 | $this->assertEquals('2010-06-02', $form->getViewData()); | ||
63 | } | ||
64 | |||
65 | public function testSubmitFromSingleTextDateTime() | ||
66 | { | ||
67 | $form = $this->factory->create('date', null, array( | ||
68 | 'format' => \IntlDateFormatter::MEDIUM, | ||
69 | 'model_timezone' => 'UTC', | ||
70 | 'view_timezone' => 'UTC', | ||
71 | 'widget' => 'single_text', | ||
72 | 'input' => 'datetime', | ||
73 | )); | ||
74 | |||
75 | $form->submit('2.6.2010'); | ||
76 | |||
77 | $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); | ||
78 | $this->assertEquals('02.06.2010', $form->getViewData()); | ||
79 | } | ||
80 | |||
81 | public function testSubmitFromSingleTextString() | ||
82 | { | ||
83 | $form = $this->factory->create('date', null, array( | ||
84 | 'format' => \IntlDateFormatter::MEDIUM, | ||
85 | 'model_timezone' => 'UTC', | ||
86 | 'view_timezone' => 'UTC', | ||
87 | 'widget' => 'single_text', | ||
88 | 'input' => 'string', | ||
89 | )); | ||
90 | |||
91 | $form->submit('2.6.2010'); | ||
92 | |||
93 | $this->assertEquals('2010-06-02', $form->getData()); | ||
94 | $this->assertEquals('02.06.2010', $form->getViewData()); | ||
95 | } | ||
96 | |||
97 | public function testSubmitFromSingleTextTimestamp() | ||
98 | { | ||
99 | $form = $this->factory->create('date', null, array( | ||
100 | 'format' => \IntlDateFormatter::MEDIUM, | ||
101 | 'model_timezone' => 'UTC', | ||
102 | 'view_timezone' => 'UTC', | ||
103 | 'widget' => 'single_text', | ||
104 | 'input' => 'timestamp', | ||
105 | )); | ||
106 | |||
107 | $form->submit('2.6.2010'); | ||
108 | |||
109 | $dateTime = new \DateTime('2010-06-02 UTC'); | ||
110 | |||
111 | $this->assertEquals($dateTime->format('U'), $form->getData()); | ||
112 | $this->assertEquals('02.06.2010', $form->getViewData()); | ||
113 | } | ||
114 | |||
115 | public function testSubmitFromSingleTextRaw() | ||
116 | { | ||
117 | $form = $this->factory->create('date', null, array( | ||
118 | 'format' => \IntlDateFormatter::MEDIUM, | ||
119 | 'model_timezone' => 'UTC', | ||
120 | 'view_timezone' => 'UTC', | ||
121 | 'widget' => 'single_text', | ||
122 | 'input' => 'array', | ||
123 | )); | ||
124 | |||
125 | $form->submit('2.6.2010'); | ||
126 | |||
127 | $output = array( | ||
128 | 'day' => '2', | ||
129 | 'month' => '6', | ||
130 | 'year' => '2010', | ||
131 | ); | ||
132 | |||
133 | $this->assertEquals($output, $form->getData()); | ||
134 | $this->assertEquals('02.06.2010', $form->getViewData()); | ||
135 | } | ||
136 | |||
137 | public function testSubmitFromText() | ||
138 | { | ||
139 | $form = $this->factory->create('date', null, array( | ||
140 | 'model_timezone' => 'UTC', | ||
141 | 'view_timezone' => 'UTC', | ||
142 | 'widget' => 'text', | ||
143 | )); | ||
144 | |||
145 | $text = array( | ||
146 | 'day' => '2', | ||
147 | 'month' => '6', | ||
148 | 'year' => '2010', | ||
149 | ); | ||
150 | |||
151 | $form->submit($text); | ||
152 | |||
153 | $dateTime = new \DateTime('2010-06-02 UTC'); | ||
154 | |||
155 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
156 | $this->assertEquals($text, $form->getViewData()); | ||
157 | } | ||
158 | |||
159 | public function testSubmitFromChoice() | ||
160 | { | ||
161 | $form = $this->factory->create('date', null, array( | ||
162 | 'model_timezone' => 'UTC', | ||
163 | 'view_timezone' => 'UTC', | ||
164 | 'widget' => 'choice', | ||
165 | )); | ||
166 | |||
167 | $text = array( | ||
168 | 'day' => '2', | ||
169 | 'month' => '6', | ||
170 | 'year' => '2010', | ||
171 | ); | ||
172 | |||
173 | $form->submit($text); | ||
174 | |||
175 | $dateTime = new \DateTime('2010-06-02 UTC'); | ||
176 | |||
177 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
178 | $this->assertEquals($text, $form->getViewData()); | ||
179 | } | ||
180 | |||
181 | public function testSubmitFromChoiceEmpty() | ||
182 | { | ||
183 | $form = $this->factory->create('date', null, array( | ||
184 | 'model_timezone' => 'UTC', | ||
185 | 'view_timezone' => 'UTC', | ||
186 | 'widget' => 'choice', | ||
187 | 'required' => false, | ||
188 | )); | ||
189 | |||
190 | $text = array( | ||
191 | 'day' => '', | ||
192 | 'month' => '', | ||
193 | 'year' => '', | ||
194 | ); | ||
195 | |||
196 | $form->submit($text); | ||
197 | |||
198 | $this->assertNull($form->getData()); | ||
199 | $this->assertEquals($text, $form->getViewData()); | ||
200 | } | ||
201 | |||
202 | public function testSubmitFromInputDateTimeDifferentPattern() | ||
203 | { | ||
204 | $form = $this->factory->create('date', null, array( | ||
205 | 'model_timezone' => 'UTC', | ||
206 | 'view_timezone' => 'UTC', | ||
207 | 'format' => 'MM*yyyy*dd', | ||
208 | 'widget' => 'single_text', | ||
209 | 'input' => 'datetime', | ||
210 | )); | ||
211 | |||
212 | $form->submit('06*2010*02'); | ||
213 | |||
214 | $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); | ||
215 | $this->assertEquals('06*2010*02', $form->getViewData()); | ||
216 | } | ||
217 | |||
218 | public function testSubmitFromInputStringDifferentPattern() | ||
219 | { | ||
220 | $form = $this->factory->create('date', null, array( | ||
221 | 'model_timezone' => 'UTC', | ||
222 | 'view_timezone' => 'UTC', | ||
223 | 'format' => 'MM*yyyy*dd', | ||
224 | 'widget' => 'single_text', | ||
225 | 'input' => 'string', | ||
226 | )); | ||
227 | |||
228 | $form->submit('06*2010*02'); | ||
229 | |||
230 | $this->assertEquals('2010-06-02', $form->getData()); | ||
231 | $this->assertEquals('06*2010*02', $form->getViewData()); | ||
232 | } | ||
233 | |||
234 | public function testSubmitFromInputTimestampDifferentPattern() | ||
235 | { | ||
236 | $form = $this->factory->create('date', null, array( | ||
237 | 'model_timezone' => 'UTC', | ||
238 | 'view_timezone' => 'UTC', | ||
239 | 'format' => 'MM*yyyy*dd', | ||
240 | 'widget' => 'single_text', | ||
241 | 'input' => 'timestamp', | ||
242 | )); | ||
243 | |||
244 | $form->submit('06*2010*02'); | ||
245 | |||
246 | $dateTime = new \DateTime('2010-06-02 UTC'); | ||
247 | |||
248 | $this->assertEquals($dateTime->format('U'), $form->getData()); | ||
249 | $this->assertEquals('06*2010*02', $form->getViewData()); | ||
250 | } | ||
251 | |||
252 | public function testSubmitFromInputRawDifferentPattern() | ||
253 | { | ||
254 | $form = $this->factory->create('date', null, array( | ||
255 | 'model_timezone' => 'UTC', | ||
256 | 'view_timezone' => 'UTC', | ||
257 | 'format' => 'MM*yyyy*dd', | ||
258 | 'widget' => 'single_text', | ||
259 | 'input' => 'array', | ||
260 | )); | ||
261 | |||
262 | $form->submit('06*2010*02'); | ||
263 | |||
264 | $output = array( | ||
265 | 'day' => '2', | ||
266 | 'month' => '6', | ||
267 | 'year' => '2010', | ||
268 | ); | ||
269 | |||
270 | $this->assertEquals($output, $form->getData()); | ||
271 | $this->assertEquals('06*2010*02', $form->getViewData()); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * @dataProvider provideDateFormats | ||
276 | */ | ||
277 | public function testDatePatternWithFormatOption($format, $pattern) | ||
278 | { | ||
279 | $form = $this->factory->create('date', null, array( | ||
280 | 'format' => $format, | ||
281 | )); | ||
282 | |||
283 | $view = $form->createView(); | ||
284 | |||
285 | $this->assertEquals($pattern, $view->vars['date_pattern']); | ||
286 | } | ||
287 | |||
288 | public function provideDateFormats() | ||
289 | { | ||
290 | return array( | ||
291 | array('dMy', '{{ day }}{{ month }}{{ year }}'), | ||
292 | array('d-M-yyyy', '{{ day }}-{{ month }}-{{ year }}'), | ||
293 | array('M d y', '{{ month }} {{ day }} {{ year }}'), | ||
294 | ); | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * This test is to check that the strings '0', '1', '2', '3' are no accepted | ||
299 | * as valid IntlDateFormatter constants for FULL, LONG, MEDIUM or SHORT respectively. | ||
300 | * | ||
301 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
302 | */ | ||
303 | public function testThrowExceptionIfFormatIsNoPattern() | ||
304 | { | ||
305 | $this->factory->create('date', null, array( | ||
306 | 'format' => '0', | ||
307 | 'widget' => 'single_text', | ||
308 | 'input' => 'string', | ||
309 | )); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
314 | */ | ||
315 | public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay() | ||
316 | { | ||
317 | $this->factory->create('date', null, array( | ||
318 | 'months' => array(6, 7), | ||
319 | 'format' => 'yy', | ||
320 | )); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
325 | */ | ||
326 | public function testThrowExceptionIfFormatIsNoConstant() | ||
327 | { | ||
328 | $this->factory->create('date', null, array( | ||
329 | 'format' => 105, | ||
330 | )); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
335 | */ | ||
336 | public function testThrowExceptionIfFormatIsInvalid() | ||
337 | { | ||
338 | $this->factory->create('date', null, array( | ||
339 | 'format' => array(), | ||
340 | )); | ||
341 | } | ||
342 | |||
343 | public function testSetDataWithDifferentTimezones() | ||
344 | { | ||
345 | $form = $this->factory->create('date', null, array( | ||
346 | 'format' => \IntlDateFormatter::MEDIUM, | ||
347 | 'model_timezone' => 'America/New_York', | ||
348 | 'view_timezone' => 'Pacific/Tahiti', | ||
349 | 'input' => 'string', | ||
350 | 'widget' => 'single_text', | ||
351 | )); | ||
352 | |||
353 | $form->setData('2010-06-02'); | ||
354 | |||
355 | $this->assertEquals('01.06.2010', $form->getViewData()); | ||
356 | } | ||
357 | |||
358 | public function testSetDataWithDifferentTimezonesDateTime() | ||
359 | { | ||
360 | $form = $this->factory->create('date', null, array( | ||
361 | 'format' => \IntlDateFormatter::MEDIUM, | ||
362 | 'model_timezone' => 'America/New_York', | ||
363 | 'view_timezone' => 'Pacific/Tahiti', | ||
364 | 'input' => 'datetime', | ||
365 | 'widget' => 'single_text', | ||
366 | )); | ||
367 | |||
368 | $dateTime = new \DateTime('2010-06-02 America/New_York'); | ||
369 | |||
370 | $form->setData($dateTime); | ||
371 | |||
372 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
373 | $this->assertEquals('01.06.2010', $form->getViewData()); | ||
374 | } | ||
375 | |||
376 | public function testYearsOption() | ||
377 | { | ||
378 | $form = $this->factory->create('date', null, array( | ||
379 | 'years' => array(2010, 2011), | ||
380 | )); | ||
381 | |||
382 | $view = $form->createView(); | ||
383 | |||
384 | $this->assertEquals(array( | ||
385 | new ChoiceView('2010', '2010', '2010'), | ||
386 | new ChoiceView('2011', '2011', '2011'), | ||
387 | ), $view['year']->vars['choices']); | ||
388 | } | ||
389 | |||
390 | public function testMonthsOption() | ||
391 | { | ||
392 | $form = $this->factory->create('date', null, array( | ||
393 | 'months' => array(6, 7), | ||
394 | )); | ||
395 | |||
396 | $view = $form->createView(); | ||
397 | |||
398 | $this->assertEquals(array( | ||
399 | new ChoiceView('6', '6', '06'), | ||
400 | new ChoiceView('7', '7', '07'), | ||
401 | ), $view['month']->vars['choices']); | ||
402 | } | ||
403 | |||
404 | public function testMonthsOptionShortFormat() | ||
405 | { | ||
406 | $form = $this->factory->create('date', null, array( | ||
407 | 'months' => array(1, 4), | ||
408 | 'format' => 'dd.MMM.yy', | ||
409 | )); | ||
410 | |||
411 | $view = $form->createView(); | ||
412 | |||
413 | $this->assertEquals(array( | ||
414 | new ChoiceView('1', '1', 'Jän'), | ||
415 | new ChoiceView('4', '4', 'Apr.') | ||
416 | ), $view['month']->vars['choices']); | ||
417 | } | ||
418 | |||
419 | public function testMonthsOptionLongFormat() | ||
420 | { | ||
421 | $form = $this->factory->create('date', null, array( | ||
422 | 'months' => array(1, 4), | ||
423 | 'format' => 'dd.MMMM.yy', | ||
424 | )); | ||
425 | |||
426 | $view = $form->createView(); | ||
427 | |||
428 | $this->assertEquals(array( | ||
429 | new ChoiceView('1', '1', 'Jänner'), | ||
430 | new ChoiceView('4', '4', 'April'), | ||
431 | ), $view['month']->vars['choices']); | ||
432 | } | ||
433 | |||
434 | public function testMonthsOptionLongFormatWithDifferentTimezone() | ||
435 | { | ||
436 | $form = $this->factory->create('date', null, array( | ||
437 | 'months' => array(1, 4), | ||
438 | 'format' => 'dd.MMMM.yy', | ||
439 | )); | ||
440 | |||
441 | $view = $form->createView(); | ||
442 | |||
443 | $this->assertEquals(array( | ||
444 | new ChoiceView('1', '1', 'Jänner'), | ||
445 | new ChoiceView('4', '4', 'April'), | ||
446 | ), $view['month']->vars['choices']); | ||
447 | } | ||
448 | |||
449 | public function testIsDayWithinRangeReturnsTrueIfWithin() | ||
450 | { | ||
451 | $form = $this->factory->create('date', null, array( | ||
452 | 'days' => array(6, 7), | ||
453 | )); | ||
454 | |||
455 | $view = $form->createView(); | ||
456 | |||
457 | $this->assertEquals(array( | ||
458 | new ChoiceView('6', '6', '06'), | ||
459 | new ChoiceView('7', '7', '07'), | ||
460 | ), $view['day']->vars['choices']); | ||
461 | } | ||
462 | |||
463 | public function testIsPartiallyFilledReturnsFalseIfSingleText() | ||
464 | { | ||
465 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
466 | |||
467 | $form = $this->factory->create('date', null, array( | ||
468 | 'model_timezone' => 'UTC', | ||
469 | 'view_timezone' => 'UTC', | ||
470 | 'widget' => 'single_text', | ||
471 | )); | ||
472 | |||
473 | $form->submit('7.6.2010'); | ||
474 | |||
475 | $this->assertFalse($form->isPartiallyFilled()); | ||
476 | } | ||
477 | |||
478 | public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty() | ||
479 | { | ||
480 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
481 | |||
482 | $form = $this->factory->create('date', null, array( | ||
483 | 'model_timezone' => 'UTC', | ||
484 | 'view_timezone' => 'UTC', | ||
485 | 'widget' => 'choice', | ||
486 | )); | ||
487 | |||
488 | $form->submit(array( | ||
489 | 'day' => '', | ||
490 | 'month' => '', | ||
491 | 'year' => '', | ||
492 | )); | ||
493 | |||
494 | $this->assertFalse($form->isPartiallyFilled()); | ||
495 | } | ||
496 | |||
497 | public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled() | ||
498 | { | ||
499 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
500 | |||
501 | $form = $this->factory->create('date', null, array( | ||
502 | 'model_timezone' => 'UTC', | ||
503 | 'view_timezone' => 'UTC', | ||
504 | 'widget' => 'choice', | ||
505 | )); | ||
506 | |||
507 | $form->submit(array( | ||
508 | 'day' => '2', | ||
509 | 'month' => '6', | ||
510 | 'year' => '2010', | ||
511 | )); | ||
512 | |||
513 | $this->assertFalse($form->isPartiallyFilled()); | ||
514 | } | ||
515 | |||
516 | public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty() | ||
517 | { | ||
518 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
519 | |||
520 | $form = $this->factory->create('date', null, array( | ||
521 | 'model_timezone' => 'UTC', | ||
522 | 'view_timezone' => 'UTC', | ||
523 | 'widget' => 'choice', | ||
524 | )); | ||
525 | |||
526 | $form->submit(array( | ||
527 | 'day' => '', | ||
528 | 'month' => '6', | ||
529 | 'year' => '2010', | ||
530 | )); | ||
531 | |||
532 | $this->assertTrue($form->isPartiallyFilled()); | ||
533 | } | ||
534 | |||
535 | public function testPassDatePatternToView() | ||
536 | { | ||
537 | $form = $this->factory->create('date'); | ||
538 | $view = $form->createView(); | ||
539 | |||
540 | $this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); | ||
541 | } | ||
542 | |||
543 | public function testPassDatePatternToViewDifferentFormat() | ||
544 | { | ||
545 | $form = $this->factory->create('date', null, array( | ||
546 | 'format' => \IntlDateFormatter::LONG, | ||
547 | )); | ||
548 | |||
549 | $view = $form->createView(); | ||
550 | |||
551 | $this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); | ||
552 | } | ||
553 | |||
554 | public function testPassDatePatternToViewDifferentPattern() | ||
555 | { | ||
556 | $form = $this->factory->create('date', null, array( | ||
557 | 'format' => 'MMyyyydd' | ||
558 | )); | ||
559 | |||
560 | $view = $form->createView(); | ||
561 | |||
562 | $this->assertSame('{{ month }}{{ year }}{{ day }}', $view->vars['date_pattern']); | ||
563 | } | ||
564 | |||
565 | public function testPassDatePatternToViewDifferentPatternWithSeparators() | ||
566 | { | ||
567 | $form = $this->factory->create('date', null, array( | ||
568 | 'format' => 'MM*yyyy*dd' | ||
569 | )); | ||
570 | |||
571 | $view = $form->createView(); | ||
572 | |||
573 | $this->assertSame('{{ month }}*{{ year }}*{{ day }}', $view->vars['date_pattern']); | ||
574 | } | ||
575 | |||
576 | public function testDontPassDatePatternIfText() | ||
577 | { | ||
578 | $form = $this->factory->create('date', null, array( | ||
579 | 'widget' => 'single_text', | ||
580 | )); | ||
581 | $view = $form->createView(); | ||
582 | |||
583 | $this->assertFalse(isset($view->vars['date_pattern'])); | ||
584 | } | ||
585 | |||
586 | public function testPassWidgetToView() | ||
587 | { | ||
588 | $form = $this->factory->create('date', null, array( | ||
589 | 'widget' => 'single_text', | ||
590 | )); | ||
591 | $view = $form->createView(); | ||
592 | |||
593 | $this->assertSame('single_text', $view->vars['widget']); | ||
594 | } | ||
595 | |||
596 | // Bug fix | ||
597 | public function testInitializeWithDateTime() | ||
598 | { | ||
599 | // Throws an exception if "data_class" option is not explicitly set | ||
600 | // to null in the type | ||
601 | $this->factory->create('date', new \DateTime()); | ||
602 | } | ||
603 | |||
604 | public function testSingleTextWidgetShouldUseTheRightInputType() | ||
605 | { | ||
606 | $form = $this->factory->create('date', null, array( | ||
607 | 'widget' => 'single_text', | ||
608 | )); | ||
609 | |||
610 | $view = $form->createView(); | ||
611 | $this->assertEquals('date', $view->vars['type']); | ||
612 | } | ||
613 | |||
614 | public function testPassDefaultEmptyValueToViewIfNotRequired() | ||
615 | { | ||
616 | $form = $this->factory->create('date', null, array( | ||
617 | 'required' => false, | ||
618 | )); | ||
619 | |||
620 | $view = $form->createView(); | ||
621 | $this->assertSame('', $view['year']->vars['empty_value']); | ||
622 | $this->assertSame('', $view['month']->vars['empty_value']); | ||
623 | $this->assertSame('', $view['day']->vars['empty_value']); | ||
624 | } | ||
625 | |||
626 | public function testPassNoEmptyValueToViewIfRequired() | ||
627 | { | ||
628 | $form = $this->factory->create('date', null, array( | ||
629 | 'required' => true, | ||
630 | )); | ||
631 | |||
632 | $view = $form->createView(); | ||
633 | $this->assertNull($view['year']->vars['empty_value']); | ||
634 | $this->assertNull($view['month']->vars['empty_value']); | ||
635 | $this->assertNull($view['day']->vars['empty_value']); | ||
636 | } | ||
637 | |||
638 | public function testPassEmptyValueAsString() | ||
639 | { | ||
640 | $form = $this->factory->create('date', null, array( | ||
641 | 'empty_value' => 'Empty', | ||
642 | )); | ||
643 | |||
644 | $view = $form->createView(); | ||
645 | $this->assertSame('Empty', $view['year']->vars['empty_value']); | ||
646 | $this->assertSame('Empty', $view['month']->vars['empty_value']); | ||
647 | $this->assertSame('Empty', $view['day']->vars['empty_value']); | ||
648 | } | ||
649 | |||
650 | public function testPassEmptyValueAsArray() | ||
651 | { | ||
652 | $form = $this->factory->create('date', null, array( | ||
653 | 'empty_value' => array( | ||
654 | 'year' => 'Empty year', | ||
655 | 'month' => 'Empty month', | ||
656 | 'day' => 'Empty day', | ||
657 | ), | ||
658 | )); | ||
659 | |||
660 | $view = $form->createView(); | ||
661 | $this->assertSame('Empty year', $view['year']->vars['empty_value']); | ||
662 | $this->assertSame('Empty month', $view['month']->vars['empty_value']); | ||
663 | $this->assertSame('Empty day', $view['day']->vars['empty_value']); | ||
664 | } | ||
665 | |||
666 | public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() | ||
667 | { | ||
668 | $form = $this->factory->create('date', null, array( | ||
669 | 'required' => false, | ||
670 | 'empty_value' => array( | ||
671 | 'year' => 'Empty year', | ||
672 | 'day' => 'Empty day', | ||
673 | ), | ||
674 | )); | ||
675 | |||
676 | $view = $form->createView(); | ||
677 | $this->assertSame('Empty year', $view['year']->vars['empty_value']); | ||
678 | $this->assertSame('', $view['month']->vars['empty_value']); | ||
679 | $this->assertSame('Empty day', $view['day']->vars['empty_value']); | ||
680 | } | ||
681 | |||
682 | public function testPassEmptyValueAsPartialArrayAddNullIfRequired() | ||
683 | { | ||
684 | $form = $this->factory->create('date', null, array( | ||
685 | 'required' => true, | ||
686 | 'empty_value' => array( | ||
687 | 'year' => 'Empty year', | ||
688 | 'day' => 'Empty day', | ||
689 | ), | ||
690 | )); | ||
691 | |||
692 | $view = $form->createView(); | ||
693 | $this->assertSame('Empty year', $view['year']->vars['empty_value']); | ||
694 | $this->assertNull($view['month']->vars['empty_value']); | ||
695 | $this->assertSame('Empty day', $view['day']->vars['empty_value']); | ||
696 | } | ||
697 | |||
698 | public function testPassHtml5TypeIfSingleTextAndHtml5Format() | ||
699 | { | ||
700 | $form = $this->factory->create('date', null, array( | ||
701 | 'widget' => 'single_text', | ||
702 | )); | ||
703 | |||
704 | $view = $form->createView(); | ||
705 | $this->assertSame('date', $view->vars['type']); | ||
706 | } | ||
707 | |||
708 | public function testDontPassHtml5TypeIfNotHtml5Format() | ||
709 | { | ||
710 | $form = $this->factory->create('date', null, array( | ||
711 | 'widget' => 'single_text', | ||
712 | 'format' => \IntlDateFormatter::MEDIUM, | ||
713 | )); | ||
714 | |||
715 | $view = $form->createView(); | ||
716 | $this->assertFalse(isset($view->vars['type'])); | ||
717 | } | ||
718 | |||
719 | public function testDontPassHtml5TypeIfNotSingleText() | ||
720 | { | ||
721 | $form = $this->factory->create('date', null, array( | ||
722 | 'widget' => 'text', | ||
723 | )); | ||
724 | |||
725 | $view = $form->createView(); | ||
726 | $this->assertFalse(isset($view->vars['type'])); | ||
727 | } | ||
728 | |||
729 | public function provideCompoundWidgets() | ||
730 | { | ||
731 | return array( | ||
732 | array('text'), | ||
733 | array('choice'), | ||
734 | ); | ||
735 | } | ||
736 | |||
737 | /** | ||
738 | * @dataProvider provideCompoundWidgets | ||
739 | */ | ||
740 | public function testYearErrorsBubbleUp($widget) | ||
741 | { | ||
742 | $error = new FormError('Invalid!'); | ||
743 | $form = $this->factory->create('date', null, array( | ||
744 | 'widget' => $widget, | ||
745 | )); | ||
746 | $form['year']->addError($error); | ||
747 | |||
748 | $this->assertSame(array(), $form['year']->getErrors()); | ||
749 | $this->assertSame(array($error), $form->getErrors()); | ||
750 | } | ||
751 | |||
752 | /** | ||
753 | * @dataProvider provideCompoundWidgets | ||
754 | */ | ||
755 | public function testMonthErrorsBubbleUp($widget) | ||
756 | { | ||
757 | $error = new FormError('Invalid!'); | ||
758 | $form = $this->factory->create('date', null, array( | ||
759 | 'widget' => $widget, | ||
760 | )); | ||
761 | $form['month']->addError($error); | ||
762 | |||
763 | $this->assertSame(array(), $form['month']->getErrors()); | ||
764 | $this->assertSame(array($error), $form->getErrors()); | ||
765 | } | ||
766 | |||
767 | /** | ||
768 | * @dataProvider provideCompoundWidgets | ||
769 | */ | ||
770 | public function testDayErrorsBubbleUp($widget) | ||
771 | { | ||
772 | $error = new FormError('Invalid!'); | ||
773 | $form = $this->factory->create('date', null, array( | ||
774 | 'widget' => $widget, | ||
775 | )); | ||
776 | $form['day']->addError($error); | ||
777 | |||
778 | $this->assertSame(array(), $form['day']->getErrors()); | ||
779 | $this->assertSame(array($error), $form->getErrors()); | ||
780 | } | ||
781 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php deleted file mode 100644 index 63556eb5..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
15 | { | ||
16 | // https://github.com/symfony/symfony/pull/5028 | ||
17 | public function testSetData() | ||
18 | { | ||
19 | $form = $this->factory->createBuilder('file')->getForm(); | ||
20 | $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); | ||
21 | |||
22 | $form->setData($data); | ||
23 | |||
24 | $this->assertSame($data, $form->getData()); | ||
25 | } | ||
26 | |||
27 | public function testSubmit() | ||
28 | { | ||
29 | $form = $this->factory->createBuilder('file')->getForm(); | ||
30 | $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); | ||
31 | |||
32 | $form->submit($data); | ||
33 | |||
34 | $this->assertSame($data, $form->getData()); | ||
35 | } | ||
36 | |||
37 | // https://github.com/symfony/symfony/issues/6134 | ||
38 | public function testSubmitEmpty() | ||
39 | { | ||
40 | $form = $this->factory->createBuilder('file')->getForm(); | ||
41 | |||
42 | $form->submit(null); | ||
43 | |||
44 | $this->assertNull($form->getData()); | ||
45 | } | ||
46 | |||
47 | public function testDontPassValueToView() | ||
48 | { | ||
49 | $form = $this->factory->create('file'); | ||
50 | $form->submit(array( | ||
51 | 'file' => $this->createUploadedFileMock('abcdef', 'original.jpg', true), | ||
52 | )); | ||
53 | $view = $form->createView(); | ||
54 | |||
55 | $this->assertEquals('', $view->vars['value']); | ||
56 | } | ||
57 | |||
58 | private function createUploadedFileMock($name, $originalName, $valid) | ||
59 | { | ||
60 | $file = $this | ||
61 | ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') | ||
62 | ->disableOriginalConstructor() | ||
63 | ->getMock() | ||
64 | ; | ||
65 | $file | ||
66 | ->expects($this->any()) | ||
67 | ->method('getBasename') | ||
68 | ->will($this->returnValue($name)) | ||
69 | ; | ||
70 | $file | ||
71 | ->expects($this->any()) | ||
72 | ->method('getClientOriginalName') | ||
73 | ->will($this->returnValue($originalName)) | ||
74 | ; | ||
75 | $file | ||
76 | ->expects($this->any()) | ||
77 | ->method('isValid') | ||
78 | ->will($this->returnValue($valid)) | ||
79 | ; | ||
80 | |||
81 | return $file; | ||
82 | } | ||
83 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php deleted file mode 100644 index cced82f4..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ /dev/null | |||
@@ -1,578 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\PropertyAccess\PropertyPath; | ||
15 | use Symfony\Component\Form\Form; | ||
16 | use Symfony\Component\Form\CallbackTransformer; | ||
17 | use Symfony\Component\Form\Tests\Fixtures\Author; | ||
18 | use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; | ||
19 | use Symfony\Component\Form\FormError; | ||
20 | |||
21 | class FormTest_AuthorWithoutRefSetter | ||
22 | { | ||
23 | protected $reference; | ||
24 | |||
25 | protected $referenceCopy; | ||
26 | |||
27 | public function __construct($reference) | ||
28 | { | ||
29 | $this->reference = $reference; | ||
30 | $this->referenceCopy = $reference; | ||
31 | } | ||
32 | |||
33 | // The returned object should be modified by reference without having | ||
34 | // to provide a setReference() method | ||
35 | public function getReference() | ||
36 | { | ||
37 | return $this->reference; | ||
38 | } | ||
39 | |||
40 | // The returned object is a copy, so setReferenceCopy() must be used | ||
41 | // to update it | ||
42 | public function getReferenceCopy() | ||
43 | { | ||
44 | return is_object($this->referenceCopy) ? clone $this->referenceCopy : $this->referenceCopy; | ||
45 | } | ||
46 | |||
47 | public function setReferenceCopy($reference) | ||
48 | { | ||
49 | $this->referenceCopy = $reference; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | class FormTypeTest extends BaseTypeTest | ||
54 | { | ||
55 | public function testCreateFormInstances() | ||
56 | { | ||
57 | $this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('form')); | ||
58 | } | ||
59 | |||
60 | public function testPassRequiredAsOption() | ||
61 | { | ||
62 | $form = $this->factory->create('form', null, array('required' => false)); | ||
63 | |||
64 | $this->assertFalse($form->isRequired()); | ||
65 | |||
66 | $form = $this->factory->create('form', null, array('required' => true)); | ||
67 | |||
68 | $this->assertTrue($form->isRequired()); | ||
69 | } | ||
70 | |||
71 | public function testSubmittedDataIsTrimmedBeforeTransforming() | ||
72 | { | ||
73 | $form = $this->factory->createBuilder('form') | ||
74 | ->addViewTransformer(new FixedDataTransformer(array( | ||
75 | null => '', | ||
76 | 'reverse[a]' => 'a', | ||
77 | ))) | ||
78 | ->setCompound(false) | ||
79 | ->getForm(); | ||
80 | |||
81 | $form->submit(' a '); | ||
82 | |||
83 | $this->assertEquals('a', $form->getViewData()); | ||
84 | $this->assertEquals('reverse[a]', $form->getData()); | ||
85 | } | ||
86 | |||
87 | public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming() | ||
88 | { | ||
89 | $form = $this->factory->createBuilder('form', null, array('trim' => false)) | ||
90 | ->addViewTransformer(new FixedDataTransformer(array( | ||
91 | null => '', | ||
92 | 'reverse[ a ]' => ' a ', | ||
93 | ))) | ||
94 | ->setCompound(false) | ||
95 | ->getForm(); | ||
96 | |||
97 | $form->submit(' a '); | ||
98 | |||
99 | $this->assertEquals(' a ', $form->getViewData()); | ||
100 | $this->assertEquals('reverse[ a ]', $form->getData()); | ||
101 | } | ||
102 | |||
103 | public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly() | ||
104 | { | ||
105 | $view = $this->factory->createNamedBuilder('parent', 'form', null, array('read_only' => true)) | ||
106 | ->add('child', 'form') | ||
107 | ->getForm() | ||
108 | ->createView(); | ||
109 | |||
110 | $this->assertTrue($view['child']->vars['read_only']); | ||
111 | } | ||
112 | |||
113 | public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly() | ||
114 | { | ||
115 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
116 | ->add('child', 'form', array('read_only' => true)) | ||
117 | ->getForm() | ||
118 | ->createView(); | ||
119 | |||
120 | $this->assertTrue($view['child']->vars['read_only']); | ||
121 | } | ||
122 | |||
123 | public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() | ||
124 | { | ||
125 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
126 | ->add('child', 'form') | ||
127 | ->getForm() | ||
128 | ->createView(); | ||
129 | |||
130 | $this->assertFalse($view['child']->vars['read_only']); | ||
131 | } | ||
132 | |||
133 | public function testPassMaxLengthToView() | ||
134 | { | ||
135 | $form = $this->factory->create('form', null, array('max_length' => 10)); | ||
136 | $view = $form->createView(); | ||
137 | |||
138 | $this->assertSame(10, $view->vars['max_length']); | ||
139 | } | ||
140 | |||
141 | public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable() | ||
142 | { | ||
143 | $builder = $this->factory->createBuilder('form', null, array( | ||
144 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
145 | 'required' => false, | ||
146 | )); | ||
147 | $builder->add('firstName', 'text'); | ||
148 | $builder->add('lastName', 'text'); | ||
149 | $form = $builder->getForm(); | ||
150 | |||
151 | $form->setData(null); | ||
152 | // partially empty, still an object is created | ||
153 | $form->submit(array('firstName' => 'Bernhard', 'lastName' => '')); | ||
154 | |||
155 | $author = new Author(); | ||
156 | $author->firstName = 'Bernhard'; | ||
157 | $author->setLastName(''); | ||
158 | |||
159 | $this->assertEquals($author, $form->getData()); | ||
160 | } | ||
161 | |||
162 | public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObject() | ||
163 | { | ||
164 | $builder = $this->factory->createBuilder('form', null, array( | ||
165 | // data class is inferred from the passed object | ||
166 | 'data' => new Author(), | ||
167 | 'required' => false, | ||
168 | )); | ||
169 | $builder->add('firstName', 'text'); | ||
170 | $builder->add('lastName', 'text'); | ||
171 | $form = $builder->getForm(); | ||
172 | |||
173 | $form->setData(null); | ||
174 | // partially empty, still an object is created | ||
175 | $form->submit(array('firstName' => 'Bernhard', 'lastName' => '')); | ||
176 | |||
177 | $author = new Author(); | ||
178 | $author->firstName = 'Bernhard'; | ||
179 | $author->setLastName(''); | ||
180 | |||
181 | $this->assertEquals($author, $form->getData()); | ||
182 | } | ||
183 | |||
184 | public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull() | ||
185 | { | ||
186 | $builder = $this->factory->createBuilder('form', null, array( | ||
187 | 'data_class' => null, | ||
188 | 'required' => false, | ||
189 | )); | ||
190 | $builder->add('firstName', 'text'); | ||
191 | $form = $builder->getForm(); | ||
192 | |||
193 | $form->setData(null); | ||
194 | $form->submit(array('firstName' => 'Bernhard')); | ||
195 | |||
196 | $this->assertSame(array('firstName' => 'Bernhard'), $form->getData()); | ||
197 | } | ||
198 | |||
199 | public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired() | ||
200 | { | ||
201 | $builder = $this->factory->createBuilder('form', null, array( | ||
202 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
203 | 'required' => false, | ||
204 | )); | ||
205 | $builder->add('firstName', 'text'); | ||
206 | $builder->add('lastName', 'text'); | ||
207 | $form = $builder->getForm(); | ||
208 | |||
209 | $form->setData(null); | ||
210 | $form->submit(array('firstName' => '', 'lastName' => '')); | ||
211 | |||
212 | $this->assertNull($form->getData()); | ||
213 | } | ||
214 | |||
215 | public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired() | ||
216 | { | ||
217 | $builder = $this->factory->createBuilder('form', null, array( | ||
218 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
219 | 'required' => true, | ||
220 | )); | ||
221 | $builder->add('firstName', 'text'); | ||
222 | $builder->add('lastName', 'text'); | ||
223 | $form = $builder->getForm(); | ||
224 | |||
225 | $form->setData(null); | ||
226 | $form->submit(array('firstName' => '', 'lastName' => '')); | ||
227 | |||
228 | $this->assertEquals(new Author(), $form->getData()); | ||
229 | } | ||
230 | |||
231 | /* | ||
232 | * We need something to write the field values into | ||
233 | */ | ||
234 | public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable() | ||
235 | { | ||
236 | $form = $this->factory->createBuilder('form') | ||
237 | ->add('firstName', 'text') | ||
238 | ->getForm(); | ||
239 | |||
240 | $form->setData(null); | ||
241 | $form->submit(array('firstName' => 'Bernhard')); | ||
242 | |||
243 | $this->assertSame(array('firstName' => 'Bernhard'), $form->getData()); | ||
244 | } | ||
245 | |||
246 | public function testSubmitWithEmptyDataPassesEmptyStringToTransformerIfNotCompound() | ||
247 | { | ||
248 | $form = $this->factory->createBuilder('form') | ||
249 | ->addViewTransformer(new FixedDataTransformer(array( | ||
250 | // required for the initial, internal setData(null) | ||
251 | null => 'null', | ||
252 | // required to test that submit(null) is converted to '' | ||
253 | 'empty' => '', | ||
254 | ))) | ||
255 | ->setCompound(false) | ||
256 | ->getForm(); | ||
257 | |||
258 | $form->submit(null); | ||
259 | |||
260 | $this->assertSame('empty', $form->getData()); | ||
261 | } | ||
262 | |||
263 | public function testSubmitWithEmptyDataUsesEmptyDataOption() | ||
264 | { | ||
265 | $author = new Author(); | ||
266 | |||
267 | $builder = $this->factory->createBuilder('form', null, array( | ||
268 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
269 | 'empty_data' => $author, | ||
270 | )); | ||
271 | $builder->add('firstName', 'text'); | ||
272 | $form = $builder->getForm(); | ||
273 | |||
274 | $form->submit(array('firstName' => 'Bernhard')); | ||
275 | |||
276 | $this->assertSame($author, $form->getData()); | ||
277 | $this->assertEquals('Bernhard', $author->firstName); | ||
278 | } | ||
279 | |||
280 | public function provideZeros() | ||
281 | { | ||
282 | return array( | ||
283 | array(0, '0'), | ||
284 | array('0', '0'), | ||
285 | array('00000', '00000'), | ||
286 | ); | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * @dataProvider provideZeros | ||
291 | * @see https://github.com/symfony/symfony/issues/1986 | ||
292 | */ | ||
293 | public function testSetDataThroughParamsWithZero($data, $dataAsString) | ||
294 | { | ||
295 | $form = $this->factory->create('form', null, array( | ||
296 | 'data' => $data, | ||
297 | 'compound' => false, | ||
298 | )); | ||
299 | $view = $form->createView(); | ||
300 | |||
301 | $this->assertFalse($form->isEmpty()); | ||
302 | |||
303 | $this->assertSame($dataAsString, $view->vars['value']); | ||
304 | $this->assertSame($dataAsString, $form->getData()); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
309 | */ | ||
310 | public function testAttributesException() | ||
311 | { | ||
312 | $this->factory->create('form', null, array('attr' => '')); | ||
313 | } | ||
314 | |||
315 | public function testNameCanBeEmptyString() | ||
316 | { | ||
317 | $form = $this->factory->createNamed('', 'form'); | ||
318 | |||
319 | $this->assertEquals('', $form->getName()); | ||
320 | } | ||
321 | |||
322 | public function testSubformDoesntCallSetters() | ||
323 | { | ||
324 | $author = new FormTest_AuthorWithoutRefSetter(new Author()); | ||
325 | |||
326 | $builder = $this->factory->createBuilder('form', $author); | ||
327 | $builder->add('reference', 'form', array( | ||
328 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
329 | )); | ||
330 | $builder->get('reference')->add('firstName', 'text'); | ||
331 | $form = $builder->getForm(); | ||
332 | |||
333 | $form->submit(array( | ||
334 | // reference has a getter, but not setter | ||
335 | 'reference' => array( | ||
336 | 'firstName' => 'Foo', | ||
337 | ) | ||
338 | )); | ||
339 | |||
340 | $this->assertEquals('Foo', $author->getReference()->firstName); | ||
341 | } | ||
342 | |||
343 | public function testSubformCallsSettersIfTheObjectChanged() | ||
344 | { | ||
345 | // no reference | ||
346 | $author = new FormTest_AuthorWithoutRefSetter(null); | ||
347 | $newReference = new Author(); | ||
348 | |||
349 | $builder = $this->factory->createBuilder('form', $author); | ||
350 | $builder->add('referenceCopy', 'form', array( | ||
351 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
352 | )); | ||
353 | $builder->get('referenceCopy')->add('firstName', 'text'); | ||
354 | $form = $builder->getForm(); | ||
355 | |||
356 | $form['referenceCopy']->setData($newReference); // new author object | ||
357 | |||
358 | $form->submit(array( | ||
359 | // referenceCopy has a getter that returns a copy | ||
360 | 'referenceCopy' => array( | ||
361 | 'firstName' => 'Foo', | ||
362 | ) | ||
363 | )); | ||
364 | |||
365 | $this->assertEquals('Foo', $author->getReferenceCopy()->firstName); | ||
366 | } | ||
367 | |||
368 | public function testSubformCallsSettersIfByReferenceIsFalse() | ||
369 | { | ||
370 | $author = new FormTest_AuthorWithoutRefSetter(new Author()); | ||
371 | |||
372 | $builder = $this->factory->createBuilder('form', $author); | ||
373 | $builder->add('referenceCopy', 'form', array( | ||
374 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
375 | 'by_reference' => false | ||
376 | )); | ||
377 | $builder->get('referenceCopy')->add('firstName', 'text'); | ||
378 | $form = $builder->getForm(); | ||
379 | |||
380 | $form->submit(array( | ||
381 | // referenceCopy has a getter that returns a copy | ||
382 | 'referenceCopy' => array( | ||
383 | 'firstName' => 'Foo', | ||
384 | ) | ||
385 | )); | ||
386 | |||
387 | // firstName can only be updated if setReferenceCopy() was called | ||
388 | $this->assertEquals('Foo', $author->getReferenceCopy()->firstName); | ||
389 | } | ||
390 | |||
391 | public function testSubformCallsSettersIfReferenceIsScalar() | ||
392 | { | ||
393 | $author = new FormTest_AuthorWithoutRefSetter('scalar'); | ||
394 | |||
395 | $builder = $this->factory->createBuilder('form', $author); | ||
396 | $builder->add('referenceCopy', 'form'); | ||
397 | $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( | ||
398 | function () {}, | ||
399 | function ($value) { // reverseTransform | ||
400 | |||
401 | return 'foobar'; | ||
402 | } | ||
403 | )); | ||
404 | $form = $builder->getForm(); | ||
405 | |||
406 | $form->submit(array( | ||
407 | 'referenceCopy' => array(), // doesn't matter actually | ||
408 | )); | ||
409 | |||
410 | // firstName can only be updated if setReferenceCopy() was called | ||
411 | $this->assertEquals('foobar', $author->getReferenceCopy()); | ||
412 | } | ||
413 | |||
414 | public function testSubformAlwaysInsertsIntoArrays() | ||
415 | { | ||
416 | $ref1 = new Author(); | ||
417 | $ref2 = new Author(); | ||
418 | $author = array('referenceCopy' => $ref1); | ||
419 | |||
420 | $builder = $this->factory->createBuilder('form'); | ||
421 | $builder->setData($author); | ||
422 | $builder->add('referenceCopy', 'form'); | ||
423 | $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( | ||
424 | function () {}, | ||
425 | function ($value) use ($ref2) { // reverseTransform | ||
426 | |||
427 | return $ref2; | ||
428 | } | ||
429 | )); | ||
430 | $form = $builder->getForm(); | ||
431 | |||
432 | $form->submit(array( | ||
433 | 'referenceCopy' => array('a' => 'b'), // doesn't matter actually | ||
434 | )); | ||
435 | |||
436 | // the new reference was inserted into the array | ||
437 | $author = $form->getData(); | ||
438 | $this->assertSame($ref2, $author['referenceCopy']); | ||
439 | } | ||
440 | |||
441 | public function testPassMultipartTrueIfAnyChildIsMultipartToView() | ||
442 | { | ||
443 | $view = $this->factory->createBuilder('form') | ||
444 | ->add('foo', 'text') | ||
445 | ->add('bar', 'file') | ||
446 | ->getForm() | ||
447 | ->createView(); | ||
448 | |||
449 | $this->assertTrue($view->vars['multipart']); | ||
450 | } | ||
451 | |||
452 | public function testViewIsNotRenderedByDefault() | ||
453 | { | ||
454 | $view = $this->factory->createBuilder('form') | ||
455 | ->add('foo', 'form') | ||
456 | ->getForm() | ||
457 | ->createView(); | ||
458 | |||
459 | $this->assertFalse($view->isRendered()); | ||
460 | } | ||
461 | |||
462 | public function testErrorBubblingIfCompound() | ||
463 | { | ||
464 | $form = $this->factory->create('form', null, array( | ||
465 | 'compound' => true, | ||
466 | )); | ||
467 | |||
468 | $this->assertTrue($form->getConfig()->getErrorBubbling()); | ||
469 | } | ||
470 | |||
471 | public function testNoErrorBubblingIfNotCompound() | ||
472 | { | ||
473 | $form = $this->factory->create('form', null, array( | ||
474 | 'compound' => false, | ||
475 | )); | ||
476 | |||
477 | $this->assertFalse($form->getConfig()->getErrorBubbling()); | ||
478 | } | ||
479 | |||
480 | public function testOverrideErrorBubbling() | ||
481 | { | ||
482 | $form = $this->factory->create('form', null, array( | ||
483 | 'compound' => false, | ||
484 | 'error_bubbling' => true, | ||
485 | )); | ||
486 | |||
487 | $this->assertTrue($form->getConfig()->getErrorBubbling()); | ||
488 | } | ||
489 | |||
490 | public function testPropertyPath() | ||
491 | { | ||
492 | $form = $this->factory->create('form', null, array( | ||
493 | 'property_path' => 'foo', | ||
494 | )); | ||
495 | |||
496 | $this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath()); | ||
497 | $this->assertTrue($form->getConfig()->getMapped()); | ||
498 | } | ||
499 | |||
500 | public function testPropertyPathNullImpliesDefault() | ||
501 | { | ||
502 | $form = $this->factory->createNamed('name', 'form', null, array( | ||
503 | 'property_path' => null, | ||
504 | )); | ||
505 | |||
506 | $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); | ||
507 | $this->assertTrue($form->getConfig()->getMapped()); | ||
508 | } | ||
509 | |||
510 | public function testNotMapped() | ||
511 | { | ||
512 | $form = $this->factory->create('form', null, array( | ||
513 | 'property_path' => 'foo', | ||
514 | 'mapped' => false, | ||
515 | )); | ||
516 | |||
517 | $this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath()); | ||
518 | $this->assertFalse($form->getConfig()->getMapped()); | ||
519 | } | ||
520 | |||
521 | public function testViewValidNotSubmitted() | ||
522 | { | ||
523 | $form = $this->factory->create('form'); | ||
524 | $view = $form->createView(); | ||
525 | $this->assertTrue($view->vars['valid']); | ||
526 | } | ||
527 | |||
528 | public function testViewNotValidSubmitted() | ||
529 | { | ||
530 | $form = $this->factory->create('form'); | ||
531 | $form->submit(array()); | ||
532 | $form->addError(new FormError('An error')); | ||
533 | $view = $form->createView(); | ||
534 | $this->assertFalse($view->vars['valid']); | ||
535 | } | ||
536 | |||
537 | public function testDataOptionSupersedesSetDataCalls() | ||
538 | { | ||
539 | $form = $this->factory->create('form', null, array( | ||
540 | 'data' => 'default', | ||
541 | 'compound' => false, | ||
542 | )); | ||
543 | |||
544 | $form->setData('foobar'); | ||
545 | |||
546 | $this->assertSame('default', $form->getData()); | ||
547 | } | ||
548 | |||
549 | public function testNormDataIsPassedToView() | ||
550 | { | ||
551 | $view = $this->factory->createBuilder('form') | ||
552 | ->addViewTransformer(new FixedDataTransformer(array( | ||
553 | 'foo' => 'bar', | ||
554 | ))) | ||
555 | ->setData('foo') | ||
556 | ->getForm() | ||
557 | ->createView(); | ||
558 | |||
559 | $this->assertSame('foo', $view->vars['data']); | ||
560 | $this->assertSame('bar', $view->vars['value']); | ||
561 | } | ||
562 | |||
563 | // https://github.com/symfony/symfony/issues/6862 | ||
564 | public function testPassZeroLabelToView() | ||
565 | { | ||
566 | $view = $this->factory->create('form', null, array( | ||
567 | 'label' => '0' | ||
568 | )) | ||
569 | ->createView(); | ||
570 | |||
571 | $this->assertSame('0', $view->vars['label']); | ||
572 | } | ||
573 | |||
574 | protected function getTestedType() | ||
575 | { | ||
576 | return 'form'; | ||
577 | } | ||
578 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php deleted file mode 100644 index 998bbe01..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
15 | |||
16 | class IntegerTypeTest extends TypeTestCase | ||
17 | { | ||
18 | protected function setUp() | ||
19 | { | ||
20 | IntlTestHelper::requireIntl($this); | ||
21 | |||
22 | parent::setUp(); | ||
23 | } | ||
24 | |||
25 | public function testSubmitCastsToInteger() | ||
26 | { | ||
27 | $form = $this->factory->create('integer'); | ||
28 | |||
29 | $form->submit('1.678'); | ||
30 | |||
31 | $this->assertSame(1, $form->getData()); | ||
32 | $this->assertSame('1', $form->getViewData()); | ||
33 | } | ||
34 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php deleted file mode 100644 index 24434b21..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class LanguageTypeTest extends TypeTestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | IntlTestHelper::requireIntl($this); | ||
22 | |||
23 | parent::setUp(); | ||
24 | } | ||
25 | |||
26 | public function testCountriesAreSelectable() | ||
27 | { | ||
28 | $form = $this->factory->create('language'); | ||
29 | $view = $form->createView(); | ||
30 | $choices = $view->vars['choices']; | ||
31 | |||
32 | $this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false); | ||
33 | $this->assertContains(new ChoiceView('en_GB', 'en_GB', 'British English'), $choices, '', false, false); | ||
34 | $this->assertContains(new ChoiceView('en_US', 'en_US', 'U.S. English'), $choices, '', false, false); | ||
35 | $this->assertContains(new ChoiceView('fr', 'fr', 'French'), $choices, '', false, false); | ||
36 | $this->assertContains(new ChoiceView('my', 'my', 'Burmese'), $choices, '', false, false); | ||
37 | } | ||
38 | |||
39 | public function testMultipleLanguagesIsNotIncluded() | ||
40 | { | ||
41 | $form = $this->factory->create('language', 'language'); | ||
42 | $view = $form->createView(); | ||
43 | $choices = $view->vars['choices']; | ||
44 | |||
45 | $this->assertNotContains(new ChoiceView('mul', 'mul', 'Mehrsprachig'), $choices, '', false, false); | ||
46 | } | ||
47 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php deleted file mode 100644 index e402cb4b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
16 | |||
17 | class LocaleTypeTest extends TypeTestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | IntlTestHelper::requireIntl($this); | ||
22 | |||
23 | parent::setUp(); | ||
24 | } | ||
25 | |||
26 | public function testLocalesAreSelectable() | ||
27 | { | ||
28 | $form = $this->factory->create('locale'); | ||
29 | $view = $form->createView(); | ||
30 | $choices = $view->vars['choices']; | ||
31 | |||
32 | $this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false); | ||
33 | $this->assertContains(new ChoiceView('en_GB', 'en_GB', 'English (United Kingdom)'), $choices, '', false, false); | ||
34 | $this->assertContains(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'Chinese (Traditional, Macau SAR China)'), $choices, '', false, false); | ||
35 | } | ||
36 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php deleted file mode 100644 index 97fc37fa..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
15 | |||
16 | class MoneyTypeTest extends TypeTestCase | ||
17 | { | ||
18 | protected function setUp() | ||
19 | { | ||
20 | // we test against different locales, so we need the full | ||
21 | // implementation | ||
22 | IntlTestHelper::requireFullIntl($this); | ||
23 | |||
24 | parent::setUp(); | ||
25 | } | ||
26 | |||
27 | public function testPassMoneyPatternToView() | ||
28 | { | ||
29 | \Locale::setDefault('de_DE'); | ||
30 | |||
31 | $form = $this->factory->create('money'); | ||
32 | $view = $form->createView(); | ||
33 | |||
34 | $this->assertSame('{{ widget }} €', $view->vars['money_pattern']); | ||
35 | } | ||
36 | |||
37 | public function testMoneyPatternWorksForYen() | ||
38 | { | ||
39 | \Locale::setDefault('en_US'); | ||
40 | |||
41 | $form = $this->factory->create('money', null, array('currency' => 'JPY')); | ||
42 | $view = $form->createView(); | ||
43 | $this->assertTrue((Boolean) strstr($view->vars['money_pattern'], 'Â¥')); | ||
44 | } | ||
45 | |||
46 | // https://github.com/symfony/symfony/issues/5458 | ||
47 | public function testPassDifferentPatternsForDifferentCurrencies() | ||
48 | { | ||
49 | \Locale::setDefault('de_DE'); | ||
50 | |||
51 | $form1 = $this->factory->create('money', null, array('currency' => 'GBP')); | ||
52 | $form2 = $this->factory->create('money', null, array('currency' => 'EUR')); | ||
53 | $view1 = $form1->createView(); | ||
54 | $view2 = $form2->createView(); | ||
55 | |||
56 | $this->assertSame('{{ widget }} £', $view1->vars['money_pattern']); | ||
57 | $this->assertSame('{{ widget }} €', $view2->vars['money_pattern']); | ||
58 | } | ||
59 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php deleted file mode 100644 index e5b3dd74..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
15 | |||
16 | class NumberTypeTest extends TypeTestCase | ||
17 | { | ||
18 | protected function setUp() | ||
19 | { | ||
20 | parent::setUp(); | ||
21 | |||
22 | // we test against "de_DE", so we need the full implementation | ||
23 | IntlTestHelper::requireFullIntl($this); | ||
24 | |||
25 | \Locale::setDefault('de_DE'); | ||
26 | } | ||
27 | |||
28 | public function testDefaultFormatting() | ||
29 | { | ||
30 | $form = $this->factory->create('number'); | ||
31 | $form->setData('12345.67890'); | ||
32 | $view = $form->createView(); | ||
33 | |||
34 | $this->assertSame('12345,679', $view->vars['value']); | ||
35 | } | ||
36 | |||
37 | public function testDefaultFormattingWithGrouping() | ||
38 | { | ||
39 | $form = $this->factory->create('number', null, array('grouping' => true)); | ||
40 | $form->setData('12345.67890'); | ||
41 | $view = $form->createView(); | ||
42 | |||
43 | $this->assertSame('12.345,679', $view->vars['value']); | ||
44 | } | ||
45 | |||
46 | public function testDefaultFormattingWithPrecision() | ||
47 | { | ||
48 | $form = $this->factory->create('number', null, array('precision' => 2)); | ||
49 | $form->setData('12345.67890'); | ||
50 | $view = $form->createView(); | ||
51 | |||
52 | $this->assertSame('12345,68', $view->vars['value']); | ||
53 | } | ||
54 | |||
55 | public function testDefaultFormattingWithRounding() | ||
56 | { | ||
57 | $form = $this->factory->create('number', null, array('precision' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP)); | ||
58 | $form->setData('12345.54321'); | ||
59 | $view = $form->createView(); | ||
60 | |||
61 | $this->assertSame('12346', $view->vars['value']); | ||
62 | } | ||
63 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php deleted file mode 100644 index bccb6f7b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
15 | { | ||
16 | public function testEmptyIfNotSubmitted() | ||
17 | { | ||
18 | $form = $this->factory->create('password'); | ||
19 | $form->setData('pAs5w0rd'); | ||
20 | $view = $form->createView(); | ||
21 | |||
22 | $this->assertSame('', $view->vars['value']); | ||
23 | } | ||
24 | |||
25 | public function testEmptyIfSubmitted() | ||
26 | { | ||
27 | $form = $this->factory->create('password'); | ||
28 | $form->submit('pAs5w0rd'); | ||
29 | $view = $form->createView(); | ||
30 | |||
31 | $this->assertSame('', $view->vars['value']); | ||
32 | } | ||
33 | |||
34 | public function testNotEmptyIfSubmittedAndNotAlwaysEmpty() | ||
35 | { | ||
36 | $form = $this->factory->create('password', null, array('always_empty' => false)); | ||
37 | $form->submit('pAs5w0rd'); | ||
38 | $view = $form->createView(); | ||
39 | |||
40 | $this->assertSame('pAs5w0rd', $view->vars['value']); | ||
41 | } | ||
42 | |||
43 | public function testNotTrimmed() | ||
44 | { | ||
45 | $form = $this->factory->create('password', null); | ||
46 | $form->submit(' pAs5w0rd '); | ||
47 | $data = $form->getData(); | ||
48 | |||
49 | $this->assertSame(' pAs5w0rd ', $data); | ||
50 | } | ||
51 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php deleted file mode 100644 index 9e125d78..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
15 | { | ||
16 | protected $form; | ||
17 | |||
18 | protected function setUp() | ||
19 | { | ||
20 | parent::setUp(); | ||
21 | |||
22 | $this->form = $this->factory->create('repeated', null, array( | ||
23 | 'type' => 'text', | ||
24 | )); | ||
25 | $this->form->setData(null); | ||
26 | } | ||
27 | |||
28 | public function testSetData() | ||
29 | { | ||
30 | $this->form->setData('foobar'); | ||
31 | |||
32 | $this->assertEquals('foobar', $this->form['first']->getData()); | ||
33 | $this->assertEquals('foobar', $this->form['second']->getData()); | ||
34 | } | ||
35 | |||
36 | public function testSetOptions() | ||
37 | { | ||
38 | $form = $this->factory->create('repeated', null, array( | ||
39 | 'type' => 'text', | ||
40 | 'options' => array('label' => 'Global'), | ||
41 | )); | ||
42 | |||
43 | $this->assertEquals('Global', $form['first']->getConfig()->getOption('label')); | ||
44 | $this->assertEquals('Global', $form['second']->getConfig()->getOption('label')); | ||
45 | $this->assertTrue($form['first']->isRequired()); | ||
46 | $this->assertTrue($form['second']->isRequired()); | ||
47 | } | ||
48 | |||
49 | public function testSetOptionsPerChild() | ||
50 | { | ||
51 | $form = $this->factory->create('repeated', null, array( | ||
52 | // the global required value cannot be overridden | ||
53 | 'type' => 'text', | ||
54 | 'first_options' => array('label' => 'Test', 'required' => false), | ||
55 | 'second_options' => array('label' => 'Test2') | ||
56 | )); | ||
57 | |||
58 | $this->assertEquals('Test', $form['first']->getConfig()->getOption('label')); | ||
59 | $this->assertEquals('Test2', $form['second']->getConfig()->getOption('label')); | ||
60 | $this->assertTrue($form['first']->isRequired()); | ||
61 | $this->assertTrue($form['second']->isRequired()); | ||
62 | } | ||
63 | |||
64 | public function testSetRequired() | ||
65 | { | ||
66 | $form = $this->factory->create('repeated', null, array( | ||
67 | 'required' => false, | ||
68 | 'type' => 'text', | ||
69 | )); | ||
70 | |||
71 | $this->assertFalse($form['first']->isRequired()); | ||
72 | $this->assertFalse($form['second']->isRequired()); | ||
73 | } | ||
74 | |||
75 | public function testSetErrorBubblingToTrue() | ||
76 | { | ||
77 | $form = $this->factory->create('repeated', null, array( | ||
78 | 'error_bubbling' => true, | ||
79 | )); | ||
80 | |||
81 | $this->assertTrue($form->getConfig()->getOption('error_bubbling')); | ||
82 | $this->assertTrue($form['first']->getConfig()->getOption('error_bubbling')); | ||
83 | $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); | ||
84 | } | ||
85 | |||
86 | public function testSetErrorBubblingToFalse() | ||
87 | { | ||
88 | $form = $this->factory->create('repeated', null, array( | ||
89 | 'error_bubbling' => false, | ||
90 | )); | ||
91 | |||
92 | $this->assertFalse($form->getConfig()->getOption('error_bubbling')); | ||
93 | $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); | ||
94 | $this->assertFalse($form['second']->getConfig()->getOption('error_bubbling')); | ||
95 | } | ||
96 | |||
97 | public function testSetErrorBubblingIndividually() | ||
98 | { | ||
99 | $form = $this->factory->create('repeated', null, array( | ||
100 | 'error_bubbling' => true, | ||
101 | 'options' => array('error_bubbling' => false), | ||
102 | 'second_options' => array('error_bubbling' => true), | ||
103 | )); | ||
104 | |||
105 | $this->assertTrue($form->getConfig()->getOption('error_bubbling')); | ||
106 | $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); | ||
107 | $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); | ||
108 | } | ||
109 | |||
110 | public function testSetOptionsPerChildAndOverwrite() | ||
111 | { | ||
112 | $form = $this->factory->create('repeated', null, array( | ||
113 | 'type' => 'text', | ||
114 | 'options' => array('label' => 'Label'), | ||
115 | 'second_options' => array('label' => 'Second label') | ||
116 | )); | ||
117 | |||
118 | $this->assertEquals('Label', $form['first']->getConfig()->getOption('label')); | ||
119 | $this->assertEquals('Second label', $form['second']->getConfig()->getOption('label')); | ||
120 | $this->assertTrue($form['first']->isRequired()); | ||
121 | $this->assertTrue($form['second']->isRequired()); | ||
122 | } | ||
123 | |||
124 | public function testSubmitUnequal() | ||
125 | { | ||
126 | $input = array('first' => 'foo', 'second' => 'bar'); | ||
127 | |||
128 | $this->form->submit($input); | ||
129 | |||
130 | $this->assertEquals('foo', $this->form['first']->getViewData()); | ||
131 | $this->assertEquals('bar', $this->form['second']->getViewData()); | ||
132 | $this->assertFalse($this->form->isSynchronized()); | ||
133 | $this->assertEquals($input, $this->form->getViewData()); | ||
134 | $this->assertNull($this->form->getData()); | ||
135 | } | ||
136 | |||
137 | public function testSubmitEqual() | ||
138 | { | ||
139 | $input = array('first' => 'foo', 'second' => 'foo'); | ||
140 | |||
141 | $this->form->submit($input); | ||
142 | |||
143 | $this->assertEquals('foo', $this->form['first']->getViewData()); | ||
144 | $this->assertEquals('foo', $this->form['second']->getViewData()); | ||
145 | $this->assertTrue($this->form->isSynchronized()); | ||
146 | $this->assertEquals($input, $this->form->getViewData()); | ||
147 | $this->assertEquals('foo', $this->form->getData()); | ||
148 | } | ||
149 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php deleted file mode 100644 index 8cc72281..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | class SubmitTypeTest extends TypeTestCase | ||
18 | { | ||
19 | public function testCreateSubmitButtonInstances() | ||
20 | { | ||
21 | $this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('submit')); | ||
22 | } | ||
23 | |||
24 | public function testNotClickedByDefault() | ||
25 | { | ||
26 | $button = $this->factory->create('submit'); | ||
27 | |||
28 | $this->assertFalse($button->isClicked()); | ||
29 | } | ||
30 | |||
31 | public function testNotClickedIfSubmittedWithNull() | ||
32 | { | ||
33 | $button = $this->factory->create('submit'); | ||
34 | $button->submit(null); | ||
35 | |||
36 | $this->assertFalse($button->isClicked()); | ||
37 | } | ||
38 | |||
39 | public function testClickedIfSubmittedWithEmptyString() | ||
40 | { | ||
41 | $button = $this->factory->create('submit'); | ||
42 | $button->submit(''); | ||
43 | |||
44 | $this->assertTrue($button->isClicked()); | ||
45 | } | ||
46 | |||
47 | public function testClickedIfSubmittedWithUnemptyString() | ||
48 | { | ||
49 | $button = $this->factory->create('submit'); | ||
50 | $button->submit('foo'); | ||
51 | |||
52 | $this->assertTrue($button->isClicked()); | ||
53 | } | ||
54 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php deleted file mode 100644 index 9bdfe156..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ /dev/null | |||
@@ -1,649 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | use Symfony\Component\Form\FormError; | ||
16 | use Symfony\Component\Intl\Util\IntlTestHelper; | ||
17 | |||
18 | class TimeTypeTest extends TypeTestCase | ||
19 | { | ||
20 | protected function setUp() | ||
21 | { | ||
22 | IntlTestHelper::requireIntl($this); | ||
23 | |||
24 | parent::setUp(); | ||
25 | } | ||
26 | |||
27 | public function testSubmitDateTime() | ||
28 | { | ||
29 | $form = $this->factory->create('time', null, array( | ||
30 | 'model_timezone' => 'UTC', | ||
31 | 'view_timezone' => 'UTC', | ||
32 | 'input' => 'datetime', | ||
33 | )); | ||
34 | |||
35 | $input = array( | ||
36 | 'hour' => '3', | ||
37 | 'minute' => '4', | ||
38 | ); | ||
39 | |||
40 | $form->submit($input); | ||
41 | |||
42 | $dateTime = new \DateTime('1970-01-01 03:04:00 UTC'); | ||
43 | |||
44 | $this->assertEquals($dateTime, $form->getData()); | ||
45 | $this->assertEquals($input, $form->getViewData()); | ||
46 | } | ||
47 | |||
48 | public function testSubmitString() | ||
49 | { | ||
50 | $form = $this->factory->create('time', null, array( | ||
51 | 'model_timezone' => 'UTC', | ||
52 | 'view_timezone' => 'UTC', | ||
53 | 'input' => 'string', | ||
54 | )); | ||
55 | |||
56 | $input = array( | ||
57 | 'hour' => '3', | ||
58 | 'minute' => '4', | ||
59 | ); | ||
60 | |||
61 | $form->submit($input); | ||
62 | |||
63 | $this->assertEquals('03:04:00', $form->getData()); | ||
64 | $this->assertEquals($input, $form->getViewData()); | ||
65 | } | ||
66 | |||
67 | public function testSubmitTimestamp() | ||
68 | { | ||
69 | $form = $this->factory->create('time', null, array( | ||
70 | 'model_timezone' => 'UTC', | ||
71 | 'view_timezone' => 'UTC', | ||
72 | 'input' => 'timestamp', | ||
73 | )); | ||
74 | |||
75 | $input = array( | ||
76 | 'hour' => '3', | ||
77 | 'minute' => '4', | ||
78 | ); | ||
79 | |||
80 | $form->submit($input); | ||
81 | |||
82 | $dateTime = new \DateTime('1970-01-01 03:04:00 UTC'); | ||
83 | |||
84 | $this->assertEquals($dateTime->format('U'), $form->getData()); | ||
85 | $this->assertEquals($input, $form->getViewData()); | ||
86 | } | ||
87 | |||
88 | public function testSubmitArray() | ||
89 | { | ||
90 | $form = $this->factory->create('time', null, array( | ||
91 | 'model_timezone' => 'UTC', | ||
92 | 'view_timezone' => 'UTC', | ||
93 | 'input' => 'array', | ||
94 | )); | ||
95 | |||
96 | $input = array( | ||
97 | 'hour' => '3', | ||
98 | 'minute' => '4', | ||
99 | ); | ||
100 | |||
101 | $form->submit($input); | ||
102 | |||
103 | $this->assertEquals($input, $form->getData()); | ||
104 | $this->assertEquals($input, $form->getViewData()); | ||
105 | } | ||
106 | |||
107 | public function testSubmitDatetimeSingleText() | ||
108 | { | ||
109 | $form = $this->factory->create('time', null, array( | ||
110 | 'model_timezone' => 'UTC', | ||
111 | 'view_timezone' => 'UTC', | ||
112 | 'input' => 'datetime', | ||
113 | 'widget' => 'single_text', | ||
114 | )); | ||
115 | |||
116 | $form->submit('03:04'); | ||
117 | |||
118 | $this->assertEquals(new \DateTime('1970-01-01 03:04:00 UTC'), $form->getData()); | ||
119 | $this->assertEquals('03:04', $form->getViewData()); | ||
120 | } | ||
121 | |||
122 | public function testSubmitDatetimeSingleTextWithoutMinutes() | ||
123 | { | ||
124 | $form = $this->factory->create('time', null, array( | ||
125 | 'model_timezone' => 'UTC', | ||
126 | 'view_timezone' => 'UTC', | ||
127 | 'input' => 'datetime', | ||
128 | 'widget' => 'single_text', | ||
129 | 'with_minutes' => false, | ||
130 | )); | ||
131 | |||
132 | $form->submit('03'); | ||
133 | |||
134 | $this->assertEquals(new \DateTime('1970-01-01 03:00:00 UTC'), $form->getData()); | ||
135 | $this->assertEquals('03', $form->getViewData()); | ||
136 | } | ||
137 | |||
138 | public function testSubmitArraySingleText() | ||
139 | { | ||
140 | $form = $this->factory->create('time', null, array( | ||
141 | 'model_timezone' => 'UTC', | ||
142 | 'view_timezone' => 'UTC', | ||
143 | 'input' => 'array', | ||
144 | 'widget' => 'single_text', | ||
145 | )); | ||
146 | |||
147 | $data = array( | ||
148 | 'hour' => '3', | ||
149 | 'minute' => '4', | ||
150 | ); | ||
151 | |||
152 | $form->submit('03:04'); | ||
153 | |||
154 | $this->assertEquals($data, $form->getData()); | ||
155 | $this->assertEquals('03:04', $form->getViewData()); | ||
156 | } | ||
157 | |||
158 | public function testSubmitArraySingleTextWithoutMinutes() | ||
159 | { | ||
160 | $form = $this->factory->create('time', null, array( | ||
161 | 'model_timezone' => 'UTC', | ||
162 | 'view_timezone' => 'UTC', | ||
163 | 'input' => 'array', | ||
164 | 'widget' => 'single_text', | ||
165 | 'with_minutes' => false, | ||
166 | )); | ||
167 | |||
168 | $data = array( | ||
169 | 'hour' => '3', | ||
170 | ); | ||
171 | |||
172 | $form->submit('03'); | ||
173 | |||
174 | $this->assertEquals($data, $form->getData()); | ||
175 | $this->assertEquals('03', $form->getViewData()); | ||
176 | } | ||
177 | |||
178 | public function testSubmitArraySingleTextWithSeconds() | ||
179 | { | ||
180 | $form = $this->factory->create('time', null, array( | ||
181 | 'model_timezone' => 'UTC', | ||
182 | 'view_timezone' => 'UTC', | ||
183 | 'input' => 'array', | ||
184 | 'widget' => 'single_text', | ||
185 | 'with_seconds' => true, | ||
186 | )); | ||
187 | |||
188 | $data = array( | ||
189 | 'hour' => '3', | ||
190 | 'minute' => '4', | ||
191 | 'second' => '5', | ||
192 | ); | ||
193 | |||
194 | $form->submit('03:04:05'); | ||
195 | |||
196 | $this->assertEquals($data, $form->getData()); | ||
197 | $this->assertEquals('03:04:05', $form->getViewData()); | ||
198 | } | ||
199 | |||
200 | public function testSubmitStringSingleText() | ||
201 | { | ||
202 | $form = $this->factory->create('time', null, array( | ||
203 | 'model_timezone' => 'UTC', | ||
204 | 'view_timezone' => 'UTC', | ||
205 | 'input' => 'string', | ||
206 | 'widget' => 'single_text', | ||
207 | )); | ||
208 | |||
209 | $form->submit('03:04'); | ||
210 | |||
211 | $this->assertEquals('03:04:00', $form->getData()); | ||
212 | $this->assertEquals('03:04', $form->getViewData()); | ||
213 | } | ||
214 | |||
215 | public function testSubmitStringSingleTextWithoutMinutes() | ||
216 | { | ||
217 | $form = $this->factory->create('time', null, array( | ||
218 | 'model_timezone' => 'UTC', | ||
219 | 'view_timezone' => 'UTC', | ||
220 | 'input' => 'string', | ||
221 | 'widget' => 'single_text', | ||
222 | 'with_minutes' => false, | ||
223 | )); | ||
224 | |||
225 | $form->submit('03'); | ||
226 | |||
227 | $this->assertEquals('03:00:00', $form->getData()); | ||
228 | $this->assertEquals('03', $form->getViewData()); | ||
229 | } | ||
230 | |||
231 | public function testSetDataWithoutMinutes() | ||
232 | { | ||
233 | $form = $this->factory->create('time', null, array( | ||
234 | 'model_timezone' => 'UTC', | ||
235 | 'view_timezone' => 'UTC', | ||
236 | 'input' => 'datetime', | ||
237 | 'with_minutes' => false, | ||
238 | )); | ||
239 | |||
240 | $form->setData(new \DateTime('03:04:05 UTC')); | ||
241 | |||
242 | $this->assertEquals(array('hour' => 3), $form->getViewData()); | ||
243 | } | ||
244 | |||
245 | public function testSetDataWithSeconds() | ||
246 | { | ||
247 | $form = $this->factory->create('time', null, array( | ||
248 | 'model_timezone' => 'UTC', | ||
249 | 'view_timezone' => 'UTC', | ||
250 | 'input' => 'datetime', | ||
251 | 'with_seconds' => true, | ||
252 | )); | ||
253 | |||
254 | $form->setData(new \DateTime('03:04:05 UTC')); | ||
255 | |||
256 | $this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData()); | ||
257 | } | ||
258 | |||
259 | public function testSetDataDifferentTimezones() | ||
260 | { | ||
261 | $form = $this->factory->create('time', null, array( | ||
262 | 'model_timezone' => 'America/New_York', | ||
263 | 'view_timezone' => 'Asia/Hong_Kong', | ||
264 | 'input' => 'string', | ||
265 | 'with_seconds' => true, | ||
266 | )); | ||
267 | |||
268 | $dateTime = new \DateTime('2013-01-01 12:04:05'); | ||
269 | $dateTime->setTimezone(new \DateTimeZone('America/New_York')); | ||
270 | |||
271 | $form->setData($dateTime->format('H:i:s')); | ||
272 | |||
273 | $outputTime = clone $dateTime; | ||
274 | $outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
275 | |||
276 | $displayedData = array( | ||
277 | 'hour' => (int) $outputTime->format('H'), | ||
278 | 'minute' => (int) $outputTime->format('i'), | ||
279 | 'second' => (int) $outputTime->format('s') | ||
280 | ); | ||
281 | |||
282 | $this->assertEquals($displayedData, $form->getViewData()); | ||
283 | } | ||
284 | |||
285 | public function testSetDataDifferentTimezonesDateTime() | ||
286 | { | ||
287 | $form = $this->factory->create('time', null, array( | ||
288 | 'model_timezone' => 'America/New_York', | ||
289 | 'view_timezone' => 'Asia/Hong_Kong', | ||
290 | 'input' => 'datetime', | ||
291 | 'with_seconds' => true, | ||
292 | )); | ||
293 | |||
294 | $dateTime = new \DateTime('12:04:05'); | ||
295 | $dateTime->setTimezone(new \DateTimeZone('America/New_York')); | ||
296 | |||
297 | $form->setData($dateTime); | ||
298 | |||
299 | $outputTime = clone $dateTime; | ||
300 | $outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); | ||
301 | |||
302 | $displayedData = array( | ||
303 | 'hour' => (int) $outputTime->format('H'), | ||
304 | 'minute' => (int) $outputTime->format('i'), | ||
305 | 'second' => (int) $outputTime->format('s') | ||
306 | ); | ||
307 | |||
308 | $this->assertDateTimeEquals($dateTime, $form->getData()); | ||
309 | $this->assertEquals($displayedData, $form->getViewData()); | ||
310 | } | ||
311 | |||
312 | public function testHoursOption() | ||
313 | { | ||
314 | $form = $this->factory->create('time', null, array( | ||
315 | 'hours' => array(6, 7), | ||
316 | )); | ||
317 | |||
318 | $view = $form->createView(); | ||
319 | |||
320 | $this->assertEquals(array( | ||
321 | new ChoiceView('6', '6', '06'), | ||
322 | new ChoiceView('7', '7', '07'), | ||
323 | ), $view['hour']->vars['choices']); | ||
324 | } | ||
325 | |||
326 | public function testIsMinuteWithinRangeReturnsTrueIfWithin() | ||
327 | { | ||
328 | $form = $this->factory->create('time', null, array( | ||
329 | 'minutes' => array(6, 7), | ||
330 | )); | ||
331 | |||
332 | $view = $form->createView(); | ||
333 | |||
334 | $this->assertEquals(array( | ||
335 | new ChoiceView('6', '6', '06'), | ||
336 | new ChoiceView('7', '7', '07'), | ||
337 | ), $view['minute']->vars['choices']); | ||
338 | } | ||
339 | |||
340 | public function testIsSecondWithinRangeReturnsTrueIfWithin() | ||
341 | { | ||
342 | $form = $this->factory->create('time', null, array( | ||
343 | 'seconds' => array(6, 7), | ||
344 | 'with_seconds' => true, | ||
345 | )); | ||
346 | |||
347 | $view = $form->createView(); | ||
348 | |||
349 | $this->assertEquals(array( | ||
350 | new ChoiceView('6', '6', '06'), | ||
351 | new ChoiceView('7', '7', '07'), | ||
352 | ), $view['second']->vars['choices']); | ||
353 | } | ||
354 | |||
355 | public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty() | ||
356 | { | ||
357 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
358 | |||
359 | $form = $this->factory->create('time', null, array( | ||
360 | 'widget' => 'choice', | ||
361 | )); | ||
362 | |||
363 | $form->submit(array( | ||
364 | 'hour' => '', | ||
365 | 'minute' => '', | ||
366 | )); | ||
367 | |||
368 | $this->assertFalse($form->isPartiallyFilled()); | ||
369 | } | ||
370 | |||
371 | public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds() | ||
372 | { | ||
373 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
374 | |||
375 | $form = $this->factory->create('time', null, array( | ||
376 | 'widget' => 'choice', | ||
377 | 'with_seconds' => true, | ||
378 | )); | ||
379 | |||
380 | $form->submit(array( | ||
381 | 'hour' => '', | ||
382 | 'minute' => '', | ||
383 | 'second' => '', | ||
384 | )); | ||
385 | |||
386 | $this->assertFalse($form->isPartiallyFilled()); | ||
387 | } | ||
388 | |||
389 | public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled() | ||
390 | { | ||
391 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
392 | |||
393 | $form = $this->factory->create('time', null, array( | ||
394 | 'widget' => 'choice', | ||
395 | )); | ||
396 | |||
397 | $form->submit(array( | ||
398 | 'hour' => '0', | ||
399 | 'minute' => '0', | ||
400 | )); | ||
401 | |||
402 | $this->assertFalse($form->isPartiallyFilled()); | ||
403 | } | ||
404 | |||
405 | public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds() | ||
406 | { | ||
407 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
408 | |||
409 | $form = $this->factory->create('time', null, array( | ||
410 | 'widget' => 'choice', | ||
411 | 'with_seconds' => true, | ||
412 | )); | ||
413 | |||
414 | $form->submit(array( | ||
415 | 'hour' => '0', | ||
416 | 'minute' => '0', | ||
417 | 'second' => '0', | ||
418 | )); | ||
419 | |||
420 | $this->assertFalse($form->isPartiallyFilled()); | ||
421 | } | ||
422 | |||
423 | public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty() | ||
424 | { | ||
425 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
426 | |||
427 | $form = $this->factory->create('time', null, array( | ||
428 | 'widget' => 'choice', | ||
429 | 'with_seconds' => true, | ||
430 | )); | ||
431 | |||
432 | $form->submit(array( | ||
433 | 'hour' => '', | ||
434 | 'minute' => '0', | ||
435 | 'second' => '0', | ||
436 | )); | ||
437 | |||
438 | $this->assertTrue($form->isPartiallyFilled()); | ||
439 | } | ||
440 | |||
441 | public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty() | ||
442 | { | ||
443 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
444 | |||
445 | $form = $this->factory->create('time', null, array( | ||
446 | 'widget' => 'choice', | ||
447 | 'with_seconds' => true, | ||
448 | )); | ||
449 | |||
450 | $form->submit(array( | ||
451 | 'hour' => '0', | ||
452 | 'minute' => '', | ||
453 | 'second' => '0', | ||
454 | )); | ||
455 | |||
456 | $this->assertTrue($form->isPartiallyFilled()); | ||
457 | } | ||
458 | |||
459 | public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty() | ||
460 | { | ||
461 | $this->markTestIncomplete('Needs to be reimplemented using validators'); | ||
462 | |||
463 | $form = $this->factory->create('time', null, array( | ||
464 | 'widget' => 'choice', | ||
465 | 'with_seconds' => true, | ||
466 | )); | ||
467 | |||
468 | $form->submit(array( | ||
469 | 'hour' => '0', | ||
470 | 'minute' => '0', | ||
471 | 'second' => '', | ||
472 | )); | ||
473 | |||
474 | $this->assertTrue($form->isPartiallyFilled()); | ||
475 | } | ||
476 | |||
477 | // Bug fix | ||
478 | public function testInitializeWithDateTime() | ||
479 | { | ||
480 | // Throws an exception if "data_class" option is not explicitly set | ||
481 | // to null in the type | ||
482 | $this->factory->create('time', new \DateTime()); | ||
483 | } | ||
484 | |||
485 | public function testSingleTextWidgetShouldUseTheRightInputType() | ||
486 | { | ||
487 | $form = $this->factory->create('time', null, array( | ||
488 | 'widget' => 'single_text', | ||
489 | )); | ||
490 | |||
491 | $view = $form->createView(); | ||
492 | $this->assertEquals('time', $view->vars['type']); | ||
493 | } | ||
494 | |||
495 | public function testPassDefaultEmptyValueToViewIfNotRequired() | ||
496 | { | ||
497 | $form = $this->factory->create('time', null, array( | ||
498 | 'required' => false, | ||
499 | 'with_seconds' => true, | ||
500 | )); | ||
501 | |||
502 | $view = $form->createView(); | ||
503 | $this->assertSame('', $view['hour']->vars['empty_value']); | ||
504 | $this->assertSame('', $view['minute']->vars['empty_value']); | ||
505 | $this->assertSame('', $view['second']->vars['empty_value']); | ||
506 | } | ||
507 | |||
508 | public function testPassNoEmptyValueToViewIfRequired() | ||
509 | { | ||
510 | $form = $this->factory->create('time', null, array( | ||
511 | 'required' => true, | ||
512 | 'with_seconds' => true, | ||
513 | )); | ||
514 | |||
515 | $view = $form->createView(); | ||
516 | $this->assertNull($view['hour']->vars['empty_value']); | ||
517 | $this->assertNull($view['minute']->vars['empty_value']); | ||
518 | $this->assertNull($view['second']->vars['empty_value']); | ||
519 | } | ||
520 | |||
521 | public function testPassEmptyValueAsString() | ||
522 | { | ||
523 | $form = $this->factory->create('time', null, array( | ||
524 | 'empty_value' => 'Empty', | ||
525 | 'with_seconds' => true, | ||
526 | )); | ||
527 | |||
528 | $view = $form->createView(); | ||
529 | $this->assertSame('Empty', $view['hour']->vars['empty_value']); | ||
530 | $this->assertSame('Empty', $view['minute']->vars['empty_value']); | ||
531 | $this->assertSame('Empty', $view['second']->vars['empty_value']); | ||
532 | } | ||
533 | |||
534 | public function testPassEmptyValueAsArray() | ||
535 | { | ||
536 | $form = $this->factory->create('time', null, array( | ||
537 | 'empty_value' => array( | ||
538 | 'hour' => 'Empty hour', | ||
539 | 'minute' => 'Empty minute', | ||
540 | 'second' => 'Empty second', | ||
541 | ), | ||
542 | 'with_seconds' => true, | ||
543 | )); | ||
544 | |||
545 | $view = $form->createView(); | ||
546 | $this->assertSame('Empty hour', $view['hour']->vars['empty_value']); | ||
547 | $this->assertSame('Empty minute', $view['minute']->vars['empty_value']); | ||
548 | $this->assertSame('Empty second', $view['second']->vars['empty_value']); | ||
549 | } | ||
550 | |||
551 | public function testPassEmptyValueAsPartialArrayAddEmptyIfNotRequired() | ||
552 | { | ||
553 | $form = $this->factory->create('time', null, array( | ||
554 | 'required' => false, | ||
555 | 'empty_value' => array( | ||
556 | 'hour' => 'Empty hour', | ||
557 | 'second' => 'Empty second', | ||
558 | ), | ||
559 | 'with_seconds' => true, | ||
560 | )); | ||
561 | |||
562 | $view = $form->createView(); | ||
563 | $this->assertSame('Empty hour', $view['hour']->vars['empty_value']); | ||
564 | $this->assertSame('', $view['minute']->vars['empty_value']); | ||
565 | $this->assertSame('Empty second', $view['second']->vars['empty_value']); | ||
566 | } | ||
567 | |||
568 | public function testPassEmptyValueAsPartialArrayAddNullIfRequired() | ||
569 | { | ||
570 | $form = $this->factory->create('time', null, array( | ||
571 | 'required' => true, | ||
572 | 'empty_value' => array( | ||
573 | 'hour' => 'Empty hour', | ||
574 | 'second' => 'Empty second', | ||
575 | ), | ||
576 | 'with_seconds' => true, | ||
577 | )); | ||
578 | |||
579 | $view = $form->createView(); | ||
580 | $this->assertSame('Empty hour', $view['hour']->vars['empty_value']); | ||
581 | $this->assertNull($view['minute']->vars['empty_value']); | ||
582 | $this->assertSame('Empty second', $view['second']->vars['empty_value']); | ||
583 | } | ||
584 | |||
585 | public function provideCompoundWidgets() | ||
586 | { | ||
587 | return array( | ||
588 | array('text'), | ||
589 | array('choice'), | ||
590 | ); | ||
591 | } | ||
592 | |||
593 | /** | ||
594 | * @dataProvider provideCompoundWidgets | ||
595 | */ | ||
596 | public function testHourErrorsBubbleUp($widget) | ||
597 | { | ||
598 | $error = new FormError('Invalid!'); | ||
599 | $form = $this->factory->create('time', null, array( | ||
600 | 'widget' => $widget, | ||
601 | )); | ||
602 | $form['hour']->addError($error); | ||
603 | |||
604 | $this->assertSame(array(), $form['hour']->getErrors()); | ||
605 | $this->assertSame(array($error), $form->getErrors()); | ||
606 | } | ||
607 | |||
608 | /** | ||
609 | * @dataProvider provideCompoundWidgets | ||
610 | */ | ||
611 | public function testMinuteErrorsBubbleUp($widget) | ||
612 | { | ||
613 | $error = new FormError('Invalid!'); | ||
614 | $form = $this->factory->create('time', null, array( | ||
615 | 'widget' => $widget, | ||
616 | )); | ||
617 | $form['minute']->addError($error); | ||
618 | |||
619 | $this->assertSame(array(), $form['minute']->getErrors()); | ||
620 | $this->assertSame(array($error), $form->getErrors()); | ||
621 | } | ||
622 | |||
623 | /** | ||
624 | * @dataProvider provideCompoundWidgets | ||
625 | */ | ||
626 | public function testSecondErrorsBubbleUp($widget) | ||
627 | { | ||
628 | $error = new FormError('Invalid!'); | ||
629 | $form = $this->factory->create('time', null, array( | ||
630 | 'widget' => $widget, | ||
631 | 'with_seconds' => true, | ||
632 | )); | ||
633 | $form['second']->addError($error); | ||
634 | |||
635 | $this->assertSame(array(), $form['second']->getErrors()); | ||
636 | $this->assertSame(array($error), $form->getErrors()); | ||
637 | } | ||
638 | |||
639 | /** | ||
640 | * @expectedException \Symfony\Component\Form\Exception\InvalidConfigurationException | ||
641 | */ | ||
642 | public function testInitializeWithSecondsAndWithoutMinutes() | ||
643 | { | ||
644 | $this->factory->create('time', null, array( | ||
645 | 'with_minutes' => false, | ||
646 | 'with_seconds' => true, | ||
647 | )); | ||
648 | } | ||
649 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php deleted file mode 100644 index 81df20cb..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\View\ChoiceView; | ||
15 | |||
16 | class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
17 | { | ||
18 | public function testTimezonesAreSelectable() | ||
19 | { | ||
20 | $form = $this->factory->create('timezone'); | ||
21 | $view = $form->createView(); | ||
22 | $choices = $view->vars['choices']; | ||
23 | |||
24 | $this->assertArrayHasKey('Africa', $choices); | ||
25 | $this->assertContains(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Kinshasa'), $choices['Africa'], '', false, false); | ||
26 | |||
27 | $this->assertArrayHasKey('America', $choices); | ||
28 | $this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America'], '', false, false); | ||
29 | } | ||
30 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php deleted file mode 100644 index 733546e3..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase; | ||
15 | |||
16 | /** | ||
17 | * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\TypeTestCase instead. | ||
18 | */ | ||
19 | abstract class TypeTestCase extends BaseTypeTestCase | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php deleted file mode 100644 index 254b2a8e..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\Type; | ||
13 | |||
14 | class UrlTypeTest extends TypeTestCase | ||
15 | { | ||
16 | public function testSubmitAddsDefaultProtocolIfNoneIsIncluded() | ||
17 | { | ||
18 | $form = $this->factory->create('url', 'name'); | ||
19 | |||
20 | $form->submit('www.domain.com'); | ||
21 | |||
22 | $this->assertSame('http://www.domain.com', $form->getData()); | ||
23 | $this->assertSame('http://www.domain.com', $form->getViewData()); | ||
24 | } | ||
25 | |||
26 | public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded() | ||
27 | { | ||
28 | $form = $this->factory->create('url', null, array( | ||
29 | 'default_protocol' => 'http', | ||
30 | )); | ||
31 | |||
32 | $form->submit('ftp://www.domain.com'); | ||
33 | |||
34 | $this->assertSame('ftp://www.domain.com', $form->getData()); | ||
35 | $this->assertSame('ftp://www.domain.com', $form->getViewData()); | ||
36 | } | ||
37 | |||
38 | public function testSubmitAddsNoDefaultProtocolIfEmpty() | ||
39 | { | ||
40 | $form = $this->factory->create('url', null, array( | ||
41 | 'default_protocol' => 'http', | ||
42 | )); | ||
43 | |||
44 | $form->submit(''); | ||
45 | |||
46 | $this->assertNull($form->getData()); | ||
47 | $this->assertSame('', $form->getViewData()); | ||
48 | } | ||
49 | |||
50 | public function testSubmitAddsNoDefaultProtocolIfSetToNull() | ||
51 | { | ||
52 | $form = $this->factory->create('url', null, array( | ||
53 | 'default_protocol' => null, | ||
54 | )); | ||
55 | |||
56 | $form->submit('www.domain.com'); | ||
57 | |||
58 | $this->assertSame('www.domain.com', $form->getData()); | ||
59 | $this->assertSame('www.domain.com', $form->getViewData()); | ||
60 | } | ||
61 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php deleted file mode 100644 index a99b5444..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider; | ||
15 | |||
16 | /** | ||
17 | * @runTestsInSeparateProcesses | ||
18 | */ | ||
19 | class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | protected $provider; | ||
22 | |||
23 | public static function setUpBeforeClass() | ||
24 | { | ||
25 | ini_set('session.save_handler', 'files'); | ||
26 | ini_set('session.save_path', sys_get_temp_dir()); | ||
27 | } | ||
28 | |||
29 | protected function setUp() | ||
30 | { | ||
31 | $this->provider = new DefaultCsrfProvider('SECRET'); | ||
32 | } | ||
33 | |||
34 | protected function tearDown() | ||
35 | { | ||
36 | $this->provider = null; | ||
37 | } | ||
38 | |||
39 | public function testGenerateCsrfToken() | ||
40 | { | ||
41 | session_start(); | ||
42 | |||
43 | $token = $this->provider->generateCsrfToken('foo'); | ||
44 | |||
45 | $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token); | ||
46 | } | ||
47 | |||
48 | public function testGenerateCsrfTokenOnUnstartedSession() | ||
49 | { | ||
50 | session_id('touti'); | ||
51 | |||
52 | if (!version_compare(PHP_VERSION, '5.4', '>=')) { | ||
53 | $this->markTestSkipped('This test requires PHP >= 5.4'); | ||
54 | } | ||
55 | |||
56 | $this->assertSame(PHP_SESSION_NONE, session_status()); | ||
57 | |||
58 | $token = $this->provider->generateCsrfToken('foo'); | ||
59 | |||
60 | $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token); | ||
61 | $this->assertSame(PHP_SESSION_ACTIVE, session_status()); | ||
62 | } | ||
63 | |||
64 | public function testIsCsrfTokenValidSucceeds() | ||
65 | { | ||
66 | session_start(); | ||
67 | |||
68 | $token = sha1('SECRET'.'foo'.session_id()); | ||
69 | |||
70 | $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token)); | ||
71 | } | ||
72 | |||
73 | public function testIsCsrfTokenValidFails() | ||
74 | { | ||
75 | session_start(); | ||
76 | |||
77 | $token = sha1('SECRET'.'bar'.session_id()); | ||
78 | |||
79 | $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token)); | ||
80 | } | ||
81 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php deleted file mode 100644 index 1dcc6b4c..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; | ||
15 | |||
16 | class SessionCsrfProviderTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | protected $provider; | ||
19 | protected $session; | ||
20 | |||
21 | protected function setUp() | ||
22 | { | ||
23 | if (!class_exists('Symfony\Component\HttpFoundation\Session\Session')) { | ||
24 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
25 | } | ||
26 | |||
27 | $this->session = $this->getMock( | ||
28 | 'Symfony\Component\HttpFoundation\Session\Session', | ||
29 | array(), | ||
30 | array(), | ||
31 | '', | ||
32 | false // don't call constructor | ||
33 | ); | ||
34 | $this->provider = new SessionCsrfProvider($this->session, 'SECRET'); | ||
35 | } | ||
36 | |||
37 | protected function tearDown() | ||
38 | { | ||
39 | $this->provider = null; | ||
40 | $this->session = null; | ||
41 | } | ||
42 | |||
43 | public function testGenerateCsrfToken() | ||
44 | { | ||
45 | $this->session->expects($this->once()) | ||
46 | ->method('getId') | ||
47 | ->will($this->returnValue('ABCDEF')); | ||
48 | |||
49 | $token = $this->provider->generateCsrfToken('foo'); | ||
50 | |||
51 | $this->assertEquals(sha1('SECRET'.'foo'.'ABCDEF'), $token); | ||
52 | } | ||
53 | |||
54 | public function testIsCsrfTokenValidSucceeds() | ||
55 | { | ||
56 | $this->session->expects($this->once()) | ||
57 | ->method('getId') | ||
58 | ->will($this->returnValue('ABCDEF')); | ||
59 | |||
60 | $token = sha1('SECRET'.'foo'.'ABCDEF'); | ||
61 | |||
62 | $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token)); | ||
63 | } | ||
64 | |||
65 | public function testIsCsrfTokenValidFails() | ||
66 | { | ||
67 | $this->session->expects($this->once()) | ||
68 | ->method('getId') | ||
69 | ->will($this->returnValue('ABCDEF')); | ||
70 | |||
71 | $token = sha1('SECRET'.'bar'.'ABCDEF'); | ||
72 | |||
73 | $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token)); | ||
74 | } | ||
75 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php deleted file mode 100644 index 0bcfe74e..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener; | ||
17 | |||
18 | class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | protected $dispatcher; | ||
21 | protected $factory; | ||
22 | protected $csrfProvider; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
27 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
28 | } | ||
29 | |||
30 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
31 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
32 | $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); | ||
33 | $this->form = $this->getBuilder('post') | ||
34 | ->setDataMapper($this->getDataMapper()) | ||
35 | ->getForm(); | ||
36 | } | ||
37 | |||
38 | protected function tearDown() | ||
39 | { | ||
40 | $this->dispatcher = null; | ||
41 | $this->factory = null; | ||
42 | $this->csrfProvider = null; | ||
43 | $this->form = null; | ||
44 | } | ||
45 | |||
46 | protected function getBuilder($name = 'name') | ||
47 | { | ||
48 | return new FormBuilder($name, null, $this->dispatcher, $this->factory, array('compound' => true)); | ||
49 | } | ||
50 | |||
51 | protected function getForm($name = 'name') | ||
52 | { | ||
53 | return $this->getBuilder($name)->getForm(); | ||
54 | } | ||
55 | |||
56 | protected function getDataMapper() | ||
57 | { | ||
58 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
59 | } | ||
60 | |||
61 | protected function getMockForm() | ||
62 | { | ||
63 | return $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
64 | } | ||
65 | |||
66 | // https://github.com/symfony/symfony/pull/5838 | ||
67 | public function testStringFormData() | ||
68 | { | ||
69 | $data = "XP4HUzmHPi"; | ||
70 | $event = new FormEvent($this->form, $data); | ||
71 | |||
72 | $validation = new CsrfValidationListener('csrf', $this->csrfProvider, 'unknown', 'Invalid.'); | ||
73 | $validation->preSubmit($event); | ||
74 | |||
75 | // Validate accordingly | ||
76 | $this->assertSame($data, $event->getData()); | ||
77 | } | ||
78 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php deleted file mode 100644 index 0a1f0dc4..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ /dev/null | |||
@@ -1,301 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Csrf\Type; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | use Symfony\Component\Form\FormError; | ||
17 | use Symfony\Component\Form\Test\TypeTestCase; | ||
18 | use Symfony\Component\Form\Extension\Csrf\CsrfExtension; | ||
19 | |||
20 | class FormTypeCsrfExtensionTest_ChildType extends AbstractType | ||
21 | { | ||
22 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
23 | { | ||
24 | // The form needs a child in order to trigger CSRF protection by | ||
25 | // default | ||
26 | $builder->add('name', 'text'); | ||
27 | } | ||
28 | |||
29 | public function getName() | ||
30 | { | ||
31 | return 'csrf_collection_test'; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | class FormTypeCsrfExtensionTest extends TypeTestCase | ||
36 | { | ||
37 | /** | ||
38 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
39 | */ | ||
40 | protected $csrfProvider; | ||
41 | |||
42 | /** | ||
43 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
44 | */ | ||
45 | protected $translator; | ||
46 | |||
47 | protected function setUp() | ||
48 | { | ||
49 | $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); | ||
50 | $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); | ||
51 | |||
52 | parent::setUp(); | ||
53 | } | ||
54 | |||
55 | protected function tearDown() | ||
56 | { | ||
57 | $this->csrfProvider = null; | ||
58 | $this->translator = null; | ||
59 | |||
60 | parent::tearDown(); | ||
61 | } | ||
62 | |||
63 | protected function getExtensions() | ||
64 | { | ||
65 | return array_merge(parent::getExtensions(), array( | ||
66 | new CsrfExtension($this->csrfProvider, $this->translator), | ||
67 | )); | ||
68 | } | ||
69 | |||
70 | public function testCsrfProtectionByDefaultIfRootAndCompound() | ||
71 | { | ||
72 | $view = $this->factory | ||
73 | ->create('form', null, array( | ||
74 | 'csrf_field_name' => 'csrf', | ||
75 | 'compound' => true, | ||
76 | )) | ||
77 | ->createView(); | ||
78 | |||
79 | $this->assertTrue(isset($view['csrf'])); | ||
80 | } | ||
81 | |||
82 | public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot() | ||
83 | { | ||
84 | $view = $this->factory | ||
85 | ->createNamedBuilder('root', 'form') | ||
86 | ->add($this->factory | ||
87 | ->createNamedBuilder('form', 'form', null, array( | ||
88 | 'csrf_field_name' => 'csrf', | ||
89 | 'compound' => true, | ||
90 | )) | ||
91 | ) | ||
92 | ->getForm() | ||
93 | ->get('form') | ||
94 | ->createView(); | ||
95 | |||
96 | $this->assertFalse(isset($view['csrf'])); | ||
97 | } | ||
98 | |||
99 | public function testNoCsrfProtectionByDefaultIfRootButNotCompound() | ||
100 | { | ||
101 | $view = $this->factory | ||
102 | ->create('form', null, array( | ||
103 | 'csrf_field_name' => 'csrf', | ||
104 | 'compound' => false, | ||
105 | )) | ||
106 | ->createView(); | ||
107 | |||
108 | $this->assertFalse(isset($view['csrf'])); | ||
109 | } | ||
110 | |||
111 | public function testCsrfProtectionCanBeDisabled() | ||
112 | { | ||
113 | $view = $this->factory | ||
114 | ->create('form', null, array( | ||
115 | 'csrf_field_name' => 'csrf', | ||
116 | 'csrf_protection' => false, | ||
117 | 'compound' => true, | ||
118 | )) | ||
119 | ->createView(); | ||
120 | |||
121 | $this->assertFalse(isset($view['csrf'])); | ||
122 | } | ||
123 | |||
124 | public function testGenerateCsrfToken() | ||
125 | { | ||
126 | $this->csrfProvider->expects($this->once()) | ||
127 | ->method('generateCsrfToken') | ||
128 | ->with('%INTENTION%') | ||
129 | ->will($this->returnValue('token')); | ||
130 | |||
131 | $view = $this->factory | ||
132 | ->create('form', null, array( | ||
133 | 'csrf_field_name' => 'csrf', | ||
134 | 'csrf_provider' => $this->csrfProvider, | ||
135 | 'intention' => '%INTENTION%', | ||
136 | 'compound' => true, | ||
137 | )) | ||
138 | ->createView(); | ||
139 | |||
140 | $this->assertEquals('token', $view['csrf']->vars['value']); | ||
141 | } | ||
142 | |||
143 | public function provideBoolean() | ||
144 | { | ||
145 | return array( | ||
146 | array(true), | ||
147 | array(false), | ||
148 | ); | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * @dataProvider provideBoolean | ||
153 | */ | ||
154 | public function testValidateTokenOnSubmitIfRootAndCompound($valid) | ||
155 | { | ||
156 | $this->csrfProvider->expects($this->once()) | ||
157 | ->method('isCsrfTokenValid') | ||
158 | ->with('%INTENTION%', 'token') | ||
159 | ->will($this->returnValue($valid)); | ||
160 | |||
161 | $form = $this->factory | ||
162 | ->createBuilder('form', null, array( | ||
163 | 'csrf_field_name' => 'csrf', | ||
164 | 'csrf_provider' => $this->csrfProvider, | ||
165 | 'intention' => '%INTENTION%', | ||
166 | 'compound' => true, | ||
167 | )) | ||
168 | ->add('child', 'text') | ||
169 | ->getForm(); | ||
170 | |||
171 | $form->submit(array( | ||
172 | 'child' => 'foobar', | ||
173 | 'csrf' => 'token', | ||
174 | )); | ||
175 | |||
176 | // Remove token from data | ||
177 | $this->assertSame(array('child' => 'foobar'), $form->getData()); | ||
178 | |||
179 | // Validate accordingly | ||
180 | $this->assertSame($valid, $form->isValid()); | ||
181 | } | ||
182 | |||
183 | public function testFailIfRootAndCompoundAndTokenMissing() | ||
184 | { | ||
185 | $this->csrfProvider->expects($this->never()) | ||
186 | ->method('isCsrfTokenValid'); | ||
187 | |||
188 | $form = $this->factory | ||
189 | ->createBuilder('form', null, array( | ||
190 | 'csrf_field_name' => 'csrf', | ||
191 | 'csrf_provider' => $this->csrfProvider, | ||
192 | 'intention' => '%INTENTION%', | ||
193 | 'compound' => true, | ||
194 | )) | ||
195 | ->add('child', 'text') | ||
196 | ->getForm(); | ||
197 | |||
198 | $form->submit(array( | ||
199 | 'child' => 'foobar', | ||
200 | // token is missing | ||
201 | )); | ||
202 | |||
203 | // Remove token from data | ||
204 | $this->assertSame(array('child' => 'foobar'), $form->getData()); | ||
205 | |||
206 | // Validate accordingly | ||
207 | $this->assertFalse($form->isValid()); | ||
208 | } | ||
209 | |||
210 | public function testDontValidateTokenIfCompoundButNoRoot() | ||
211 | { | ||
212 | $this->csrfProvider->expects($this->never()) | ||
213 | ->method('isCsrfTokenValid'); | ||
214 | |||
215 | $form = $this->factory | ||
216 | ->createNamedBuilder('root', 'form') | ||
217 | ->add($this->factory | ||
218 | ->createNamedBuilder('form', 'form', null, array( | ||
219 | 'csrf_field_name' => 'csrf', | ||
220 | 'csrf_provider' => $this->csrfProvider, | ||
221 | 'intention' => '%INTENTION%', | ||
222 | 'compound' => true, | ||
223 | )) | ||
224 | ) | ||
225 | ->getForm() | ||
226 | ->get('form'); | ||
227 | |||
228 | $form->submit(array( | ||
229 | 'child' => 'foobar', | ||
230 | 'csrf' => 'token', | ||
231 | )); | ||
232 | } | ||
233 | |||
234 | public function testDontValidateTokenIfRootButNotCompound() | ||
235 | { | ||
236 | $this->csrfProvider->expects($this->never()) | ||
237 | ->method('isCsrfTokenValid'); | ||
238 | |||
239 | $form = $this->factory | ||
240 | ->create('form', null, array( | ||
241 | 'csrf_field_name' => 'csrf', | ||
242 | 'csrf_provider' => $this->csrfProvider, | ||
243 | 'intention' => '%INTENTION%', | ||
244 | 'compound' => false, | ||
245 | )); | ||
246 | |||
247 | $form->submit(array( | ||
248 | 'csrf' => 'token', | ||
249 | )); | ||
250 | } | ||
251 | |||
252 | public function testNoCsrfProtectionOnPrototype() | ||
253 | { | ||
254 | $prototypeView = $this->factory | ||
255 | ->create('collection', null, array( | ||
256 | 'type' => new FormTypeCsrfExtensionTest_ChildType(), | ||
257 | 'options' => array( | ||
258 | 'csrf_field_name' => 'csrf', | ||
259 | ), | ||
260 | 'prototype' => true, | ||
261 | 'allow_add' => true, | ||
262 | )) | ||
263 | ->createView() | ||
264 | ->vars['prototype']; | ||
265 | |||
266 | $this->assertFalse(isset($prototypeView['csrf'])); | ||
267 | $this->assertCount(1, $prototypeView); | ||
268 | } | ||
269 | |||
270 | public function testsTranslateCustomErrorMessage() | ||
271 | { | ||
272 | $this->csrfProvider->expects($this->once()) | ||
273 | ->method('isCsrfTokenValid') | ||
274 | ->with('%INTENTION%', 'token') | ||
275 | ->will($this->returnValue(false)); | ||
276 | |||
277 | $this->translator->expects($this->once()) | ||
278 | ->method('trans') | ||
279 | ->with('Foobar') | ||
280 | ->will($this->returnValue('[trans]Foobar[/trans]')); | ||
281 | |||
282 | $form = $this->factory | ||
283 | ->createBuilder('form', null, array( | ||
284 | 'csrf_field_name' => 'csrf', | ||
285 | 'csrf_provider' => $this->csrfProvider, | ||
286 | 'csrf_message' => 'Foobar', | ||
287 | 'intention' => '%INTENTION%', | ||
288 | 'compound' => true, | ||
289 | )) | ||
290 | ->getForm(); | ||
291 | |||
292 | $form->submit(array( | ||
293 | 'csrf' => 'token', | ||
294 | )); | ||
295 | |||
296 | $errors = $form->getErrors(); | ||
297 | |||
298 | $this->assertGreaterThan(0, count($errors)); | ||
299 | $this->assertEquals(new FormError('[trans]Foobar[/trans]'), $errors[0]); | ||
300 | } | ||
301 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php deleted file mode 100644 index 2ff072b2..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php +++ /dev/null | |||
@@ -1,286 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener; | ||
15 | use Symfony\Component\Form\Form; | ||
16 | use Symfony\Component\Form\FormConfigBuilder; | ||
17 | use Symfony\Component\Form\FormEvent; | ||
18 | use Symfony\Component\Form\Test\DeprecationErrorHandler; | ||
19 | use Symfony\Component\HttpFoundation\Request; | ||
20 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
21 | |||
22 | /** | ||
23 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
24 | */ | ||
25 | class BindRequestListenerTest extends \PHPUnit_Framework_TestCase | ||
26 | { | ||
27 | private $values; | ||
28 | |||
29 | private $filesPlain; | ||
30 | |||
31 | private $filesNested; | ||
32 | |||
33 | /** | ||
34 | * @var UploadedFile | ||
35 | */ | ||
36 | private $uploadedFile; | ||
37 | |||
38 | protected function setUp() | ||
39 | { | ||
40 | $path = tempnam(sys_get_temp_dir(), 'sf2'); | ||
41 | touch($path); | ||
42 | |||
43 | $this->values = array( | ||
44 | 'name' => 'Bernhard', | ||
45 | 'image' => array('filename' => 'foobar.png'), | ||
46 | ); | ||
47 | |||
48 | $this->filesPlain = array( | ||
49 | 'image' => array( | ||
50 | 'error' => UPLOAD_ERR_OK, | ||
51 | 'name' => 'upload.png', | ||
52 | 'size' => 123, | ||
53 | 'tmp_name' => $path, | ||
54 | 'type' => 'image/png' | ||
55 | ), | ||
56 | ); | ||
57 | |||
58 | $this->filesNested = array( | ||
59 | 'error' => array('image' => UPLOAD_ERR_OK), | ||
60 | 'name' => array('image' => 'upload.png'), | ||
61 | 'size' => array('image' => 123), | ||
62 | 'tmp_name' => array('image' => $path), | ||
63 | 'type' => array('image' => 'image/png'), | ||
64 | ); | ||
65 | |||
66 | $this->uploadedFile = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); | ||
67 | } | ||
68 | |||
69 | protected function tearDown() | ||
70 | { | ||
71 | unlink($this->uploadedFile->getRealPath()); | ||
72 | } | ||
73 | |||
74 | public function requestMethodProvider() | ||
75 | { | ||
76 | return array( | ||
77 | array('POST'), | ||
78 | array('PUT'), | ||
79 | array('DELETE'), | ||
80 | array('PATCH'), | ||
81 | ); | ||
82 | } | ||
83 | |||
84 | /** | ||
85 | * @dataProvider requestMethodProvider | ||
86 | */ | ||
87 | public function testSubmitRequest($method) | ||
88 | { | ||
89 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
90 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
91 | } | ||
92 | |||
93 | $values = array('author' => $this->values); | ||
94 | $files = array('author' => $this->filesNested); | ||
95 | $request = new Request(array(), $values, array(), array(), $files, array( | ||
96 | 'REQUEST_METHOD' => $method, | ||
97 | )); | ||
98 | |||
99 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
100 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
101 | $form = new Form($config); | ||
102 | $event = new FormEvent($form, $request); | ||
103 | |||
104 | $listener = new BindRequestListener(); | ||
105 | DeprecationErrorHandler::preBind($listener, $event); | ||
106 | |||
107 | $this->assertEquals(array( | ||
108 | 'name' => 'Bernhard', | ||
109 | 'image' => $this->uploadedFile, | ||
110 | ), $event->getData()); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * @dataProvider requestMethodProvider | ||
115 | */ | ||
116 | public function testSubmitRequestWithEmptyName($method) | ||
117 | { | ||
118 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
119 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
120 | } | ||
121 | |||
122 | $request = new Request(array(), $this->values, array(), array(), $this->filesPlain, array( | ||
123 | 'REQUEST_METHOD' => $method, | ||
124 | )); | ||
125 | |||
126 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
127 | $config = new FormConfigBuilder('', null, $dispatcher); | ||
128 | $form = new Form($config); | ||
129 | $event = new FormEvent($form, $request); | ||
130 | |||
131 | $listener = new BindRequestListener(); | ||
132 | DeprecationErrorHandler::preBind($listener, $event); | ||
133 | |||
134 | $this->assertEquals(array( | ||
135 | 'name' => 'Bernhard', | ||
136 | 'image' => $this->uploadedFile, | ||
137 | ), $event->getData()); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @dataProvider requestMethodProvider | ||
142 | */ | ||
143 | public function testSubmitEmptyRequestToCompoundForm($method) | ||
144 | { | ||
145 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
146 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
147 | } | ||
148 | |||
149 | $request = new Request(array(), array(), array(), array(), array(), array( | ||
150 | 'REQUEST_METHOD' => $method, | ||
151 | )); | ||
152 | |||
153 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
154 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
155 | $config->setCompound(true); | ||
156 | $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); | ||
157 | $form = new Form($config); | ||
158 | $event = new FormEvent($form, $request); | ||
159 | |||
160 | $listener = new BindRequestListener(); | ||
161 | DeprecationErrorHandler::preBind($listener, $event); | ||
162 | |||
163 | // Default to empty array | ||
164 | $this->assertEquals(array(), $event->getData()); | ||
165 | } | ||
166 | |||
167 | /** | ||
168 | * @dataProvider requestMethodProvider | ||
169 | */ | ||
170 | public function testSubmitEmptyRequestToSimpleForm($method) | ||
171 | { | ||
172 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
173 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
174 | } | ||
175 | |||
176 | $request = new Request(array(), array(), array(), array(), array(), array( | ||
177 | 'REQUEST_METHOD' => $method, | ||
178 | )); | ||
179 | |||
180 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
181 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
182 | $config->setCompound(false); | ||
183 | $form = new Form($config); | ||
184 | $event = new FormEvent($form, $request); | ||
185 | |||
186 | $listener = new BindRequestListener(); | ||
187 | DeprecationErrorHandler::preBind($listener, $event); | ||
188 | |||
189 | // Default to null | ||
190 | $this->assertNull($event->getData()); | ||
191 | } | ||
192 | |||
193 | public function testSubmitGetRequest() | ||
194 | { | ||
195 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
196 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
197 | } | ||
198 | |||
199 | $values = array('author' => $this->values); | ||
200 | $request = new Request($values, array(), array(), array(), array(), array( | ||
201 | 'REQUEST_METHOD' => 'GET', | ||
202 | )); | ||
203 | |||
204 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
205 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
206 | $form = new Form($config); | ||
207 | $event = new FormEvent($form, $request); | ||
208 | |||
209 | $listener = new BindRequestListener(); | ||
210 | DeprecationErrorHandler::preBind($listener, $event); | ||
211 | |||
212 | $this->assertEquals(array( | ||
213 | 'name' => 'Bernhard', | ||
214 | 'image' => array('filename' => 'foobar.png'), | ||
215 | ), $event->getData()); | ||
216 | } | ||
217 | |||
218 | public function testSubmitGetRequestWithEmptyName() | ||
219 | { | ||
220 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
221 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
222 | } | ||
223 | |||
224 | $request = new Request($this->values, array(), array(), array(), array(), array( | ||
225 | 'REQUEST_METHOD' => 'GET', | ||
226 | )); | ||
227 | |||
228 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
229 | $config = new FormConfigBuilder('', null, $dispatcher); | ||
230 | $form = new Form($config); | ||
231 | $event = new FormEvent($form, $request); | ||
232 | |||
233 | $listener = new BindRequestListener(); | ||
234 | DeprecationErrorHandler::preBind($listener, $event); | ||
235 | |||
236 | $this->assertEquals(array( | ||
237 | 'name' => 'Bernhard', | ||
238 | 'image' => array('filename' => 'foobar.png'), | ||
239 | ), $event->getData()); | ||
240 | } | ||
241 | |||
242 | public function testSubmitEmptyGetRequestToCompoundForm() | ||
243 | { | ||
244 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
245 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
246 | } | ||
247 | |||
248 | $request = new Request(array(), array(), array(), array(), array(), array( | ||
249 | 'REQUEST_METHOD' => 'GET', | ||
250 | )); | ||
251 | |||
252 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
253 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
254 | $config->setCompound(true); | ||
255 | $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); | ||
256 | $form = new Form($config); | ||
257 | $event = new FormEvent($form, $request); | ||
258 | |||
259 | $listener = new BindRequestListener(); | ||
260 | DeprecationErrorHandler::preBind($listener, $event); | ||
261 | |||
262 | $this->assertEquals(array(), $event->getData()); | ||
263 | } | ||
264 | |||
265 | public function testSubmitEmptyGetRequestToSimpleForm() | ||
266 | { | ||
267 | if (!class_exists('Symfony\Component\HttpFoundation\Request')) { | ||
268 | $this->markTestSkipped('The "HttpFoundation" component is not available'); | ||
269 | } | ||
270 | |||
271 | $request = new Request(array(), array(), array(), array(), array(), array( | ||
272 | 'REQUEST_METHOD' => 'GET', | ||
273 | )); | ||
274 | |||
275 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
276 | $config = new FormConfigBuilder('author', null, $dispatcher); | ||
277 | $config->setCompound(false); | ||
278 | $form = new Form($config); | ||
279 | $event = new FormEvent($form, $request); | ||
280 | |||
281 | $listener = new BindRequestListener(); | ||
282 | DeprecationErrorHandler::preBind($listener, $event); | ||
283 | |||
284 | $this->assertNull($event->getData()); | ||
285 | } | ||
286 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php deleted file mode 100644 index 2d5cf776..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\HttpFoundation; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; | ||
15 | use Symfony\Component\Form\Tests\AbstractRequestHandlerTest; | ||
16 | use Symfony\Component\HttpFoundation\Request; | ||
17 | |||
18 | /** | ||
19 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
20 | */ | ||
21 | class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest | ||
22 | { | ||
23 | /** | ||
24 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
25 | */ | ||
26 | public function testRequestShouldNotBeNull() | ||
27 | { | ||
28 | $this->requestHandler->handleRequest($this->getMockForm('name', 'GET')); | ||
29 | } | ||
30 | /** | ||
31 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
32 | */ | ||
33 | public function testRequestShouldBeInstanceOfRequest() | ||
34 | { | ||
35 | $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), new \stdClass()); | ||
36 | } | ||
37 | |||
38 | protected function setRequestData($method, $data, $files = array()) | ||
39 | { | ||
40 | $this->request = Request::create('http://localhost', $method, $data, array(), $files); | ||
41 | } | ||
42 | |||
43 | protected function getRequestHandler() | ||
44 | { | ||
45 | return new HttpFoundationRequestHandler(); | ||
46 | } | ||
47 | |||
48 | protected function getMockFile() | ||
49 | { | ||
50 | return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') | ||
51 | ->disableOriginalConstructor() | ||
52 | ->getMock(); | ||
53 | } | ||
54 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php deleted file mode 100644 index a8bdde8a..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ /dev/null | |||
@@ -1,748 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | use Symfony\Component\Form\Exception\TransformationFailedException; | ||
16 | use Symfony\Component\Form\CallbackTransformer; | ||
17 | use Symfony\Component\Form\FormInterface; | ||
18 | use Symfony\Component\Form\Extension\Validator\Constraints\Form; | ||
19 | use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; | ||
20 | use Symfony\Component\Form\SubmitButtonBuilder; | ||
21 | use Symfony\Component\Validator\Constraint; | ||
22 | use Symfony\Component\Validator\Constraints\NotNull; | ||
23 | use Symfony\Component\Validator\Constraints\NotBlank; | ||
24 | |||
25 | /** | ||
26 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
27 | */ | ||
28 | class FormValidatorTest extends \PHPUnit_Framework_TestCase | ||
29 | { | ||
30 | /** | ||
31 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
32 | */ | ||
33 | private $dispatcher; | ||
34 | |||
35 | /** | ||
36 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
37 | */ | ||
38 | private $factory; | ||
39 | |||
40 | /** | ||
41 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
42 | */ | ||
43 | private $serverParams; | ||
44 | |||
45 | /** | ||
46 | * @var FormValidator | ||
47 | */ | ||
48 | private $validator; | ||
49 | |||
50 | protected function setUp() | ||
51 | { | ||
52 | if (!class_exists('Symfony\Component\EventDispatcher\Event')) { | ||
53 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
54 | } | ||
55 | |||
56 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
57 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
58 | $this->serverParams = $this->getMock( | ||
59 | 'Symfony\Component\Form\Extension\Validator\Util\ServerParams', | ||
60 | array('getNormalizedIniPostMaxSize', 'getContentLength') | ||
61 | ); | ||
62 | $this->validator = new FormValidator($this->serverParams); | ||
63 | } | ||
64 | |||
65 | public function testValidate() | ||
66 | { | ||
67 | $context = $this->getMockExecutionContext(); | ||
68 | $object = $this->getMock('\stdClass'); | ||
69 | $options = array('validation_groups' => array('group1', 'group2')); | ||
70 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
71 | ->setData($object) | ||
72 | ->getForm(); | ||
73 | |||
74 | $context->expects($this->at(0)) | ||
75 | ->method('validate') | ||
76 | ->with($object, 'data', 'group1', true); | ||
77 | $context->expects($this->at(1)) | ||
78 | ->method('validate') | ||
79 | ->with($object, 'data', 'group2', true); | ||
80 | |||
81 | $this->validator->initialize($context); | ||
82 | $this->validator->validate($form, new Form()); | ||
83 | } | ||
84 | |||
85 | public function testValidateConstraints() | ||
86 | { | ||
87 | $context = $this->getMockExecutionContext(); | ||
88 | $object = $this->getMock('\stdClass'); | ||
89 | $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); | ||
90 | $constraint2 = new NotBlank(array('groups' => 'group2')); | ||
91 | |||
92 | $options = array( | ||
93 | 'validation_groups' => array('group1', 'group2'), | ||
94 | 'constraints' => array($constraint1, $constraint2), | ||
95 | ); | ||
96 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
97 | ->setData($object) | ||
98 | ->getForm(); | ||
99 | |||
100 | // First default constraints | ||
101 | $context->expects($this->at(0)) | ||
102 | ->method('validate') | ||
103 | ->with($object, 'data', 'group1', true); | ||
104 | $context->expects($this->at(1)) | ||
105 | ->method('validate') | ||
106 | ->with($object, 'data', 'group2', true); | ||
107 | |||
108 | // Then custom constraints | ||
109 | $context->expects($this->at(2)) | ||
110 | ->method('validateValue') | ||
111 | ->with($object, $constraint1, 'data', 'group1'); | ||
112 | $context->expects($this->at(3)) | ||
113 | ->method('validateValue') | ||
114 | ->with($object, $constraint2, 'data', 'group2'); | ||
115 | |||
116 | $this->validator->initialize($context); | ||
117 | $this->validator->validate($form, new Form()); | ||
118 | } | ||
119 | |||
120 | public function testDontValidateIfParentWithoutCascadeValidation() | ||
121 | { | ||
122 | $context = $this->getMockExecutionContext(); | ||
123 | $object = $this->getMock('\stdClass'); | ||
124 | |||
125 | $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) | ||
126 | ->setCompound(true) | ||
127 | ->setDataMapper($this->getDataMapper()) | ||
128 | ->getForm(); | ||
129 | $options = array('validation_groups' => array('group1', 'group2')); | ||
130 | $form = $this->getBuilder('name', '\stdClass', $options)->getForm(); | ||
131 | $parent->add($form); | ||
132 | |||
133 | $form->setData($object); | ||
134 | |||
135 | $context->expects($this->never()) | ||
136 | ->method('validate'); | ||
137 | |||
138 | $this->validator->initialize($context); | ||
139 | $this->validator->validate($form, new Form()); | ||
140 | } | ||
141 | |||
142 | public function testValidateConstraintsEvenIfNoCascadeValidation() | ||
143 | { | ||
144 | $context = $this->getMockExecutionContext(); | ||
145 | $object = $this->getMock('\stdClass'); | ||
146 | $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); | ||
147 | $constraint2 = new NotBlank(array('groups' => 'group2')); | ||
148 | |||
149 | $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) | ||
150 | ->setCompound(true) | ||
151 | ->setDataMapper($this->getDataMapper()) | ||
152 | ->getForm(); | ||
153 | $options = array( | ||
154 | 'validation_groups' => array('group1', 'group2'), | ||
155 | 'constraints' => array($constraint1, $constraint2), | ||
156 | ); | ||
157 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
158 | ->setData($object) | ||
159 | ->getForm(); | ||
160 | $parent->add($form); | ||
161 | |||
162 | $context->expects($this->at(0)) | ||
163 | ->method('validateValue') | ||
164 | ->with($object, $constraint1, 'data', 'group1'); | ||
165 | $context->expects($this->at(1)) | ||
166 | ->method('validateValue') | ||
167 | ->with($object, $constraint2, 'data', 'group2'); | ||
168 | |||
169 | $this->validator->initialize($context); | ||
170 | $this->validator->validate($form, new Form()); | ||
171 | } | ||
172 | |||
173 | public function testDontValidateIfNoValidationGroups() | ||
174 | { | ||
175 | $context = $this->getMockExecutionContext(); | ||
176 | $object = $this->getMock('\stdClass'); | ||
177 | |||
178 | $form = $this->getBuilder('name', '\stdClass', array( | ||
179 | 'validation_groups' => array(), | ||
180 | )) | ||
181 | ->setData($object) | ||
182 | ->getForm(); | ||
183 | |||
184 | $form->setData($object); | ||
185 | |||
186 | $context->expects($this->never()) | ||
187 | ->method('validate'); | ||
188 | |||
189 | $this->validator->initialize($context); | ||
190 | $this->validator->validate($form, new Form()); | ||
191 | } | ||
192 | |||
193 | public function testDontValidateConstraintsIfNoValidationGroups() | ||
194 | { | ||
195 | $context = $this->getMockExecutionContext(); | ||
196 | $object = $this->getMock('\stdClass'); | ||
197 | $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); | ||
198 | $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); | ||
199 | |||
200 | $options = array( | ||
201 | 'validation_groups' => array(), | ||
202 | 'constraints' => array($constraint1, $constraint2), | ||
203 | ); | ||
204 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
205 | ->setData($object) | ||
206 | ->getForm(); | ||
207 | |||
208 | // Launch transformer | ||
209 | $form->submit(array()); | ||
210 | |||
211 | $context->expects($this->never()) | ||
212 | ->method('validate'); | ||
213 | |||
214 | $this->validator->initialize($context); | ||
215 | $this->validator->validate($form, new Form()); | ||
216 | } | ||
217 | |||
218 | public function testDontValidateIfNotSynchronized() | ||
219 | { | ||
220 | $context = $this->getMockExecutionContext(); | ||
221 | $object = $this->getMock('\stdClass'); | ||
222 | |||
223 | $form = $this->getBuilder('name', '\stdClass', array( | ||
224 | 'invalid_message' => 'invalid_message_key', | ||
225 | // Invalid message parameters must be supported, because the | ||
226 | // invalid message can be a translation key | ||
227 | // see https://github.com/symfony/symfony/issues/5144 | ||
228 | 'invalid_message_parameters' => array('{{ foo }}' => 'bar'), | ||
229 | )) | ||
230 | ->setData($object) | ||
231 | ->addViewTransformer(new CallbackTransformer( | ||
232 | function ($data) { return $data; }, | ||
233 | function () { throw new TransformationFailedException(); } | ||
234 | )) | ||
235 | ->getForm(); | ||
236 | |||
237 | // Launch transformer | ||
238 | $form->submit('foo'); | ||
239 | |||
240 | $context->expects($this->never()) | ||
241 | ->method('validate'); | ||
242 | |||
243 | $context->expects($this->once()) | ||
244 | ->method('addViolation') | ||
245 | ->with( | ||
246 | 'invalid_message_key', | ||
247 | array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'), | ||
248 | 'foo' | ||
249 | ); | ||
250 | $context->expects($this->never()) | ||
251 | ->method('addViolationAt'); | ||
252 | |||
253 | $this->validator->initialize($context); | ||
254 | $this->validator->validate($form, new Form()); | ||
255 | } | ||
256 | |||
257 | public function testAddInvalidErrorEvenIfNoValidationGroups() | ||
258 | { | ||
259 | $context = $this->getMockExecutionContext(); | ||
260 | $object = $this->getMock('\stdClass'); | ||
261 | |||
262 | $form = $this->getBuilder('name', '\stdClass', array( | ||
263 | 'invalid_message' => 'invalid_message_key', | ||
264 | // Invalid message parameters must be supported, because the | ||
265 | // invalid message can be a translation key | ||
266 | // see https://github.com/symfony/symfony/issues/5144 | ||
267 | 'invalid_message_parameters' => array('{{ foo }}' => 'bar'), | ||
268 | 'validation_groups' => array(), | ||
269 | )) | ||
270 | ->setData($object) | ||
271 | ->addViewTransformer(new CallbackTransformer( | ||
272 | function ($data) { return $data; }, | ||
273 | function () { throw new TransformationFailedException(); } | ||
274 | )) | ||
275 | ->getForm(); | ||
276 | |||
277 | // Launch transformer | ||
278 | $form->submit('foo'); | ||
279 | |||
280 | $context->expects($this->never()) | ||
281 | ->method('validate'); | ||
282 | |||
283 | $context->expects($this->once()) | ||
284 | ->method('addViolation') | ||
285 | ->with( | ||
286 | 'invalid_message_key', | ||
287 | array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'), | ||
288 | 'foo' | ||
289 | ); | ||
290 | $context->expects($this->never()) | ||
291 | ->method('addViolationAt'); | ||
292 | |||
293 | $this->validator->initialize($context); | ||
294 | $this->validator->validate($form, new Form()); | ||
295 | } | ||
296 | |||
297 | public function testDontValidateConstraintsIfNotSynchronized() | ||
298 | { | ||
299 | $context = $this->getMockExecutionContext(); | ||
300 | $object = $this->getMock('\stdClass'); | ||
301 | $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); | ||
302 | $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); | ||
303 | |||
304 | $options = array( | ||
305 | 'validation_groups' => array('group1', 'group2'), | ||
306 | 'constraints' => array($constraint1, $constraint2), | ||
307 | ); | ||
308 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
309 | ->setData($object) | ||
310 | ->addViewTransformer(new CallbackTransformer( | ||
311 | function ($data) { return $data; }, | ||
312 | function () { throw new TransformationFailedException(); } | ||
313 | )) | ||
314 | ->getForm(); | ||
315 | |||
316 | // Launch transformer | ||
317 | $form->submit(array()); | ||
318 | |||
319 | $context->expects($this->never()) | ||
320 | ->method('validate'); | ||
321 | |||
322 | $this->validator->initialize($context); | ||
323 | $this->validator->validate($form, new Form()); | ||
324 | } | ||
325 | |||
326 | // https://github.com/symfony/symfony/issues/4359 | ||
327 | public function testDontMarkInvalidIfAnyChildIsNotSynchronized() | ||
328 | { | ||
329 | $context = $this->getMockExecutionContext(); | ||
330 | $object = $this->getMock('\stdClass'); | ||
331 | |||
332 | $failingTransformer = new CallbackTransformer( | ||
333 | function ($data) { return $data; }, | ||
334 | function () { throw new TransformationFailedException(); } | ||
335 | ); | ||
336 | |||
337 | $form = $this->getBuilder('name', '\stdClass') | ||
338 | ->setData($object) | ||
339 | ->addViewTransformer($failingTransformer) | ||
340 | ->setCompound(true) | ||
341 | ->setDataMapper($this->getDataMapper()) | ||
342 | ->add( | ||
343 | $this->getBuilder('child') | ||
344 | ->addViewTransformer($failingTransformer) | ||
345 | ) | ||
346 | ->getForm(); | ||
347 | |||
348 | // Launch transformer | ||
349 | $form->submit(array('child' => 'foo')); | ||
350 | |||
351 | $context->expects($this->never()) | ||
352 | ->method('addViolation'); | ||
353 | $context->expects($this->never()) | ||
354 | ->method('addViolationAt'); | ||
355 | |||
356 | $this->validator->initialize($context); | ||
357 | $this->validator->validate($form, new Form()); | ||
358 | } | ||
359 | |||
360 | public function testHandleCallbackValidationGroups() | ||
361 | { | ||
362 | $context = $this->getMockExecutionContext(); | ||
363 | $object = $this->getMock('\stdClass'); | ||
364 | $options = array('validation_groups' => array($this, 'getValidationGroups')); | ||
365 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
366 | ->setData($object) | ||
367 | ->getForm(); | ||
368 | |||
369 | $context->expects($this->at(0)) | ||
370 | ->method('validate') | ||
371 | ->with($object, 'data', 'group1', true); | ||
372 | $context->expects($this->at(1)) | ||
373 | ->method('validate') | ||
374 | ->with($object, 'data', 'group2', true); | ||
375 | |||
376 | $this->validator->initialize($context); | ||
377 | $this->validator->validate($form, new Form()); | ||
378 | } | ||
379 | |||
380 | public function testDontExecuteFunctionNames() | ||
381 | { | ||
382 | $context = $this->getMockExecutionContext(); | ||
383 | $object = $this->getMock('\stdClass'); | ||
384 | $options = array('validation_groups' => 'header'); | ||
385 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
386 | ->setData($object) | ||
387 | ->getForm(); | ||
388 | |||
389 | $context->expects($this->once()) | ||
390 | ->method('validate') | ||
391 | ->with($object, 'data', 'header', true); | ||
392 | |||
393 | $this->validator->initialize($context); | ||
394 | $this->validator->validate($form, new Form()); | ||
395 | } | ||
396 | |||
397 | public function testHandleClosureValidationGroups() | ||
398 | { | ||
399 | $context = $this->getMockExecutionContext(); | ||
400 | $object = $this->getMock('\stdClass'); | ||
401 | $options = array('validation_groups' => function(FormInterface $form){ | ||
402 | return array('group1', 'group2'); | ||
403 | }); | ||
404 | $form = $this->getBuilder('name', '\stdClass', $options) | ||
405 | ->setData($object) | ||
406 | ->getForm(); | ||
407 | |||
408 | $context->expects($this->at(0)) | ||
409 | ->method('validate') | ||
410 | ->with($object, 'data', 'group1', true); | ||
411 | $context->expects($this->at(1)) | ||
412 | ->method('validate') | ||
413 | ->with($object, 'data', 'group2', true); | ||
414 | |||
415 | $this->validator->initialize($context); | ||
416 | $this->validator->validate($form, new Form()); | ||
417 | } | ||
418 | |||
419 | public function testUseValidationGroupOfClickedButton() | ||
420 | { | ||
421 | $context = $this->getMockExecutionContext(); | ||
422 | $object = $this->getMock('\stdClass'); | ||
423 | |||
424 | $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) | ||
425 | ->setCompound(true) | ||
426 | ->setDataMapper($this->getDataMapper()) | ||
427 | ->getForm(); | ||
428 | $form = $this->getForm('name', '\stdClass', array( | ||
429 | 'validation_groups' => 'form_group', | ||
430 | )); | ||
431 | |||
432 | $parent->add($form); | ||
433 | $parent->add($this->getClickedSubmitButton('submit', array( | ||
434 | 'validation_groups' => 'button_group', | ||
435 | ))); | ||
436 | |||
437 | $form->setData($object); | ||
438 | |||
439 | $context->expects($this->once()) | ||
440 | ->method('validate') | ||
441 | ->with($object, 'data', 'button_group', true); | ||
442 | |||
443 | $this->validator->initialize($context); | ||
444 | $this->validator->validate($form, new Form()); | ||
445 | } | ||
446 | |||
447 | public function testDontUseValidationGroupOfUnclickedButton() | ||
448 | { | ||
449 | $context = $this->getMockExecutionContext(); | ||
450 | $object = $this->getMock('\stdClass'); | ||
451 | |||
452 | $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) | ||
453 | ->setCompound(true) | ||
454 | ->setDataMapper($this->getDataMapper()) | ||
455 | ->getForm(); | ||
456 | $form = $this->getForm('name', '\stdClass', array( | ||
457 | 'validation_groups' => 'form_group', | ||
458 | )); | ||
459 | |||
460 | $parent->add($form); | ||
461 | $parent->add($this->getSubmitButton('submit', array( | ||
462 | 'validation_groups' => 'button_group', | ||
463 | ))); | ||
464 | |||
465 | $form->setData($object); | ||
466 | |||
467 | $context->expects($this->once()) | ||
468 | ->method('validate') | ||
469 | ->with($object, 'data', 'form_group', true); | ||
470 | |||
471 | $this->validator->initialize($context); | ||
472 | $this->validator->validate($form, new Form()); | ||
473 | } | ||
474 | |||
475 | public function testUseInheritedValidationGroup() | ||
476 | { | ||
477 | $context = $this->getMockExecutionContext(); | ||
478 | $object = $this->getMock('\stdClass'); | ||
479 | |||
480 | $parentOptions = array( | ||
481 | 'validation_groups' => 'group', | ||
482 | 'cascade_validation' => true, | ||
483 | ); | ||
484 | $parent = $this->getBuilder('parent', null, $parentOptions) | ||
485 | ->setCompound(true) | ||
486 | ->setDataMapper($this->getDataMapper()) | ||
487 | ->getForm(); | ||
488 | $form = $this->getBuilder('name', '\stdClass')->getForm(); | ||
489 | $parent->add($form); | ||
490 | |||
491 | $form->setData($object); | ||
492 | |||
493 | $context->expects($this->once()) | ||
494 | ->method('validate') | ||
495 | ->with($object, 'data', 'group', true); | ||
496 | |||
497 | $this->validator->initialize($context); | ||
498 | $this->validator->validate($form, new Form()); | ||
499 | } | ||
500 | |||
501 | public function testUseInheritedCallbackValidationGroup() | ||
502 | { | ||
503 | $context = $this->getMockExecutionContext(); | ||
504 | $object = $this->getMock('\stdClass'); | ||
505 | |||
506 | $parentOptions = array( | ||
507 | 'validation_groups' => array($this, 'getValidationGroups'), | ||
508 | 'cascade_validation' => true, | ||
509 | ); | ||
510 | $parent = $this->getBuilder('parent', null, $parentOptions) | ||
511 | ->setCompound(true) | ||
512 | ->setDataMapper($this->getDataMapper()) | ||
513 | ->getForm(); | ||
514 | $form = $this->getBuilder('name', '\stdClass')->getForm(); | ||
515 | $parent->add($form); | ||
516 | |||
517 | $form->setData($object); | ||
518 | |||
519 | $context->expects($this->at(0)) | ||
520 | ->method('validate') | ||
521 | ->with($object, 'data', 'group1', true); | ||
522 | $context->expects($this->at(1)) | ||
523 | ->method('validate') | ||
524 | ->with($object, 'data', 'group2', true); | ||
525 | |||
526 | $this->validator->initialize($context); | ||
527 | $this->validator->validate($form, new Form()); | ||
528 | } | ||
529 | |||
530 | public function testUseInheritedClosureValidationGroup() | ||
531 | { | ||
532 | $context = $this->getMockExecutionContext(); | ||
533 | $object = $this->getMock('\stdClass'); | ||
534 | |||
535 | $parentOptions = array( | ||
536 | 'validation_groups' => function(FormInterface $form){ | ||
537 | return array('group1', 'group2'); | ||
538 | }, | ||
539 | 'cascade_validation' => true, | ||
540 | ); | ||
541 | $parent = $this->getBuilder('parent', null, $parentOptions) | ||
542 | ->setCompound(true) | ||
543 | ->setDataMapper($this->getDataMapper()) | ||
544 | ->getForm(); | ||
545 | $form = $this->getBuilder('name', '\stdClass')->getForm(); | ||
546 | $parent->add($form); | ||
547 | |||
548 | $form->setData($object); | ||
549 | |||
550 | $context->expects($this->at(0)) | ||
551 | ->method('validate') | ||
552 | ->with($object, 'data', 'group1', true); | ||
553 | $context->expects($this->at(1)) | ||
554 | ->method('validate') | ||
555 | ->with($object, 'data', 'group2', true); | ||
556 | |||
557 | $this->validator->initialize($context); | ||
558 | $this->validator->validate($form, new Form()); | ||
559 | } | ||
560 | |||
561 | public function testAppendPropertyPath() | ||
562 | { | ||
563 | $context = $this->getMockExecutionContext(); | ||
564 | $object = $this->getMock('\stdClass'); | ||
565 | $form = $this->getBuilder('name', '\stdClass') | ||
566 | ->setData($object) | ||
567 | ->getForm(); | ||
568 | |||
569 | $context->expects($this->once()) | ||
570 | ->method('validate') | ||
571 | ->with($object, 'data', 'Default', true); | ||
572 | |||
573 | $this->validator->initialize($context); | ||
574 | $this->validator->validate($form, new Form()); | ||
575 | } | ||
576 | |||
577 | public function testDontWalkScalars() | ||
578 | { | ||
579 | $context = $this->getMockExecutionContext(); | ||
580 | |||
581 | $form = $this->getBuilder() | ||
582 | ->setData('scalar') | ||
583 | ->getForm(); | ||
584 | |||
585 | $context->expects($this->never()) | ||
586 | ->method('validate'); | ||
587 | |||
588 | $this->validator->initialize($context); | ||
589 | $this->validator->validate($form, new Form()); | ||
590 | } | ||
591 | |||
592 | public function testViolationIfExtraData() | ||
593 | { | ||
594 | $context = $this->getMockExecutionContext(); | ||
595 | |||
596 | $form = $this->getBuilder('parent', null, array('extra_fields_message' => 'Extra!')) | ||
597 | ->setCompound(true) | ||
598 | ->setDataMapper($this->getDataMapper()) | ||
599 | ->add($this->getBuilder('child')) | ||
600 | ->getForm(); | ||
601 | |||
602 | $form->submit(array('foo' => 'bar')); | ||
603 | |||
604 | $context->expects($this->once()) | ||
605 | ->method('addViolation') | ||
606 | ->with( | ||
607 | 'Extra!', | ||
608 | array('{{ extra_fields }}' => 'foo'), | ||
609 | array('foo' => 'bar') | ||
610 | ); | ||
611 | $context->expects($this->never()) | ||
612 | ->method('addViolationAt'); | ||
613 | |||
614 | $this->validator->initialize($context); | ||
615 | $this->validator->validate($form, new Form()); | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * @dataProvider getPostMaxSizeFixtures | ||
620 | */ | ||
621 | public function testPostMaxSizeViolation($contentLength, $iniMax, $nbViolation, array $params = array()) | ||
622 | { | ||
623 | $this->serverParams->expects($this->once()) | ||
624 | ->method('getContentLength') | ||
625 | ->will($this->returnValue($contentLength)); | ||
626 | $this->serverParams->expects($this->any()) | ||
627 | ->method('getNormalizedIniPostMaxSize') | ||
628 | ->will($this->returnValue($iniMax)); | ||
629 | |||
630 | $context = $this->getMockExecutionContext(); | ||
631 | $options = array('post_max_size_message' => 'Max {{ max }}!'); | ||
632 | $form = $this->getBuilder('name', null, $options)->getForm(); | ||
633 | |||
634 | for ($i = 0; $i < $nbViolation; ++$i) { | ||
635 | if (0 === $i && count($params) > 0) { | ||
636 | $context->expects($this->at($i)) | ||
637 | ->method('addViolation') | ||
638 | ->with($options['post_max_size_message'], $params); | ||
639 | } else { | ||
640 | $context->expects($this->at($i)) | ||
641 | ->method('addViolation'); | ||
642 | } | ||
643 | } | ||
644 | |||
645 | $context->expects($this->never()) | ||
646 | ->method('addViolationAt'); | ||
647 | |||
648 | $this->validator->initialize($context); | ||
649 | $this->validator->validate($form, new Form()); | ||
650 | } | ||
651 | |||
652 | public function getPostMaxSizeFixtures() | ||
653 | { | ||
654 | return array( | ||
655 | array(pow(1024, 3) + 1, '1G', 1, array('{{ max }}' => '1G')), | ||
656 | array(pow(1024, 3), '1G', 0), | ||
657 | array(pow(1024, 2) + 1, '1M', 1, array('{{ max }}' => '1M')), | ||
658 | array(pow(1024, 2), '1M', 0), | ||
659 | array(1024 + 1, '1K', 1, array('{{ max }}' => '1K')), | ||
660 | array(1024, '1K', 0), | ||
661 | array(null, '1K', 0), | ||
662 | array(1024, '', 0), | ||
663 | array(1024, 0, 0), | ||
664 | ); | ||
665 | } | ||
666 | |||
667 | public function testNoViolationIfNotRoot() | ||
668 | { | ||
669 | $this->serverParams->expects($this->once()) | ||
670 | ->method('getContentLength') | ||
671 | ->will($this->returnValue(1025)); | ||
672 | $this->serverParams->expects($this->never()) | ||
673 | ->method('getNormalizedIniPostMaxSize'); | ||
674 | |||
675 | $context = $this->getMockExecutionContext(); | ||
676 | $parent = $this->getBuilder() | ||
677 | ->setCompound(true) | ||
678 | ->setDataMapper($this->getDataMapper()) | ||
679 | ->getForm(); | ||
680 | $form = $this->getForm(); | ||
681 | $parent->add($form); | ||
682 | |||
683 | $context->expects($this->never()) | ||
684 | ->method('addViolation'); | ||
685 | $context->expects($this->never()) | ||
686 | ->method('addViolationAt'); | ||
687 | |||
688 | $this->validator->initialize($context); | ||
689 | $this->validator->validate($form, new Form()); | ||
690 | } | ||
691 | |||
692 | /** | ||
693 | * Access has to be public, as this method is called via callback array | ||
694 | * in {@link testValidateFormDataCanHandleCallbackValidationGroups()} | ||
695 | * and {@link testValidateFormDataUsesInheritedCallbackValidationGroup()} | ||
696 | */ | ||
697 | public function getValidationGroups(FormInterface $form) | ||
698 | { | ||
699 | return array('group1', 'group2'); | ||
700 | } | ||
701 | |||
702 | private function getMockExecutionContext() | ||
703 | { | ||
704 | return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface'); | ||
705 | } | ||
706 | |||
707 | /** | ||
708 | * @param string $name | ||
709 | * @param string $dataClass | ||
710 | * @param array $options | ||
711 | * | ||
712 | * @return FormBuilder | ||
713 | */ | ||
714 | private function getBuilder($name = 'name', $dataClass = null, array $options = array()) | ||
715 | { | ||
716 | $options = array_replace(array( | ||
717 | 'constraints' => array(), | ||
718 | 'invalid_message_parameters' => array(), | ||
719 | ), $options); | ||
720 | |||
721 | return new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory, $options); | ||
722 | } | ||
723 | |||
724 | private function getForm($name = 'name', $dataClass = null, array $options = array()) | ||
725 | { | ||
726 | return $this->getBuilder($name, $dataClass, $options)->getForm(); | ||
727 | } | ||
728 | |||
729 | private function getSubmitButton($name = 'name', array $options = array()) | ||
730 | { | ||
731 | $builder = new SubmitButtonBuilder($name, $options); | ||
732 | |||
733 | return $builder->getForm(); | ||
734 | } | ||
735 | |||
736 | private function getClickedSubmitButton($name = 'name', array $options = array()) | ||
737 | { | ||
738 | return $this->getSubmitButton($name, $options)->submit(''); | ||
739 | } | ||
740 | |||
741 | /** | ||
742 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
743 | */ | ||
744 | private function getDataMapper() | ||
745 | { | ||
746 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
747 | } | ||
748 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php deleted file mode 100644 index 528f9463..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ /dev/null | |||
@@ -1,145 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\Form\Extension\Validator\Constraints\Form; | ||
17 | use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener; | ||
18 | use Symfony\Component\PropertyAccess\PropertyPath; | ||
19 | use Symfony\Component\Validator\ConstraintViolation; | ||
20 | |||
21 | class ValidationListenerTest extends \PHPUnit_Framework_TestCase | ||
22 | { | ||
23 | /** | ||
24 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
25 | */ | ||
26 | private $dispatcher; | ||
27 | |||
28 | /** | ||
29 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
30 | */ | ||
31 | private $factory; | ||
32 | |||
33 | /** | ||
34 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
35 | */ | ||
36 | private $validator; | ||
37 | |||
38 | /** | ||
39 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
40 | */ | ||
41 | private $violationMapper; | ||
42 | |||
43 | /** | ||
44 | * @var ValidationListener | ||
45 | */ | ||
46 | private $listener; | ||
47 | |||
48 | private $message; | ||
49 | |||
50 | private $messageTemplate; | ||
51 | |||
52 | private $params; | ||
53 | |||
54 | protected function setUp() | ||
55 | { | ||
56 | if (!class_exists('Symfony\Component\EventDispatcher\Event')) { | ||
57 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
58 | } | ||
59 | |||
60 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
61 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
62 | $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); | ||
63 | $this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface'); | ||
64 | $this->listener = new ValidationListener($this->validator, $this->violationMapper); | ||
65 | $this->message = 'Message'; | ||
66 | $this->messageTemplate = 'Message template'; | ||
67 | $this->params = array('foo' => 'bar'); | ||
68 | } | ||
69 | |||
70 | private function getConstraintViolation($code = null) | ||
71 | { | ||
72 | return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, 'prop.path', null, null, $code); | ||
73 | } | ||
74 | |||
75 | private function getBuilder($name = 'name', $propertyPath = null, $dataClass = null) | ||
76 | { | ||
77 | $builder = new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory); | ||
78 | $builder->setPropertyPath(new PropertyPath($propertyPath ?: $name)); | ||
79 | $builder->setAttribute('error_mapping', array()); | ||
80 | $builder->setErrorBubbling(false); | ||
81 | $builder->setMapped(true); | ||
82 | |||
83 | return $builder; | ||
84 | } | ||
85 | |||
86 | private function getForm($name = 'name', $propertyPath = null, $dataClass = null) | ||
87 | { | ||
88 | return $this->getBuilder($name, $propertyPath, $dataClass)->getForm(); | ||
89 | } | ||
90 | |||
91 | private function getMockForm() | ||
92 | { | ||
93 | return $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
94 | } | ||
95 | |||
96 | // More specific mapping tests can be found in ViolationMapperTest | ||
97 | public function testMapViolation() | ||
98 | { | ||
99 | $violation = $this->getConstraintViolation(); | ||
100 | $form = $this->getForm('street'); | ||
101 | |||
102 | $this->validator->expects($this->once()) | ||
103 | ->method('validate') | ||
104 | ->will($this->returnValue(array($violation))); | ||
105 | |||
106 | $this->violationMapper->expects($this->once()) | ||
107 | ->method('mapViolation') | ||
108 | ->with($violation, $form, false); | ||
109 | |||
110 | $this->listener->validateForm(new FormEvent($form, null)); | ||
111 | } | ||
112 | |||
113 | public function testMapViolationAllowsNonSyncIfInvalid() | ||
114 | { | ||
115 | $violation = $this->getConstraintViolation(Form::ERR_INVALID); | ||
116 | $form = $this->getForm('street'); | ||
117 | |||
118 | $this->validator->expects($this->once()) | ||
119 | ->method('validate') | ||
120 | ->will($this->returnValue(array($violation))); | ||
121 | |||
122 | $this->violationMapper->expects($this->once()) | ||
123 | ->method('mapViolation') | ||
124 | // pass true now | ||
125 | ->with($violation, $form, true); | ||
126 | |||
127 | $this->listener->validateForm(new FormEvent($form, null)); | ||
128 | } | ||
129 | |||
130 | public function testValidateIgnoresNonRoot() | ||
131 | { | ||
132 | $form = $this->getMockForm(); | ||
133 | $form->expects($this->once()) | ||
134 | ->method('isRoot') | ||
135 | ->will($this->returnValue(false)); | ||
136 | |||
137 | $this->validator->expects($this->never()) | ||
138 | ->method('validate'); | ||
139 | |||
140 | $this->violationMapper->expects($this->never()) | ||
141 | ->method('mapViolation'); | ||
142 | |||
143 | $this->listener->validateForm(new FormEvent($form, null)); | ||
144 | } | ||
145 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php deleted file mode 100644 index 66194105..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\Type; | ||
13 | |||
14 | use Symfony\Component\Form\FormInterface; | ||
15 | |||
16 | class FormTypeValidatorExtensionTest extends TypeTestCase | ||
17 | { | ||
18 | public function testValidationGroupNullByDefault() | ||
19 | { | ||
20 | $form = $this->factory->create('form'); | ||
21 | |||
22 | $this->assertNull($form->getConfig()->getOption('validation_groups')); | ||
23 | } | ||
24 | |||
25 | public function testValidationGroupsTransformedToArray() | ||
26 | { | ||
27 | $form = $this->factory->create('form', null, array( | ||
28 | 'validation_groups' => 'group', | ||
29 | )); | ||
30 | |||
31 | $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); | ||
32 | } | ||
33 | |||
34 | public function testValidationGroupsCanBeSetToArray() | ||
35 | { | ||
36 | $form = $this->factory->create('form', null, array( | ||
37 | 'validation_groups' => array('group1', 'group2'), | ||
38 | )); | ||
39 | |||
40 | $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); | ||
41 | } | ||
42 | |||
43 | public function testValidationGroupsCanBeSetToFalse() | ||
44 | { | ||
45 | $form = $this->factory->create('form', null, array( | ||
46 | 'validation_groups' => false, | ||
47 | )); | ||
48 | |||
49 | $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); | ||
50 | } | ||
51 | |||
52 | public function testValidationGroupsCanBeSetToCallback() | ||
53 | { | ||
54 | $form = $this->factory->create('form', null, array( | ||
55 | 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), | ||
56 | )); | ||
57 | |||
58 | $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
59 | } | ||
60 | |||
61 | public function testValidationGroupsCanBeSetToClosure() | ||
62 | { | ||
63 | $form = $this->factory->create('form', null, array( | ||
64 | 'validation_groups' => function(FormInterface $form){ return null; }, | ||
65 | )); | ||
66 | |||
67 | $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
68 | } | ||
69 | |||
70 | public function testSubmitValidatesData() | ||
71 | { | ||
72 | $builder = $this->factory->createBuilder('form', null, array( | ||
73 | 'validation_groups' => 'group', | ||
74 | )); | ||
75 | $builder->add('firstName', 'form'); | ||
76 | $form = $builder->getForm(); | ||
77 | |||
78 | $this->validator->expects($this->once()) | ||
79 | ->method('validate') | ||
80 | ->with($this->equalTo($form)); | ||
81 | |||
82 | // specific data is irrelevant | ||
83 | $form->submit(array()); | ||
84 | } | ||
85 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php deleted file mode 100644 index d94d896a..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\Type; | ||
13 | |||
14 | use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase; | ||
15 | use Symfony\Component\Form\Extension\Validator\ValidatorExtension; | ||
16 | |||
17 | abstract class TypeTestCase extends BaseTypeTestCase | ||
18 | { | ||
19 | protected $validator; | ||
20 | |||
21 | protected function setUp() | ||
22 | { | ||
23 | if (!class_exists('Symfony\Component\Validator\Constraint')) { | ||
24 | $this->markTestSkipped('The "Validator" component is not available'); | ||
25 | } | ||
26 | |||
27 | $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); | ||
28 | $metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); | ||
29 | $this->validator->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); | ||
30 | $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); | ||
31 | $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); | ||
32 | |||
33 | parent::setUp(); | ||
34 | } | ||
35 | |||
36 | protected function tearDown() | ||
37 | { | ||
38 | $this->validator = null; | ||
39 | |||
40 | parent::tearDown(); | ||
41 | } | ||
42 | |||
43 | protected function getExtensions() | ||
44 | { | ||
45 | return array_merge(parent::getExtensions(), array( | ||
46 | new ValidatorExtension($this->validator), | ||
47 | )); | ||
48 | } | ||
49 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php deleted file mode 100644 index 7ad5b771..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\Util; | ||
13 | |||
14 | class ServerParamsTest extends \PHPUnit_Framework_TestCase | ||
15 | { | ||
16 | /** @dataProvider getGetPostMaxSizeTestData */ | ||
17 | public function testGetPostMaxSize($size, $bytes) | ||
18 | { | ||
19 | $serverParams = $this->getMock('Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize')); | ||
20 | $serverParams | ||
21 | ->expects($this->any()) | ||
22 | ->method('getNormalizedIniPostMaxSize') | ||
23 | ->will($this->returnValue(strtoupper($size))); | ||
24 | |||
25 | $this->assertEquals($bytes, $serverParams->getPostMaxSize()); | ||
26 | } | ||
27 | |||
28 | public function getGetPostMaxSizeTestData() | ||
29 | { | ||
30 | return array( | ||
31 | array('2k', 2048), | ||
32 | array('2 k', 2048), | ||
33 | array('8m', 8 * 1024 * 1024), | ||
34 | array('+2 k', 2048), | ||
35 | array('+2???k', 2048), | ||
36 | array('0x10', 16), | ||
37 | array('0xf', 15), | ||
38 | array('010', 8), | ||
39 | array('+0x10 k', 16 * 1024), | ||
40 | array('1g', 1024 * 1024 * 1024), | ||
41 | array('-1', -1), | ||
42 | array('0', 0), | ||
43 | array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' | ||
44 | ); | ||
45 | } | ||
46 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php deleted file mode 100644 index c802ea7e..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ /dev/null | |||
@@ -1,1481 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper; | ||
15 | use Symfony\Component\Form\Exception\TransformationFailedException; | ||
16 | use Symfony\Component\Form\CallbackTransformer; | ||
17 | use Symfony\Component\Form\Form; | ||
18 | use Symfony\Component\Form\FormConfigBuilder; | ||
19 | use Symfony\Component\Form\FormError; | ||
20 | use Symfony\Component\PropertyAccess\PropertyPath; | ||
21 | use Symfony\Component\Validator\ConstraintViolation; | ||
22 | |||
23 | /** | ||
24 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
25 | */ | ||
26 | class ViolationMapperTest extends \PHPUnit_Framework_TestCase | ||
27 | { | ||
28 | const LEVEL_0 = 0; | ||
29 | |||
30 | const LEVEL_1 = 1; | ||
31 | |||
32 | const LEVEL_1B = 2; | ||
33 | |||
34 | const LEVEL_2 = 3; | ||
35 | |||
36 | /** | ||
37 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
38 | */ | ||
39 | private $dispatcher; | ||
40 | |||
41 | /** | ||
42 | * @var ViolationMapper | ||
43 | */ | ||
44 | private $mapper; | ||
45 | |||
46 | /** | ||
47 | * @var string | ||
48 | */ | ||
49 | private $message; | ||
50 | |||
51 | /** | ||
52 | * @var string | ||
53 | */ | ||
54 | private $messageTemplate; | ||
55 | |||
56 | /** | ||
57 | * @var array | ||
58 | */ | ||
59 | private $params; | ||
60 | |||
61 | protected function setUp() | ||
62 | { | ||
63 | if (!class_exists('Symfony\Component\EventDispatcher\Event')) { | ||
64 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
65 | } | ||
66 | |||
67 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
68 | $this->mapper = new ViolationMapper(); | ||
69 | $this->message = 'Message'; | ||
70 | $this->messageTemplate = 'Message template'; | ||
71 | $this->params = array('foo' => 'bar'); | ||
72 | } | ||
73 | |||
74 | protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $inheritData = false, $synchronized = true) | ||
75 | { | ||
76 | $config = new FormConfigBuilder($name, $dataClass, $this->dispatcher, array( | ||
77 | 'error_mapping' => $errorMapping, | ||
78 | )); | ||
79 | $config->setMapped(true); | ||
80 | $config->setInheritData($inheritData); | ||
81 | $config->setPropertyPath($propertyPath); | ||
82 | $config->setCompound(true); | ||
83 | $config->setDataMapper($this->getDataMapper()); | ||
84 | |||
85 | if (!$synchronized) { | ||
86 | $config->addViewTransformer(new CallbackTransformer( | ||
87 | function ($normData) { return $normData; }, | ||
88 | function () { throw new TransformationFailedException(); } | ||
89 | )); | ||
90 | } | ||
91 | |||
92 | return new Form($config); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
97 | */ | ||
98 | private function getDataMapper() | ||
99 | { | ||
100 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * @param $propertyPath | ||
105 | * | ||
106 | * @return ConstraintViolation | ||
107 | */ | ||
108 | protected function getConstraintViolation($propertyPath) | ||
109 | { | ||
110 | return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, $propertyPath, null); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * @return FormError | ||
115 | */ | ||
116 | protected function getFormError() | ||
117 | { | ||
118 | return new FormError($this->message, $this->messageTemplate, $this->params); | ||
119 | } | ||
120 | |||
121 | public function testMapToFormInheritingParentDataIfDataDoesNotMatch() | ||
122 | { | ||
123 | $violation = $this->getConstraintViolation('children[address].data.foo'); | ||
124 | $parent = $this->getForm('parent'); | ||
125 | $child = $this->getForm('address', 'address', null, array(), true); | ||
126 | $grandChild = $this->getForm('street'); | ||
127 | |||
128 | $parent->add($child); | ||
129 | $child->add($grandChild); | ||
130 | |||
131 | $this->mapper->mapViolation($violation, $parent); | ||
132 | |||
133 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
134 | $this->assertEquals(array($this->getFormError()), $child->getErrors(), $child->getName().' should have an error, but has none'); | ||
135 | $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); | ||
136 | } | ||
137 | |||
138 | public function testFollowDotRules() | ||
139 | { | ||
140 | $violation = $this->getConstraintViolation('data.foo'); | ||
141 | $parent = $this->getForm('parent', null, null, array( | ||
142 | 'foo' => 'address', | ||
143 | )); | ||
144 | $child = $this->getForm('address', null, null, array( | ||
145 | '.' => 'street', | ||
146 | )); | ||
147 | $grandChild = $this->getForm('street', null, null, array( | ||
148 | '.' => 'name', | ||
149 | )); | ||
150 | $grandGrandChild = $this->getForm('name'); | ||
151 | |||
152 | $parent->add($child); | ||
153 | $child->add($grandChild); | ||
154 | $grandChild->add($grandGrandChild); | ||
155 | |||
156 | $this->mapper->mapViolation($violation, $parent); | ||
157 | |||
158 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
159 | $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); | ||
160 | $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); | ||
161 | $this->assertEquals(array($this->getFormError()), $grandGrandChild->getErrors(), $grandGrandChild->getName().' should have an error, but has none'); | ||
162 | } | ||
163 | |||
164 | public function testAbortMappingIfNotSynchronized() | ||
165 | { | ||
166 | $violation = $this->getConstraintViolation('children[address].data.street'); | ||
167 | $parent = $this->getForm('parent'); | ||
168 | $child = $this->getForm('address', 'address', null, array(), false, false); | ||
169 | // even though "street" is synchronized, it should not have any errors | ||
170 | // due to its parent not being synchronized | ||
171 | $grandChild = $this->getForm('street' , 'street'); | ||
172 | |||
173 | $parent->add($child); | ||
174 | $child->add($grandChild); | ||
175 | |||
176 | // submit to invoke the transformer and mark the form unsynchronized | ||
177 | $parent->submit(array()); | ||
178 | |||
179 | $this->mapper->mapViolation($violation, $parent); | ||
180 | |||
181 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
182 | $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); | ||
183 | $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); | ||
184 | } | ||
185 | |||
186 | public function testAbortDotRuleMappingIfNotSynchronized() | ||
187 | { | ||
188 | $violation = $this->getConstraintViolation('data.address'); | ||
189 | $parent = $this->getForm('parent'); | ||
190 | $child = $this->getForm('address', 'address', null, array( | ||
191 | '.' => 'street', | ||
192 | ), false, false); | ||
193 | // even though "street" is synchronized, it should not have any errors | ||
194 | // due to its parent not being synchronized | ||
195 | $grandChild = $this->getForm('street'); | ||
196 | |||
197 | $parent->add($child); | ||
198 | $child->add($grandChild); | ||
199 | |||
200 | // submit to invoke the transformer and mark the form unsynchronized | ||
201 | $parent->submit(array()); | ||
202 | |||
203 | $this->mapper->mapViolation($violation, $parent); | ||
204 | |||
205 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
206 | $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); | ||
207 | $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); | ||
208 | } | ||
209 | |||
210 | public function provideDefaultTests() | ||
211 | { | ||
212 | // The mapping must be deterministic! If a child has the property path "[street]", | ||
213 | // "data[street]" should be mapped, but "data.street" should not! | ||
214 | return array( | ||
215 | // mapping target, child name, its property path, grand child name, its property path, violation path | ||
216 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', ''), | ||
217 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data'), | ||
218 | |||
219 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'), | ||
220 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), | ||
221 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data'), | ||
222 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
223 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), | ||
224 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
225 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), | ||
226 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street'), | ||
227 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street.prop'), | ||
228 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street]'), | ||
229 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street].prop'), | ||
230 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'), | ||
231 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'), | ||
232 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'), | ||
233 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'), | ||
234 | |||
235 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data'), | ||
236 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
237 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data'), | ||
238 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
239 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'), | ||
240 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
241 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'), | ||
242 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street'), | ||
243 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street.prop'), | ||
244 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street]'), | ||
245 | array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street].prop'), | ||
246 | array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street'), | ||
247 | array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street.prop'), | ||
248 | array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street]'), | ||
249 | array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street].prop'), | ||
250 | |||
251 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data'), | ||
252 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'), | ||
253 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data'), | ||
254 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
255 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'), | ||
256 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
257 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'), | ||
258 | array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street'), | ||
259 | array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street.prop'), | ||
260 | array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street]'), | ||
261 | array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street].prop'), | ||
262 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street'), | ||
263 | array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street.prop'), | ||
264 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street]'), | ||
265 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street].prop'), | ||
266 | |||
267 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'), | ||
268 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
269 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data'), | ||
270 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
271 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'), | ||
272 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
273 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'), | ||
274 | array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street'), | ||
275 | array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), | ||
276 | array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street]'), | ||
277 | array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), | ||
278 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street'), | ||
279 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), | ||
280 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street]'), | ||
281 | array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), | ||
282 | |||
283 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data'), | ||
284 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data.prop'), | ||
285 | array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data'), | ||
286 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street'), | ||
287 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street.prop'), | ||
288 | array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street]'), | ||
289 | array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street].prop'), | ||
290 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street'), | ||
291 | array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street.prop'), | ||
292 | array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street]'), | ||
293 | array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street].prop'), | ||
294 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street'), | ||
295 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street.prop'), | ||
296 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street]'), | ||
297 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street].prop'), | ||
298 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street'), | ||
299 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street.prop'), | ||
300 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street]'), | ||
301 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street].prop'), | ||
302 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street'), | ||
303 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street.prop'), | ||
304 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street]'), | ||
305 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street].prop'), | ||
306 | |||
307 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data'), | ||
308 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
309 | array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data'), | ||
310 | array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street'), | ||
311 | array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street.prop'), | ||
312 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street]'), | ||
313 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street].prop'), | ||
314 | array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street'), | ||
315 | array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street.prop'), | ||
316 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street]'), | ||
317 | array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street].prop'), | ||
318 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street'), | ||
319 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street.prop'), | ||
320 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street]'), | ||
321 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street].prop'), | ||
322 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street'), | ||
323 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street.prop'), | ||
324 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street]'), | ||
325 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street].prop'), | ||
326 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street'), | ||
327 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street.prop'), | ||
328 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street]'), | ||
329 | array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street].prop'), | ||
330 | |||
331 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data'), | ||
332 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data.prop'), | ||
333 | array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data'), | ||
334 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street'), | ||
335 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street.prop'), | ||
336 | array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street]'), | ||
337 | array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street].prop'), | ||
338 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street'), | ||
339 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street.prop'), | ||
340 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street]'), | ||
341 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street].prop'), | ||
342 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street'), | ||
343 | array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street.prop'), | ||
344 | array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street]'), | ||
345 | array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street].prop'), | ||
346 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street'), | ||
347 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street.prop'), | ||
348 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street]'), | ||
349 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street].prop'), | ||
350 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street'), | ||
351 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street.prop'), | ||
352 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street]'), | ||
353 | array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street].prop'), | ||
354 | |||
355 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data'), | ||
356 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
357 | array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data'), | ||
358 | array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street'), | ||
359 | array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street.prop'), | ||
360 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street]'), | ||
361 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street].prop'), | ||
362 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street'), | ||
363 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street.prop'), | ||
364 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street]'), | ||
365 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street].prop'), | ||
366 | array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street'), | ||
367 | array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street.prop'), | ||
368 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street]'), | ||
369 | array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street].prop'), | ||
370 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street'), | ||
371 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street.prop'), | ||
372 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street]'), | ||
373 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street].prop'), | ||
374 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street'), | ||
375 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street.prop'), | ||
376 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street]'), | ||
377 | array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street].prop'), | ||
378 | |||
379 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data'), | ||
380 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data.prop'), | ||
381 | array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data'), | ||
382 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street'), | ||
383 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street.prop'), | ||
384 | array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street]'), | ||
385 | array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street].prop'), | ||
386 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street'), | ||
387 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street.prop'), | ||
388 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street]'), | ||
389 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street].prop'), | ||
390 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street'), | ||
391 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street.prop'), | ||
392 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street]'), | ||
393 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street].prop'), | ||
394 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street'), | ||
395 | array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street.prop'), | ||
396 | array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street]'), | ||
397 | array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street].prop'), | ||
398 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street'), | ||
399 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street.prop'), | ||
400 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street]'), | ||
401 | array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street].prop'), | ||
402 | |||
403 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data'), | ||
404 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
405 | array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data'), | ||
406 | array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street'), | ||
407 | array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street.prop'), | ||
408 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street]'), | ||
409 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street].prop'), | ||
410 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street'), | ||
411 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street.prop'), | ||
412 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street]'), | ||
413 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street].prop'), | ||
414 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street'), | ||
415 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street.prop'), | ||
416 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street]'), | ||
417 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street].prop'), | ||
418 | array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street'), | ||
419 | array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street.prop'), | ||
420 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street]'), | ||
421 | array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street].prop'), | ||
422 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street'), | ||
423 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street.prop'), | ||
424 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street]'), | ||
425 | array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street].prop'), | ||
426 | |||
427 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data'), | ||
428 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data.prop'), | ||
429 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address]'), | ||
430 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data'), | ||
431 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street'), | ||
432 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street.prop'), | ||
433 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street]'), | ||
434 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street].prop'), | ||
435 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street'), | ||
436 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street.prop'), | ||
437 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street]'), | ||
438 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street].prop'), | ||
439 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street'), | ||
440 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street.prop'), | ||
441 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street]'), | ||
442 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street].prop'), | ||
443 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street'), | ||
444 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street.prop'), | ||
445 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street]'), | ||
446 | array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street].prop'), | ||
447 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street'), | ||
448 | array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street.prop'), | ||
449 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street]'), | ||
450 | array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street].prop'), | ||
451 | |||
452 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data'), | ||
453 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
454 | array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data'), | ||
455 | array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street'), | ||
456 | array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street.prop'), | ||
457 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street]'), | ||
458 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street].prop'), | ||
459 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street'), | ||
460 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street.prop'), | ||
461 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street]'), | ||
462 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street].prop'), | ||
463 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street'), | ||
464 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street.prop'), | ||
465 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street]'), | ||
466 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street].prop'), | ||
467 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street'), | ||
468 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street.prop'), | ||
469 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street]'), | ||
470 | array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street].prop'), | ||
471 | array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street'), | ||
472 | array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street.prop'), | ||
473 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street]'), | ||
474 | array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street].prop'), | ||
475 | |||
476 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data'), | ||
477 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data.prop'), | ||
478 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data'), | ||
479 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office'), | ||
480 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street'), | ||
481 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street.prop'), | ||
482 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street]'), | ||
483 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street].prop'), | ||
484 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office]'), | ||
485 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street'), | ||
486 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street.prop'), | ||
487 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street]'), | ||
488 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street].prop'), | ||
489 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street'), | ||
490 | array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street.prop'), | ||
491 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street]'), | ||
492 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street].prop'), | ||
493 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street'), | ||
494 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street.prop'), | ||
495 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street]'), | ||
496 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street].prop'), | ||
497 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street'), | ||
498 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street.prop'), | ||
499 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street]'), | ||
500 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street].prop'), | ||
501 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street'), | ||
502 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street.prop'), | ||
503 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street]'), | ||
504 | array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street].prop'), | ||
505 | |||
506 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data'), | ||
507 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data.prop'), | ||
508 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data'), | ||
509 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office'), | ||
510 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street'), | ||
511 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street.prop'), | ||
512 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street]'), | ||
513 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street].prop'), | ||
514 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office]'), | ||
515 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street'), | ||
516 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street.prop'), | ||
517 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street]'), | ||
518 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street].prop'), | ||
519 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street'), | ||
520 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street.prop'), | ||
521 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street]'), | ||
522 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street].prop'), | ||
523 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street'), | ||
524 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street.prop'), | ||
525 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street]'), | ||
526 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street].prop'), | ||
527 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street'), | ||
528 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street.prop'), | ||
529 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street]'), | ||
530 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street].prop'), | ||
531 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street'), | ||
532 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street.prop'), | ||
533 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street]'), | ||
534 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street].prop'), | ||
535 | |||
536 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data'), | ||
537 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data.prop'), | ||
538 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data'), | ||
539 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office'), | ||
540 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street'), | ||
541 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street.prop'), | ||
542 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street]'), | ||
543 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street].prop'), | ||
544 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office]'), | ||
545 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street'), | ||
546 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street.prop'), | ||
547 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street]'), | ||
548 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street].prop'), | ||
549 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street'), | ||
550 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street.prop'), | ||
551 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street]'), | ||
552 | array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street].prop'), | ||
553 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street'), | ||
554 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street.prop'), | ||
555 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street]'), | ||
556 | array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street].prop'), | ||
557 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street'), | ||
558 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street.prop'), | ||
559 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street]'), | ||
560 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street].prop'), | ||
561 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street'), | ||
562 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street.prop'), | ||
563 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street]'), | ||
564 | array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street].prop'), | ||
565 | |||
566 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data'), | ||
567 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data.prop'), | ||
568 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street'), | ||
569 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street.prop'), | ||
570 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street]'), | ||
571 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street].prop'), | ||
572 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office]'), | ||
573 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street'), | ||
574 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street.prop'), | ||
575 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street]'), | ||
576 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street].prop'), | ||
577 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street'), | ||
578 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street.prop'), | ||
579 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street]'), | ||
580 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street].prop'), | ||
581 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street'), | ||
582 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street.prop'), | ||
583 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street]'), | ||
584 | array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street].prop'), | ||
585 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street'), | ||
586 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street.prop'), | ||
587 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street]'), | ||
588 | array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street].prop'), | ||
589 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street'), | ||
590 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street.prop'), | ||
591 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street]'), | ||
592 | array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street].prop'), | ||
593 | |||
594 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data'), | ||
595 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data.prop'), | ||
596 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data'), | ||
597 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office'), | ||
598 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street'), | ||
599 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street.prop'), | ||
600 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street]'), | ||
601 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street].prop'), | ||
602 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office]'), | ||
603 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street'), | ||
604 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street.prop'), | ||
605 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street]'), | ||
606 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street].prop'), | ||
607 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street'), | ||
608 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street.prop'), | ||
609 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street]'), | ||
610 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street].prop'), | ||
611 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street'), | ||
612 | array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street.prop'), | ||
613 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street]'), | ||
614 | array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street].prop'), | ||
615 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street'), | ||
616 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street.prop'), | ||
617 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street]'), | ||
618 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street].prop'), | ||
619 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street'), | ||
620 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street.prop'), | ||
621 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street]'), | ||
622 | array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street].prop'), | ||
623 | |||
624 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data'), | ||
625 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data.prop'), | ||
626 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data'), | ||
627 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office'), | ||
628 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street'), | ||
629 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street.prop'), | ||
630 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street]'), | ||
631 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street].prop'), | ||
632 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office]'), | ||
633 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street'), | ||
634 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street.prop'), | ||
635 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street]'), | ||
636 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street].prop'), | ||
637 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street'), | ||
638 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street.prop'), | ||
639 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street]'), | ||
640 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street].prop'), | ||
641 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street'), | ||
642 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street.prop'), | ||
643 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street]'), | ||
644 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street].prop'), | ||
645 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street'), | ||
646 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street.prop'), | ||
647 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street]'), | ||
648 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street].prop'), | ||
649 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street'), | ||
650 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street.prop'), | ||
651 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street]'), | ||
652 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street].prop'), | ||
653 | |||
654 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data'), | ||
655 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data.prop'), | ||
656 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data'), | ||
657 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office'), | ||
658 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street'), | ||
659 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street.prop'), | ||
660 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street]'), | ||
661 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street].prop'), | ||
662 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office]'), | ||
663 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street'), | ||
664 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street.prop'), | ||
665 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street]'), | ||
666 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street].prop'), | ||
667 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street'), | ||
668 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street.prop'), | ||
669 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street]'), | ||
670 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street].prop'), | ||
671 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street'), | ||
672 | array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street.prop'), | ||
673 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street]'), | ||
674 | array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street].prop'), | ||
675 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street'), | ||
676 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street.prop'), | ||
677 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street]'), | ||
678 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street].prop'), | ||
679 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street'), | ||
680 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street.prop'), | ||
681 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street]'), | ||
682 | array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street].prop'), | ||
683 | |||
684 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data'), | ||
685 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data.prop'), | ||
686 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data'), | ||
687 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office'), | ||
688 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street'), | ||
689 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street.prop'), | ||
690 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street]'), | ||
691 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street].prop'), | ||
692 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office]'), | ||
693 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street'), | ||
694 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street.prop'), | ||
695 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street]'), | ||
696 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street].prop'), | ||
697 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street'), | ||
698 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street.prop'), | ||
699 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street]'), | ||
700 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street].prop'), | ||
701 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street'), | ||
702 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street.prop'), | ||
703 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street]'), | ||
704 | array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street].prop'), | ||
705 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street'), | ||
706 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street.prop'), | ||
707 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street]'), | ||
708 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street].prop'), | ||
709 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street'), | ||
710 | array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street.prop'), | ||
711 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street]'), | ||
712 | array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street].prop'), | ||
713 | |||
714 | // Edge cases which must not occur | ||
715 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street]'), | ||
716 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street].prop'), | ||
717 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street]'), | ||
718 | array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street].prop'), | ||
719 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street]'), | ||
720 | array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street].prop'), | ||
721 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street]'), | ||
722 | array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street].prop'), | ||
723 | |||
724 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].children[street]'), | ||
725 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].data.street'), | ||
726 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].data.address.street'), | ||
727 | array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.address.street'), | ||
728 | |||
729 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].children[street]'), | ||
730 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].data.street'), | ||
731 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.street'), | ||
732 | array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.street'), | ||
733 | ); | ||
734 | } | ||
735 | |||
736 | /** | ||
737 | * @dataProvider provideDefaultTests | ||
738 | */ | ||
739 | public function testDefaultErrorMapping($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) | ||
740 | { | ||
741 | $violation = $this->getConstraintViolation($violationPath); | ||
742 | $parent = $this->getForm('parent'); | ||
743 | $child = $this->getForm($childName, $childPath); | ||
744 | $grandChild = $this->getForm($grandChildName, $grandChildPath); | ||
745 | |||
746 | $parent->add($child); | ||
747 | $child->add($grandChild); | ||
748 | |||
749 | $this->mapper->mapViolation($violation, $parent); | ||
750 | |||
751 | if (self::LEVEL_0 === $target) { | ||
752 | $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none'); | ||
753 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
754 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
755 | } elseif (self::LEVEL_1 === $target) { | ||
756 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
757 | $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none'); | ||
758 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
759 | } else { | ||
760 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
761 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
762 | $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none'); | ||
763 | } | ||
764 | } | ||
765 | |||
766 | public function provideCustomDataErrorTests() | ||
767 | { | ||
768 | return array( | ||
769 | // mapping target, error mapping, child name, its property path, grand child name, its property path, violation path | ||
770 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo'), | ||
771 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'), | ||
772 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo]'), | ||
773 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'), | ||
774 | |||
775 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address'), | ||
776 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'), | ||
777 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address]'), | ||
778 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'), | ||
779 | |||
780 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo'), | ||
781 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'), | ||
782 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'), | ||
783 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'), | ||
784 | |||
785 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address'), | ||
786 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'), | ||
787 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address]'), | ||
788 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'), | ||
789 | |||
790 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo'), | ||
791 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'), | ||
792 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo]'), | ||
793 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'), | ||
794 | |||
795 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address'), | ||
796 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'), | ||
797 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address]'), | ||
798 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'), | ||
799 | |||
800 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo'), | ||
801 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'), | ||
802 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'), | ||
803 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'), | ||
804 | |||
805 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address'), | ||
806 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'), | ||
807 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address]'), | ||
808 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'), | ||
809 | |||
810 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), | ||
811 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), | ||
812 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), | ||
813 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), | ||
814 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), | ||
815 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), | ||
816 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), | ||
817 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), | ||
818 | |||
819 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street'), | ||
820 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'), | ||
821 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'), | ||
822 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'), | ||
823 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street'), | ||
824 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'), | ||
825 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'), | ||
826 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'), | ||
827 | |||
828 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'), | ||
829 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'), | ||
830 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'), | ||
831 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'), | ||
832 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'), | ||
833 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'), | ||
834 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'), | ||
835 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'), | ||
836 | |||
837 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'), | ||
838 | array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'), | ||
839 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'), | ||
840 | array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'), | ||
841 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'), | ||
842 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'), | ||
843 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'), | ||
844 | array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'), | ||
845 | |||
846 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), | ||
847 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), | ||
848 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), | ||
849 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), | ||
850 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), | ||
851 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), | ||
852 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), | ||
853 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), | ||
854 | |||
855 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'), | ||
856 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'), | ||
857 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'), | ||
858 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'), | ||
859 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'), | ||
860 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'), | ||
861 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'), | ||
862 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'), | ||
863 | |||
864 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'), | ||
865 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'), | ||
866 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'), | ||
867 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'), | ||
868 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'), | ||
869 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'), | ||
870 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'), | ||
871 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'), | ||
872 | |||
873 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'), | ||
874 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), | ||
875 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'), | ||
876 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), | ||
877 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'), | ||
878 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), | ||
879 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'), | ||
880 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), | ||
881 | |||
882 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), | ||
883 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), | ||
884 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), | ||
885 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), | ||
886 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), | ||
887 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), | ||
888 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), | ||
889 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), | ||
890 | |||
891 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street'), | ||
892 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'), | ||
893 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'), | ||
894 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'), | ||
895 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street'), | ||
896 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'), | ||
897 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'), | ||
898 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'), | ||
899 | |||
900 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'), | ||
901 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'), | ||
902 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'), | ||
903 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'), | ||
904 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'), | ||
905 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'), | ||
906 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'), | ||
907 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'), | ||
908 | |||
909 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'), | ||
910 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'), | ||
911 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'), | ||
912 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'), | ||
913 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'), | ||
914 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'), | ||
915 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'), | ||
916 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'), | ||
917 | |||
918 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), | ||
919 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), | ||
920 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), | ||
921 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), | ||
922 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), | ||
923 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), | ||
924 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), | ||
925 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), | ||
926 | |||
927 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'), | ||
928 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'), | ||
929 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'), | ||
930 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'), | ||
931 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'), | ||
932 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'), | ||
933 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'), | ||
934 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'), | ||
935 | |||
936 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'), | ||
937 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'), | ||
938 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'), | ||
939 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'), | ||
940 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'), | ||
941 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'), | ||
942 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'), | ||
943 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'), | ||
944 | |||
945 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'), | ||
946 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), | ||
947 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'), | ||
948 | array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), | ||
949 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'), | ||
950 | array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), | ||
951 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'), | ||
952 | array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), | ||
953 | |||
954 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), | ||
955 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), | ||
956 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), | ||
957 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), | ||
958 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), | ||
959 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), | ||
960 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), | ||
961 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), | ||
962 | |||
963 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), | ||
964 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), | ||
965 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), | ||
966 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), | ||
967 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), | ||
968 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), | ||
969 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), | ||
970 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), | ||
971 | |||
972 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), | ||
973 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), | ||
974 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), | ||
975 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), | ||
976 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), | ||
977 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), | ||
978 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), | ||
979 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), | ||
980 | |||
981 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), | ||
982 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), | ||
983 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), | ||
984 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), | ||
985 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), | ||
986 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), | ||
987 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), | ||
988 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), | ||
989 | |||
990 | array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), | ||
991 | array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), | ||
992 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), | ||
993 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), | ||
994 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), | ||
995 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), | ||
996 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), | ||
997 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), | ||
998 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), | ||
999 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), | ||
1000 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), | ||
1001 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), | ||
1002 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), | ||
1003 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), | ||
1004 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), | ||
1005 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), | ||
1006 | |||
1007 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), | ||
1008 | array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), | ||
1009 | array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), | ||
1010 | array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), | ||
1011 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), | ||
1012 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), | ||
1013 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), | ||
1014 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), | ||
1015 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), | ||
1016 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), | ||
1017 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), | ||
1018 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), | ||
1019 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), | ||
1020 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), | ||
1021 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), | ||
1022 | array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), | ||
1023 | |||
1024 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), | ||
1025 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), | ||
1026 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), | ||
1027 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), | ||
1028 | array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), | ||
1029 | array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), | ||
1030 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), | ||
1031 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), | ||
1032 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), | ||
1033 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), | ||
1034 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), | ||
1035 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), | ||
1036 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), | ||
1037 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), | ||
1038 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), | ||
1039 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), | ||
1040 | |||
1041 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), | ||
1042 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), | ||
1043 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), | ||
1044 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), | ||
1045 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), | ||
1046 | array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), | ||
1047 | array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), | ||
1048 | array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), | ||
1049 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), | ||
1050 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), | ||
1051 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), | ||
1052 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), | ||
1053 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), | ||
1054 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), | ||
1055 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), | ||
1056 | array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), | ||
1057 | |||
1058 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), | ||
1059 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), | ||
1060 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), | ||
1061 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), | ||
1062 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), | ||
1063 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), | ||
1064 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), | ||
1065 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), | ||
1066 | array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), | ||
1067 | array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), | ||
1068 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), | ||
1069 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), | ||
1070 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), | ||
1071 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), | ||
1072 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), | ||
1073 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), | ||
1074 | |||
1075 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), | ||
1076 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), | ||
1077 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), | ||
1078 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), | ||
1079 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), | ||
1080 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), | ||
1081 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), | ||
1082 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), | ||
1083 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), | ||
1084 | array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), | ||
1085 | array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), | ||
1086 | array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), | ||
1087 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), | ||
1088 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), | ||
1089 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), | ||
1090 | array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), | ||
1091 | |||
1092 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), | ||
1093 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), | ||
1094 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), | ||
1095 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), | ||
1096 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), | ||
1097 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), | ||
1098 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), | ||
1099 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), | ||
1100 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), | ||
1101 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), | ||
1102 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), | ||
1103 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), | ||
1104 | array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), | ||
1105 | array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), | ||
1106 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), | ||
1107 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), | ||
1108 | |||
1109 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), | ||
1110 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), | ||
1111 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), | ||
1112 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), | ||
1113 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), | ||
1114 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), | ||
1115 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), | ||
1116 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), | ||
1117 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), | ||
1118 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), | ||
1119 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), | ||
1120 | array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), | ||
1121 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), | ||
1122 | array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), | ||
1123 | array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), | ||
1124 | array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), | ||
1125 | |||
1126 | array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo'), | ||
1127 | array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.prop'), | ||
1128 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo]'), | ||
1129 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].prop'), | ||
1130 | |||
1131 | array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo'), | ||
1132 | array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.prop'), | ||
1133 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo]'), | ||
1134 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].prop'), | ||
1135 | |||
1136 | array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo'), | ||
1137 | array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.prop'), | ||
1138 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo]'), | ||
1139 | array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].prop'), | ||
1140 | |||
1141 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar'), | ||
1142 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), | ||
1143 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar]'), | ||
1144 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), | ||
1145 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar'), | ||
1146 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), | ||
1147 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar]'), | ||
1148 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), | ||
1149 | |||
1150 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar'), | ||
1151 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar.prop'), | ||
1152 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar]'), | ||
1153 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar].prop'), | ||
1154 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar'), | ||
1155 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar.prop'), | ||
1156 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar]'), | ||
1157 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar].prop'), | ||
1158 | |||
1159 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar'), | ||
1160 | array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar.prop'), | ||
1161 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar]'), | ||
1162 | array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar].prop'), | ||
1163 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar'), | ||
1164 | array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar.prop'), | ||
1165 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar]'), | ||
1166 | array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar].prop'), | ||
1167 | |||
1168 | // Edge cases | ||
1169 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), | ||
1170 | array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), | ||
1171 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), | ||
1172 | array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), | ||
1173 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), | ||
1174 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), | ||
1175 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), | ||
1176 | array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), | ||
1177 | |||
1178 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), | ||
1179 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), | ||
1180 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), | ||
1181 | array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), | ||
1182 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), | ||
1183 | array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), | ||
1184 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), | ||
1185 | array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), | ||
1186 | ); | ||
1187 | } | ||
1188 | |||
1189 | /** | ||
1190 | * @dataProvider provideCustomDataErrorTests | ||
1191 | */ | ||
1192 | public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) | ||
1193 | { | ||
1194 | $violation = $this->getConstraintViolation($violationPath); | ||
1195 | $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo)); | ||
1196 | $child = $this->getForm($childName, $childPath); | ||
1197 | $grandChild = $this->getForm($grandChildName, $grandChildPath); | ||
1198 | |||
1199 | $parent->add($child); | ||
1200 | $child->add($grandChild); | ||
1201 | |||
1202 | // Add a field mapped to the first element of $mapFrom | ||
1203 | // to try to distract the algorithm | ||
1204 | // Only add it if we expect the error to come up on a different | ||
1205 | // level than LEVEL_0, because in this case the error would | ||
1206 | // (correctly) be mapped to the distraction field | ||
1207 | if ($target !== self::LEVEL_0) { | ||
1208 | $mapFromPath = new PropertyPath($mapFrom); | ||
1209 | $mapFromPrefix = $mapFromPath->isIndex(0) | ||
1210 | ? '['.$mapFromPath->getElement(0).']' | ||
1211 | : $mapFromPath->getElement(0); | ||
1212 | $distraction = $this->getForm('distraction', $mapFromPrefix); | ||
1213 | |||
1214 | $parent->add($distraction); | ||
1215 | } | ||
1216 | |||
1217 | $this->mapper->mapViolation($violation, $parent); | ||
1218 | |||
1219 | if ($target !== self::LEVEL_0) { | ||
1220 | $this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one'); | ||
1221 | } | ||
1222 | |||
1223 | if (self::LEVEL_0 === $target) { | ||
1224 | $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none'); | ||
1225 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1226 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1227 | } elseif (self::LEVEL_1 === $target) { | ||
1228 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1229 | $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none'); | ||
1230 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1231 | } else { | ||
1232 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1233 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1234 | $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none'); | ||
1235 | } | ||
1236 | } | ||
1237 | |||
1238 | public function provideCustomFormErrorTests() | ||
1239 | { | ||
1240 | // This case is different than the data errors, because here the | ||
1241 | // left side of the mapping refers to the property path of the actual | ||
1242 | // children. In other words, a child error only works if | ||
1243 | // 1) the error actually maps to an existing child and | ||
1244 | // 2) the property path of that child (relative to the form providing | ||
1245 | // the mapping) matches the left side of the mapping | ||
1246 | return array( | ||
1247 | // mapping target, map from, map to, child name, its property path, grand child name, its property path, violation path | ||
1248 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), | ||
1249 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), | ||
1250 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'), | ||
1251 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), | ||
1252 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), | ||
1253 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), | ||
1254 | |||
1255 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data'), | ||
1256 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), | ||
1257 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1258 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), | ||
1259 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1260 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), | ||
1261 | |||
1262 | // Property path of the erroneous field and mapping must match exactly | ||
1263 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), | ||
1264 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), | ||
1265 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'), | ||
1266 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), | ||
1267 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), | ||
1268 | array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), | ||
1269 | |||
1270 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), | ||
1271 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), | ||
1272 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'), | ||
1273 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), | ||
1274 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), | ||
1275 | array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), | ||
1276 | |||
1277 | array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), | ||
1278 | array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), | ||
1279 | array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'), | ||
1280 | array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), | ||
1281 | array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), | ||
1282 | array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), | ||
1283 | |||
1284 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data'), | ||
1285 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data.prop'), | ||
1286 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street'), | ||
1287 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street.prop'), | ||
1288 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street]'), | ||
1289 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street].prop'), | ||
1290 | |||
1291 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data'), | ||
1292 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
1293 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
1294 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'), | ||
1295 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
1296 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'), | ||
1297 | |||
1298 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data'), | ||
1299 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data.prop'), | ||
1300 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street'), | ||
1301 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street.prop'), | ||
1302 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street]'), | ||
1303 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street].prop'), | ||
1304 | |||
1305 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data'), | ||
1306 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'), | ||
1307 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
1308 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'), | ||
1309 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
1310 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'), | ||
1311 | |||
1312 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data'), | ||
1313 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data.prop'), | ||
1314 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street'), | ||
1315 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street.prop'), | ||
1316 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street]'), | ||
1317 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street].prop'), | ||
1318 | |||
1319 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'), | ||
1320 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'), | ||
1321 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
1322 | array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'), | ||
1323 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
1324 | array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'), | ||
1325 | |||
1326 | // Map to a nested child | ||
1327 | array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo]'), | ||
1328 | array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo]'), | ||
1329 | array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo]'), | ||
1330 | array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo]'), | ||
1331 | |||
1332 | // Map from a nested child | ||
1333 | array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), | ||
1334 | array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1335 | array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1336 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), | ||
1337 | array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
1338 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
1339 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), | ||
1340 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
1341 | array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
1342 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), | ||
1343 | array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
1344 | array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
1345 | |||
1346 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), | ||
1347 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1348 | array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1349 | array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), | ||
1350 | array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
1351 | array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
1352 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), | ||
1353 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
1354 | array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
1355 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), | ||
1356 | array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
1357 | array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
1358 | |||
1359 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), | ||
1360 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1361 | array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1362 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), | ||
1363 | array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
1364 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
1365 | array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), | ||
1366 | array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
1367 | array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
1368 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), | ||
1369 | array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
1370 | array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
1371 | |||
1372 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), | ||
1373 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1374 | array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1375 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), | ||
1376 | array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), | ||
1377 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), | ||
1378 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), | ||
1379 | array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), | ||
1380 | array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), | ||
1381 | array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), | ||
1382 | array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), | ||
1383 | array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), | ||
1384 | ); | ||
1385 | } | ||
1386 | |||
1387 | /** | ||
1388 | * @dataProvider provideCustomFormErrorTests | ||
1389 | */ | ||
1390 | public function testCustomFormErrorMapping($target, $mapFrom, $mapTo, $errorName, $errorPath, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) | ||
1391 | { | ||
1392 | $violation = $this->getConstraintViolation($violationPath); | ||
1393 | $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo)); | ||
1394 | $child = $this->getForm($childName, $childPath); | ||
1395 | $grandChild = $this->getForm($grandChildName, $grandChildPath); | ||
1396 | $errorChild = $this->getForm($errorName, $errorPath); | ||
1397 | |||
1398 | $parent->add($child); | ||
1399 | $parent->add($errorChild); | ||
1400 | $child->add($grandChild); | ||
1401 | |||
1402 | $this->mapper->mapViolation($violation, $parent); | ||
1403 | |||
1404 | if (self::LEVEL_0 === $target) { | ||
1405 | $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); | ||
1406 | $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none'); | ||
1407 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1408 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1409 | } elseif (self::LEVEL_1 === $target) { | ||
1410 | $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); | ||
1411 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1412 | $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none'); | ||
1413 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1414 | } elseif (self::LEVEL_1B === $target) { | ||
1415 | $this->assertEquals(array($this->getFormError()), $errorChild->getErrors(), $errorName.' should have an error, but has none'); | ||
1416 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1417 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1418 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1419 | } else { | ||
1420 | $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); | ||
1421 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1422 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1423 | $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none'); | ||
1424 | } | ||
1425 | } | ||
1426 | |||
1427 | public function provideErrorTestsForFormInheritingParentData() | ||
1428 | { | ||
1429 | return array( | ||
1430 | // mapping target, child name, its property path, grand child name, its property path, violation path | ||
1431 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'), | ||
1432 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), | ||
1433 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'), | ||
1434 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), | ||
1435 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'), | ||
1436 | array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), | ||
1437 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street'), | ||
1438 | array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street.prop'), | ||
1439 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street]'), | ||
1440 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street].prop'), | ||
1441 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street'), | ||
1442 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street.prop'), | ||
1443 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street]'), | ||
1444 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street].prop'), | ||
1445 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'), | ||
1446 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'), | ||
1447 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'), | ||
1448 | array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'), | ||
1449 | ); | ||
1450 | } | ||
1451 | |||
1452 | /** | ||
1453 | * @dataProvider provideErrorTestsForFormInheritingParentData | ||
1454 | */ | ||
1455 | public function testErrorMappingForFormInheritingParentData($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) | ||
1456 | { | ||
1457 | $violation = $this->getConstraintViolation($violationPath); | ||
1458 | $parent = $this->getForm('parent'); | ||
1459 | $child = $this->getForm($childName, $childPath, null, array(), true); | ||
1460 | $grandChild = $this->getForm($grandChildName, $grandChildPath); | ||
1461 | |||
1462 | $parent->add($child); | ||
1463 | $child->add($grandChild); | ||
1464 | |||
1465 | $this->mapper->mapViolation($violation, $parent); | ||
1466 | |||
1467 | if (self::LEVEL_0 === $target) { | ||
1468 | $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none'); | ||
1469 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1470 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1471 | } elseif (self::LEVEL_1 === $target) { | ||
1472 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1473 | $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none'); | ||
1474 | $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); | ||
1475 | } else { | ||
1476 | $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); | ||
1477 | $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); | ||
1478 | $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none'); | ||
1479 | } | ||
1480 | } | ||
1481 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php deleted file mode 100644 index 02df8f43..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ /dev/null | |||
@@ -1,245 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class ViolationPathTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function providePaths() | ||
22 | { | ||
23 | return array( | ||
24 | array('children[address]', array( | ||
25 | array('address', true, true), | ||
26 | )), | ||
27 | array('children[address].children[street]', array( | ||
28 | array('address', true, true), | ||
29 | array('street', true, true), | ||
30 | )), | ||
31 | array('children[address][street]', array( | ||
32 | array('address', true, true), | ||
33 | ), 'children[address]'), | ||
34 | array('children[address].data', array( | ||
35 | array('address', true, true), | ||
36 | ), 'children[address]'), | ||
37 | array('children[address].data.street', array( | ||
38 | array('address', true, true), | ||
39 | array('street', false, false), | ||
40 | )), | ||
41 | array('children[address].data[street]', array( | ||
42 | array('address', true, true), | ||
43 | array('street', false, true), | ||
44 | )), | ||
45 | array('children[address].children[street].data.name', array( | ||
46 | array('address', true, true), | ||
47 | array('street', true, true), | ||
48 | array('name', false, false), | ||
49 | )), | ||
50 | array('children[address].children[street].data[name]', array( | ||
51 | array('address', true, true), | ||
52 | array('street', true, true), | ||
53 | array('name', false, true), | ||
54 | )), | ||
55 | array('data.address', array( | ||
56 | array('address', false, false), | ||
57 | )), | ||
58 | array('data[address]', array( | ||
59 | array('address', false, true), | ||
60 | )), | ||
61 | array('data.address.street', array( | ||
62 | array('address', false, false), | ||
63 | array('street', false, false), | ||
64 | )), | ||
65 | array('data[address].street', array( | ||
66 | array('address', false, true), | ||
67 | array('street', false, false), | ||
68 | )), | ||
69 | array('data.address[street]', array( | ||
70 | array('address', false, false), | ||
71 | array('street', false, true), | ||
72 | )), | ||
73 | array('data[address][street]', array( | ||
74 | array('address', false, true), | ||
75 | array('street', false, true), | ||
76 | )), | ||
77 | // A few invalid examples | ||
78 | array('data', array(), ''), | ||
79 | array('children', array(), ''), | ||
80 | array('children.address', array(), ''), | ||
81 | array('children.address[street]', array(), ''), | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * @dataProvider providePaths | ||
87 | */ | ||
88 | public function testCreatePath($string, $entries, $slicedPath = null) | ||
89 | { | ||
90 | if (null === $slicedPath) { | ||
91 | $slicedPath = $string; | ||
92 | } | ||
93 | |||
94 | $path = new ViolationPath($string); | ||
95 | |||
96 | $this->assertSame($slicedPath, $path->__toString()); | ||
97 | $this->assertSame(count($entries), count($path->getElements())); | ||
98 | $this->assertSame(count($entries), $path->getLength()); | ||
99 | |||
100 | foreach ($entries as $index => $entry) { | ||
101 | $this->assertEquals($entry[0], $path->getElement($index)); | ||
102 | $this->assertSame($entry[1], $path->mapsForm($index)); | ||
103 | $this->assertSame($entry[2], $path->isIndex($index)); | ||
104 | $this->assertSame(!$entry[2], $path->isProperty($index)); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | public function provideParents() | ||
109 | { | ||
110 | return array( | ||
111 | array('children[address]', null), | ||
112 | array('children[address].children[street]', 'children[address]'), | ||
113 | array('children[address].data.street', 'children[address]'), | ||
114 | array('children[address].data[street]', 'children[address]'), | ||
115 | array('data.address', null), | ||
116 | array('data.address.street', 'data.address'), | ||
117 | array('data.address[street]', 'data.address'), | ||
118 | array('data[address].street', 'data[address]'), | ||
119 | array('data[address][street]', 'data[address]'), | ||
120 | ); | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * @dataProvider provideParents | ||
125 | */ | ||
126 | public function testGetParent($violationPath, $parentPath) | ||
127 | { | ||
128 | $path = new ViolationPath($violationPath); | ||
129 | $parent = $parentPath === null ? null : new ViolationPath($parentPath); | ||
130 | |||
131 | $this->assertEquals($parent, $path->getParent()); | ||
132 | } | ||
133 | |||
134 | public function testGetElement() | ||
135 | { | ||
136 | $path = new ViolationPath('children[address].data[street].name'); | ||
137 | |||
138 | $this->assertEquals('street', $path->getElement(1)); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * @expectedException \OutOfBoundsException | ||
143 | */ | ||
144 | public function testGetElementDoesNotAcceptInvalidIndices() | ||
145 | { | ||
146 | $path = new ViolationPath('children[address].data[street].name'); | ||
147 | |||
148 | $path->getElement(3); | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * @expectedException \OutOfBoundsException | ||
153 | */ | ||
154 | public function testGetElementDoesNotAcceptNegativeIndices() | ||
155 | { | ||
156 | $path = new ViolationPath('children[address].data[street].name'); | ||
157 | |||
158 | $path->getElement(-1); | ||
159 | } | ||
160 | |||
161 | public function testIsProperty() | ||
162 | { | ||
163 | $path = new ViolationPath('children[address].data[street].name'); | ||
164 | |||
165 | $this->assertFalse($path->isProperty(1)); | ||
166 | $this->assertTrue($path->isProperty(2)); | ||
167 | } | ||
168 | |||
169 | /** | ||
170 | * @expectedException \OutOfBoundsException | ||
171 | */ | ||
172 | public function testIsPropertyDoesNotAcceptInvalidIndices() | ||
173 | { | ||
174 | $path = new ViolationPath('children[address].data[street].name'); | ||
175 | |||
176 | $path->isProperty(3); | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * @expectedException \OutOfBoundsException | ||
181 | */ | ||
182 | public function testIsPropertyDoesNotAcceptNegativeIndices() | ||
183 | { | ||
184 | $path = new ViolationPath('children[address].data[street].name'); | ||
185 | |||
186 | $path->isProperty(-1); | ||
187 | } | ||
188 | |||
189 | public function testIsIndex() | ||
190 | { | ||
191 | $path = new ViolationPath('children[address].data[street].name'); | ||
192 | |||
193 | $this->assertTrue($path->isIndex(1)); | ||
194 | $this->assertFalse($path->isIndex(2)); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * @expectedException \OutOfBoundsException | ||
199 | */ | ||
200 | public function testIsIndexDoesNotAcceptInvalidIndices() | ||
201 | { | ||
202 | $path = new ViolationPath('children[address].data[street].name'); | ||
203 | |||
204 | $path->isIndex(3); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * @expectedException \OutOfBoundsException | ||
209 | */ | ||
210 | public function testIsIndexDoesNotAcceptNegativeIndices() | ||
211 | { | ||
212 | $path = new ViolationPath('children[address].data[street].name'); | ||
213 | |||
214 | $path->isIndex(-1); | ||
215 | } | ||
216 | |||
217 | public function testMapsForm() | ||
218 | { | ||
219 | $path = new ViolationPath('children[address].data[street].name'); | ||
220 | |||
221 | $this->assertTrue($path->mapsForm(0)); | ||
222 | $this->assertFalse($path->mapsForm(1)); | ||
223 | $this->assertFalse($path->mapsForm(2)); | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * @expectedException \OutOfBoundsException | ||
228 | */ | ||
229 | public function testMapsFormDoesNotAcceptInvalidIndices() | ||
230 | { | ||
231 | $path = new ViolationPath('children[address].data[street].name'); | ||
232 | |||
233 | $path->mapsForm(3); | ||
234 | } | ||
235 | |||
236 | /** | ||
237 | * @expectedException \OutOfBoundsException | ||
238 | */ | ||
239 | public function testMapsFormDoesNotAcceptNegativeIndices() | ||
240 | { | ||
241 | $path = new ViolationPath('children[address].data[street].name'); | ||
242 | |||
243 | $path->mapsForm(-1); | ||
244 | } | ||
245 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php deleted file mode 100644 index ee7d1353..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\FormEvents; | ||
7 | use Symfony\Component\Form\FormEvent; | ||
8 | use Symfony\Component\Form\FormBuilderInterface; | ||
9 | |||
10 | class AlternatingRowType extends AbstractType | ||
11 | { | ||
12 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
13 | { | ||
14 | $formFactory = $builder->getFormFactory(); | ||
15 | |||
16 | $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { | ||
17 | $form = $event->getForm(); | ||
18 | $type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; | ||
19 | $form->add('title', $type); | ||
20 | }); | ||
21 | } | ||
22 | |||
23 | public function getName() | ||
24 | { | ||
25 | return 'alternating_row'; | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php deleted file mode 100644 index 11204894..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | class Author | ||
15 | { | ||
16 | public $firstName; | ||
17 | private $lastName; | ||
18 | private $australian; | ||
19 | public $child; | ||
20 | private $readPermissions; | ||
21 | |||
22 | private $privateProperty; | ||
23 | |||
24 | public function setLastName($lastName) | ||
25 | { | ||
26 | $this->lastName = $lastName; | ||
27 | } | ||
28 | |||
29 | public function getLastName() | ||
30 | { | ||
31 | return $this->lastName; | ||
32 | } | ||
33 | |||
34 | private function getPrivateGetter() | ||
35 | { | ||
36 | return 'foobar'; | ||
37 | } | ||
38 | |||
39 | public function setAustralian($australian) | ||
40 | { | ||
41 | $this->australian = $australian; | ||
42 | } | ||
43 | |||
44 | public function isAustralian() | ||
45 | { | ||
46 | return $this->australian; | ||
47 | } | ||
48 | |||
49 | public function setReadPermissions($bool) | ||
50 | { | ||
51 | $this->readPermissions = $bool; | ||
52 | } | ||
53 | |||
54 | public function hasReadPermissions() | ||
55 | { | ||
56 | return $this->readPermissions; | ||
57 | } | ||
58 | |||
59 | private function isPrivateIsser() | ||
60 | { | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | public function getPrivateSetter() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | private function setPrivateSetter($data) | ||
69 | { | ||
70 | } | ||
71 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php deleted file mode 100644 index 147f6e48..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\FormBuilderInterface; | ||
7 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
8 | |||
9 | class AuthorType extends AbstractType | ||
10 | { | ||
11 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
12 | { | ||
13 | $builder | ||
14 | ->add('firstName') | ||
15 | ->add('lastName') | ||
16 | ; | ||
17 | } | ||
18 | |||
19 | public function getName() | ||
20 | { | ||
21 | return 'author'; | ||
22 | } | ||
23 | |||
24 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
25 | { | ||
26 | $resolver->setDefaults(array( | ||
27 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
28 | )); | ||
29 | } | ||
30 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php deleted file mode 100644 index 950f677f..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | /** | ||
15 | * This class is a hand written simplified version of PHP native `ArrayObject` | ||
16 | * class, to show that it behaves differently than the PHP native implementation. | ||
17 | */ | ||
18 | class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable | ||
19 | { | ||
20 | private $array; | ||
21 | |||
22 | public function __construct(array $array = null) | ||
23 | { | ||
24 | $this->array = $array ?: array(); | ||
25 | } | ||
26 | |||
27 | public function offsetExists($offset) | ||
28 | { | ||
29 | return array_key_exists($offset, $this->array); | ||
30 | } | ||
31 | |||
32 | public function offsetGet($offset) | ||
33 | { | ||
34 | return $this->array[$offset]; | ||
35 | } | ||
36 | |||
37 | public function offsetSet($offset, $value) | ||
38 | { | ||
39 | if (null === $offset) { | ||
40 | $this->array[] = $value; | ||
41 | } else { | ||
42 | $this->array[$offset] = $value; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public function offsetUnset($offset) | ||
47 | { | ||
48 | unset($this->array[$offset]); | ||
49 | } | ||
50 | |||
51 | public function getIterator() | ||
52 | { | ||
53 | return new \ArrayIterator($this->array); | ||
54 | } | ||
55 | |||
56 | public function count() | ||
57 | { | ||
58 | return count($this->array); | ||
59 | } | ||
60 | |||
61 | public function serialize() | ||
62 | { | ||
63 | return serialize($this->array); | ||
64 | } | ||
65 | |||
66 | public function unserialize($serialized) | ||
67 | { | ||
68 | $this->array = (array) unserialize((string) $serialized); | ||
69 | } | ||
70 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php deleted file mode 100644 index a5a31248..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\DataTransformerInterface; | ||
15 | use Symfony\Component\Form\Exception\RuntimeException; | ||
16 | |||
17 | class FixedDataTransformer implements DataTransformerInterface | ||
18 | { | ||
19 | private $mapping; | ||
20 | |||
21 | public function __construct(array $mapping) | ||
22 | { | ||
23 | $this->mapping = $mapping; | ||
24 | } | ||
25 | |||
26 | public function transform($value) | ||
27 | { | ||
28 | if (!array_key_exists($value, $this->mapping)) { | ||
29 | throw new RuntimeException(sprintf('No mapping for value "%s"', $value)); | ||
30 | } | ||
31 | |||
32 | return $this->mapping[$value]; | ||
33 | } | ||
34 | |||
35 | public function reverseTransform($value) | ||
36 | { | ||
37 | $result = array_search($value, $this->mapping, true); | ||
38 | |||
39 | if ($result === false) { | ||
40 | throw new RuntimeException(sprintf('No reverse mapping for value "%s"', $value)); | ||
41 | } | ||
42 | |||
43 | return $result; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php deleted file mode 100644 index 762a10b8..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvents; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
17 | |||
18 | class FixedFilterListener implements EventSubscriberInterface | ||
19 | { | ||
20 | private $mapping; | ||
21 | |||
22 | public function __construct(array $mapping) | ||
23 | { | ||
24 | $this->mapping = array_merge(array( | ||
25 | 'preSubmit' => array(), | ||
26 | 'onSubmit' => array(), | ||
27 | 'preSetData' => array(), | ||
28 | ), $mapping); | ||
29 | } | ||
30 | |||
31 | public function preSubmit(FormEvent $event) | ||
32 | { | ||
33 | $data = $event->getData(); | ||
34 | |||
35 | if (isset($this->mapping['preSubmit'][$data])) { | ||
36 | $event->setData($this->mapping['preSubmit'][$data]); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | public function onSubmit(FormEvent $event) | ||
41 | { | ||
42 | $data = $event->getData(); | ||
43 | |||
44 | if (isset($this->mapping['onSubmit'][$data])) { | ||
45 | $event->setData($this->mapping['onSubmit'][$data]); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public function preSetData(FormEvent $event) | ||
50 | { | ||
51 | $data = $event->getData(); | ||
52 | |||
53 | if (isset($this->mapping['preSetData'][$data])) { | ||
54 | $event->setData($this->mapping['preSetData'][$data]); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public static function getSubscribedEvents() | ||
59 | { | ||
60 | return array( | ||
61 | FormEvents::PRE_SUBMIT => 'preSubmit', | ||
62 | FormEvents::SUBMIT => 'onSubmit', | ||
63 | FormEvents::PRE_SET_DATA => 'preSetData', | ||
64 | ); | ||
65 | } | ||
66 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php deleted file mode 100644 index 4f7ba6d4..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooSubType extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo_sub_type'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return 'foo'; | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php deleted file mode 100644 index 468b5a32..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooSubTypeWithParentInstance extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo_sub_type_parent_instance'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return new FooType(); | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php deleted file mode 100644 index d26d3f76..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooType extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return null; | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php deleted file mode 100644 index c5f92e11..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractTypeExtension; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | |||
17 | class FooTypeBarExtension extends AbstractTypeExtension | ||
18 | { | ||
19 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | { | ||
21 | $builder->setAttribute('bar', 'x'); | ||
22 | } | ||
23 | |||
24 | public function getAllowedOptionValues() | ||
25 | { | ||
26 | return array( | ||
27 | 'a_or_b' => array('c'), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function getExtendedType() | ||
32 | { | ||
33 | return 'foo'; | ||
34 | } | ||
35 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php deleted file mode 100644 index 2e364754..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractTypeExtension; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | |||
17 | class FooTypeBazExtension extends AbstractTypeExtension | ||
18 | { | ||
19 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | { | ||
21 | $builder->setAttribute('baz', 'x'); | ||
22 | } | ||
23 | |||
24 | public function getExtendedType() | ||
25 | { | ||
26 | return 'foo'; | ||
27 | } | ||
28 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php deleted file mode 100644 index f9de560f..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\FormTypeInterface; | ||
15 | use Symfony\Component\Form\FormTypeExtensionInterface; | ||
16 | use Symfony\Component\Form\FormTypeGuesserInterface; | ||
17 | use Symfony\Component\Form\FormExtensionInterface; | ||
18 | |||
19 | class TestExtension implements FormExtensionInterface | ||
20 | { | ||
21 | private $types = array(); | ||
22 | |||
23 | private $extensions = array(); | ||
24 | |||
25 | private $guesser; | ||
26 | |||
27 | public function __construct(FormTypeGuesserInterface $guesser) | ||
28 | { | ||
29 | $this->guesser = $guesser; | ||
30 | } | ||
31 | |||
32 | public function addType(FormTypeInterface $type) | ||
33 | { | ||
34 | $this->types[$type->getName()] = $type; | ||
35 | } | ||
36 | |||
37 | public function getType($name) | ||
38 | { | ||
39 | return isset($this->types[$name]) ? $this->types[$name] : null; | ||
40 | } | ||
41 | |||
42 | public function hasType($name) | ||
43 | { | ||
44 | return isset($this->types[$name]); | ||
45 | } | ||
46 | |||
47 | public function addTypeExtension(FormTypeExtensionInterface $extension) | ||
48 | { | ||
49 | $type = $extension->getExtendedType(); | ||
50 | |||
51 | if (!isset($this->extensions[$type])) { | ||
52 | $this->extensions[$type] = array(); | ||
53 | } | ||
54 | |||
55 | $this->extensions[$type][] = $extension; | ||
56 | } | ||
57 | |||
58 | public function getTypeExtensions($name) | ||
59 | { | ||
60 | return isset($this->extensions[$name]) ? $this->extensions[$name] : array(); | ||
61 | } | ||
62 | |||
63 | public function hasTypeExtensions($name) | ||
64 | { | ||
65 | return isset($this->extensions[$name]); | ||
66 | } | ||
67 | |||
68 | public function getTypeGuesser() | ||
69 | { | ||
70 | return $this->guesser; | ||
71 | } | ||
72 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo deleted file mode 100644 index e69de29b..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo +++ /dev/null | |||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php deleted file mode 100644 index e076c97e..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | |||
16 | class FormBuilderTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | private $dispatcher; | ||
19 | |||
20 | private $factory; | ||
21 | |||
22 | private $builder; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
27 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
28 | } | ||
29 | |||
30 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
31 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
32 | $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); | ||
33 | } | ||
34 | |||
35 | protected function tearDown() | ||
36 | { | ||
37 | $this->dispatcher = null; | ||
38 | $this->factory = null; | ||
39 | $this->builder = null; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Changing the name is not allowed, otherwise the name and property path | ||
44 | * are not synchronized anymore | ||
45 | * | ||
46 | * @see FormType::buildForm | ||
47 | */ | ||
48 | public function testNoSetName() | ||
49 | { | ||
50 | $this->assertFalse(method_exists($this->builder, 'setName')); | ||
51 | } | ||
52 | |||
53 | public function testAddNameNoStringAndNoInteger() | ||
54 | { | ||
55 | $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); | ||
56 | $this->builder->add(true); | ||
57 | } | ||
58 | |||
59 | public function testAddTypeNoString() | ||
60 | { | ||
61 | $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); | ||
62 | $this->builder->add('foo', 1234); | ||
63 | } | ||
64 | |||
65 | public function testAddWithGuessFluent() | ||
66 | { | ||
67 | $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); | ||
68 | $builder = $this->builder->add('foo'); | ||
69 | $this->assertSame($builder, $this->builder); | ||
70 | } | ||
71 | |||
72 | public function testAddIsFluent() | ||
73 | { | ||
74 | $builder = $this->builder->add('foo', 'text', array('bar' => 'baz')); | ||
75 | $this->assertSame($builder, $this->builder); | ||
76 | } | ||
77 | |||
78 | public function testAdd() | ||
79 | { | ||
80 | $this->assertFalse($this->builder->has('foo')); | ||
81 | $this->builder->add('foo', 'text'); | ||
82 | $this->assertTrue($this->builder->has('foo')); | ||
83 | } | ||
84 | |||
85 | public function testAddIntegerName() | ||
86 | { | ||
87 | $this->assertFalse($this->builder->has(0)); | ||
88 | $this->builder->add(0, 'text'); | ||
89 | $this->assertTrue($this->builder->has(0)); | ||
90 | } | ||
91 | |||
92 | public function testAll() | ||
93 | { | ||
94 | $this->factory->expects($this->once()) | ||
95 | ->method('createNamedBuilder') | ||
96 | ->with('foo', 'text') | ||
97 | ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); | ||
98 | |||
99 | $this->assertCount(0, $this->builder->all()); | ||
100 | $this->assertFalse($this->builder->has('foo')); | ||
101 | |||
102 | $this->builder->add('foo', 'text'); | ||
103 | $children = $this->builder->all(); | ||
104 | |||
105 | $this->assertTrue($this->builder->has('foo')); | ||
106 | $this->assertCount(1, $children); | ||
107 | $this->assertArrayHasKey('foo', $children); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | * https://github.com/symfony/symfony/issues/4693 | ||
112 | */ | ||
113 | public function testMaintainOrderOfLazyAndExplicitChildren() | ||
114 | { | ||
115 | $this->builder->add('foo', 'text'); | ||
116 | $this->builder->add($this->getFormBuilder('bar')); | ||
117 | $this->builder->add('baz', 'text'); | ||
118 | |||
119 | $children = $this->builder->all(); | ||
120 | |||
121 | $this->assertSame(array('foo', 'bar', 'baz'), array_keys($children)); | ||
122 | } | ||
123 | |||
124 | public function testAddFormType() | ||
125 | { | ||
126 | $this->assertFalse($this->builder->has('foo')); | ||
127 | $this->builder->add('foo', $this->getMock('Symfony\Component\Form\FormTypeInterface')); | ||
128 | $this->assertTrue($this->builder->has('foo')); | ||
129 | } | ||
130 | |||
131 | public function testRemove() | ||
132 | { | ||
133 | $this->builder->add('foo', 'text'); | ||
134 | $this->builder->remove('foo'); | ||
135 | $this->assertFalse($this->builder->has('foo')); | ||
136 | } | ||
137 | |||
138 | public function testRemoveUnknown() | ||
139 | { | ||
140 | $this->builder->remove('foo'); | ||
141 | $this->assertFalse($this->builder->has('foo')); | ||
142 | } | ||
143 | |||
144 | // https://github.com/symfony/symfony/pull/4826 | ||
145 | public function testRemoveAndGetForm() | ||
146 | { | ||
147 | $this->builder->add('foo', 'text'); | ||
148 | $this->builder->remove('foo'); | ||
149 | $form = $this->builder->getForm(); | ||
150 | $this->assertInstanceOf('Symfony\Component\Form\Form', $form); | ||
151 | } | ||
152 | |||
153 | public function testCreateNoTypeNo() | ||
154 | { | ||
155 | $this->factory->expects($this->once()) | ||
156 | ->method('createNamedBuilder') | ||
157 | ->with('foo', 'text', null, array()) | ||
158 | ; | ||
159 | |||
160 | $this->builder->create('foo'); | ||
161 | } | ||
162 | |||
163 | public function testGetUnknown() | ||
164 | { | ||
165 | $this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.'); | ||
166 | $this->builder->get('foo'); | ||
167 | } | ||
168 | |||
169 | public function testGetExplicitType() | ||
170 | { | ||
171 | $expectedType = 'text'; | ||
172 | $expectedName = 'foo'; | ||
173 | $expectedOptions = array('bar' => 'baz'); | ||
174 | |||
175 | $this->factory->expects($this->once()) | ||
176 | ->method('createNamedBuilder') | ||
177 | ->with($expectedName, $expectedType, null, $expectedOptions) | ||
178 | ->will($this->returnValue($this->getFormBuilder())); | ||
179 | |||
180 | $this->builder->add($expectedName, $expectedType, $expectedOptions); | ||
181 | $builder = $this->builder->get($expectedName); | ||
182 | |||
183 | $this->assertNotSame($builder, $this->builder); | ||
184 | } | ||
185 | |||
186 | public function testGetGuessedType() | ||
187 | { | ||
188 | $expectedName = 'foo'; | ||
189 | $expectedOptions = array('bar' => 'baz'); | ||
190 | |||
191 | $this->factory->expects($this->once()) | ||
192 | ->method('createBuilderForProperty') | ||
193 | ->with('stdClass', $expectedName, null, $expectedOptions) | ||
194 | ->will($this->returnValue($this->getFormBuilder())); | ||
195 | |||
196 | $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); | ||
197 | $this->builder->add($expectedName, null, $expectedOptions); | ||
198 | $builder = $this->builder->get($expectedName); | ||
199 | |||
200 | $this->assertNotSame($builder, $this->builder); | ||
201 | } | ||
202 | |||
203 | public function testGetFormConfigErasesReferences() | ||
204 | { | ||
205 | $builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); | ||
206 | $builder->add(new FormBuilder('child', null, $this->dispatcher, $this->factory)); | ||
207 | |||
208 | $config = $builder->getFormConfig(); | ||
209 | $reflClass = new \ReflectionClass($config); | ||
210 | $children = $reflClass->getProperty('children'); | ||
211 | $unresolvedChildren = $reflClass->getProperty('unresolvedChildren'); | ||
212 | |||
213 | $children->setAccessible(true); | ||
214 | $unresolvedChildren->setAccessible(true); | ||
215 | |||
216 | $this->assertEmpty($children->getValue($config)); | ||
217 | $this->assertEmpty($unresolvedChildren->getValue($config)); | ||
218 | } | ||
219 | |||
220 | private function getFormBuilder($name = 'name') | ||
221 | { | ||
222 | $mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') | ||
223 | ->disableOriginalConstructor() | ||
224 | ->getMock(); | ||
225 | |||
226 | $mock->expects($this->any()) | ||
227 | ->method('getName') | ||
228 | ->will($this->returnValue($name)); | ||
229 | |||
230 | return $mock; | ||
231 | } | ||
232 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php deleted file mode 100644 index 961dfd33..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\Exception\UnexpectedTypeException; | ||
15 | use Symfony\Component\Form\FormConfigBuilder; | ||
16 | use Symfony\Component\Form\Exception\InvalidArgumentException; | ||
17 | |||
18 | /** | ||
19 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
20 | */ | ||
21 | class FormConfigTest extends \PHPUnit_Framework_TestCase | ||
22 | { | ||
23 | public function getHtml4Ids() | ||
24 | { | ||
25 | return array( | ||
26 | array('z0', true), | ||
27 | array('A0', true), | ||
28 | array('A9', true), | ||
29 | array('Z0', true), | ||
30 | array('#', false), | ||
31 | array('a#', false), | ||
32 | array('a$', false), | ||
33 | array('a%', false), | ||
34 | array('a ', false), | ||
35 | array("a\t", false), | ||
36 | array("a\n", false), | ||
37 | array('a-', true), | ||
38 | array('a_', true), | ||
39 | array('a:', true), | ||
40 | // Periods are allowed by the HTML4 spec, but disallowed by us | ||
41 | // because they break the generated property paths | ||
42 | array('a.', false), | ||
43 | // Contrary to the HTML4 spec, we allow names starting with a | ||
44 | // number, otherwise naming fields by collection indices is not | ||
45 | // possible. | ||
46 | // For root forms, leading digits will be stripped from the | ||
47 | // "id" attribute to produce valid HTML4. | ||
48 | array('0', true), | ||
49 | array('9', true), | ||
50 | // Contrary to the HTML4 spec, we allow names starting with an | ||
51 | // underscore, since this is already a widely used practice in | ||
52 | // Symfony2. | ||
53 | // For root forms, leading underscores will be stripped from the | ||
54 | // "id" attribute to produce valid HTML4. | ||
55 | array('_', true), | ||
56 | // Integers are allowed | ||
57 | array(0, true), | ||
58 | array(123, true), | ||
59 | // NULL is allowed | ||
60 | array(null, true), | ||
61 | // Other types are not | ||
62 | array(1.23, false), | ||
63 | array(5., false), | ||
64 | array(true, false), | ||
65 | array(new \stdClass(), false), | ||
66 | ); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @dataProvider getHtml4Ids | ||
71 | */ | ||
72 | public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $accepted) | ||
73 | { | ||
74 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
75 | |||
76 | try { | ||
77 | new FormConfigBuilder($name, null, $dispatcher); | ||
78 | if (!$accepted) { | ||
79 | $this->fail(sprintf('The value "%s" should not be accepted', $name)); | ||
80 | } | ||
81 | } catch (UnexpectedTypeException $e) { | ||
82 | // if the value was not accepted, but should be, rethrow exception | ||
83 | if ($accepted) { | ||
84 | throw $e; | ||
85 | } | ||
86 | } catch (InvalidArgumentException $e) { | ||
87 | // if the value was not accepted, but should be, rethrow exception | ||
88 | if ($accepted) { | ||
89 | throw $e; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public function testGetRequestHandlerCreatesNativeRequestHandlerIfNotSet() | ||
95 | { | ||
96 | $config = $this->getConfigBuilder()->getFormConfig(); | ||
97 | |||
98 | $this->assertInstanceOf('Symfony\Component\Form\NativeRequestHandler', $config->getRequestHandler()); | ||
99 | } | ||
100 | |||
101 | public function testGetRequestHandlerReusesNativeRequestHandlerInstance() | ||
102 | { | ||
103 | $config1 = $this->getConfigBuilder()->getFormConfig(); | ||
104 | $config2 = $this->getConfigBuilder()->getFormConfig(); | ||
105 | |||
106 | $this->assertSame($config1->getRequestHandler(), $config2->getRequestHandler()); | ||
107 | } | ||
108 | |||
109 | public function testSetMethodAllowsGet() | ||
110 | { | ||
111 | $this->getConfigBuilder()->setMethod('GET'); | ||
112 | } | ||
113 | |||
114 | public function testSetMethodAllowsPost() | ||
115 | { | ||
116 | $this->getConfigBuilder()->setMethod('POST'); | ||
117 | } | ||
118 | |||
119 | public function testSetMethodAllowsPut() | ||
120 | { | ||
121 | $this->getConfigBuilder()->setMethod('PUT'); | ||
122 | } | ||
123 | |||
124 | public function testSetMethodAllowsDelete() | ||
125 | { | ||
126 | $this->getConfigBuilder()->setMethod('DELETE'); | ||
127 | } | ||
128 | |||
129 | public function testSetMethodAllowsPatch() | ||
130 | { | ||
131 | $this->getConfigBuilder()->setMethod('PATCH'); | ||
132 | } | ||
133 | |||
134 | /** | ||
135 | * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException | ||
136 | */ | ||
137 | public function testSetMethodDoesNotAllowOtherValues() | ||
138 | { | ||
139 | $this->getConfigBuilder()->setMethod('foo'); | ||
140 | } | ||
141 | |||
142 | private function getConfigBuilder($name = 'name') | ||
143 | { | ||
144 | $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
145 | |||
146 | return new FormConfigBuilder($name, null, $dispatcher); | ||
147 | } | ||
148 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php deleted file mode 100644 index a1292dbe..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormFactoryBuilder; | ||
15 | use Symfony\Component\Form\Tests\Fixtures\FooType; | ||
16 | |||
17 | class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | private $registry; | ||
20 | private $guesser; | ||
21 | private $type; | ||
22 | |||
23 | protected function setUp() | ||
24 | { | ||
25 | $factory = new \ReflectionClass('Symfony\Component\Form\FormFactory'); | ||
26 | $this->registry = $factory->getProperty('registry'); | ||
27 | $this->registry->setAccessible(true); | ||
28 | |||
29 | $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); | ||
30 | $this->type = new FooType; | ||
31 | } | ||
32 | |||
33 | public function testAddType() | ||
34 | { | ||
35 | $factoryBuilder = new FormFactoryBuilder; | ||
36 | $factoryBuilder->addType($this->type); | ||
37 | |||
38 | $factory = $factoryBuilder->getFormFactory(); | ||
39 | $registry = $this->registry->getValue($factory); | ||
40 | $extensions = $registry->getExtensions(); | ||
41 | |||
42 | $this->assertCount(1, $extensions); | ||
43 | $this->assertTrue($extensions[0]->hasType($this->type->getName())); | ||
44 | $this->assertNull($extensions[0]->getTypeGuesser()); | ||
45 | } | ||
46 | |||
47 | public function testAddTypeGuesser() | ||
48 | { | ||
49 | $factoryBuilder = new FormFactoryBuilder; | ||
50 | $factoryBuilder->addTypeGuesser($this->guesser); | ||
51 | |||
52 | $factory = $factoryBuilder->getFormFactory(); | ||
53 | $registry = $this->registry->getValue($factory); | ||
54 | $extensions = $registry->getExtensions(); | ||
55 | |||
56 | $this->assertCount(1, $extensions); | ||
57 | $this->assertNotNull($extensions[0]->getTypeGuesser()); | ||
58 | } | ||
59 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php deleted file mode 100644 index ea872b01..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php +++ /dev/null | |||
@@ -1,506 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormTypeGuesserChain; | ||
15 | use Symfony\Component\Form\FormFactory; | ||
16 | use Symfony\Component\Form\Guess\Guess; | ||
17 | use Symfony\Component\Form\Guess\ValueGuess; | ||
18 | use Symfony\Component\Form\Guess\TypeGuess; | ||
19 | use Symfony\Component\Form\Tests\Fixtures\Author; | ||
20 | use Symfony\Component\Form\Tests\Fixtures\FooType; | ||
21 | use Symfony\Component\Form\Tests\Fixtures\FooSubType; | ||
22 | use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; | ||
23 | |||
24 | /** | ||
25 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
26 | */ | ||
27 | class FormFactoryTest extends \PHPUnit_Framework_TestCase | ||
28 | { | ||
29 | /** | ||
30 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
31 | */ | ||
32 | private $guesser1; | ||
33 | |||
34 | /** | ||
35 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
36 | */ | ||
37 | private $guesser2; | ||
38 | |||
39 | /** | ||
40 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
41 | */ | ||
42 | private $registry; | ||
43 | |||
44 | /** | ||
45 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
46 | */ | ||
47 | private $resolvedTypeFactory; | ||
48 | |||
49 | /** | ||
50 | * @var FormFactory | ||
51 | */ | ||
52 | private $factory; | ||
53 | |||
54 | protected function setUp() | ||
55 | { | ||
56 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
57 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
58 | } | ||
59 | |||
60 | $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactoryInterface'); | ||
61 | $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); | ||
62 | $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); | ||
63 | $this->registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); | ||
64 | $this->factory = new FormFactory($this->registry, $this->resolvedTypeFactory); | ||
65 | |||
66 | $this->registry->expects($this->any()) | ||
67 | ->method('getTypeGuesser') | ||
68 | ->will($this->returnValue(new FormTypeGuesserChain(array( | ||
69 | $this->guesser1, | ||
70 | $this->guesser2, | ||
71 | )))); | ||
72 | } | ||
73 | |||
74 | public function testCreateNamedBuilderWithTypeName() | ||
75 | { | ||
76 | $options = array('a' => '1', 'b' => '2'); | ||
77 | $resolvedType = $this->getMockResolvedType(); | ||
78 | |||
79 | $this->registry->expects($this->once()) | ||
80 | ->method('getType') | ||
81 | ->with('type') | ||
82 | ->will($this->returnValue($resolvedType)); | ||
83 | |||
84 | $resolvedType->expects($this->once()) | ||
85 | ->method('createBuilder') | ||
86 | ->with($this->factory, 'name', $options) | ||
87 | ->will($this->returnValue('BUILDER')); | ||
88 | |||
89 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', 'type', null, $options)); | ||
90 | } | ||
91 | |||
92 | public function testCreateNamedBuilderWithTypeInstance() | ||
93 | { | ||
94 | $options = array('a' => '1', 'b' => '2'); | ||
95 | $type = new FooType(); | ||
96 | $resolvedType = $this->getMockResolvedType(); | ||
97 | |||
98 | $this->resolvedTypeFactory->expects($this->once()) | ||
99 | ->method('createResolvedType') | ||
100 | ->with($type) | ||
101 | ->will($this->returnValue($resolvedType)); | ||
102 | |||
103 | $resolvedType->expects($this->once()) | ||
104 | ->method('createBuilder') | ||
105 | ->with($this->factory, 'name', $options) | ||
106 | ->will($this->returnValue('BUILDER')); | ||
107 | |||
108 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', $type, null, $options)); | ||
109 | } | ||
110 | |||
111 | public function testCreateNamedBuilderWithTypeInstanceWithParentType() | ||
112 | { | ||
113 | $options = array('a' => '1', 'b' => '2'); | ||
114 | $type = new FooSubType(); | ||
115 | $resolvedType = $this->getMockResolvedType(); | ||
116 | $parentResolvedType = $this->getMockResolvedType(); | ||
117 | |||
118 | $this->registry->expects($this->once()) | ||
119 | ->method('getType') | ||
120 | ->with('foo') | ||
121 | ->will($this->returnValue($parentResolvedType)); | ||
122 | |||
123 | $this->resolvedTypeFactory->expects($this->once()) | ||
124 | ->method('createResolvedType') | ||
125 | ->with($type, array(), $parentResolvedType) | ||
126 | ->will($this->returnValue($resolvedType)); | ||
127 | |||
128 | $resolvedType->expects($this->once()) | ||
129 | ->method('createBuilder') | ||
130 | ->with($this->factory, 'name', $options) | ||
131 | ->will($this->returnValue('BUILDER')); | ||
132 | |||
133 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', $type, null, $options)); | ||
134 | } | ||
135 | |||
136 | public function testCreateNamedBuilderWithTypeInstanceWithParentTypeInstance() | ||
137 | { | ||
138 | $options = array('a' => '1', 'b' => '2'); | ||
139 | $type = new FooSubTypeWithParentInstance(); | ||
140 | $resolvedType = $this->getMockResolvedType(); | ||
141 | $parentResolvedType = $this->getMockResolvedType(); | ||
142 | |||
143 | $this->resolvedTypeFactory->expects($this->at(0)) | ||
144 | ->method('createResolvedType') | ||
145 | ->with($type->getParent()) | ||
146 | ->will($this->returnValue($parentResolvedType)); | ||
147 | |||
148 | $this->resolvedTypeFactory->expects($this->at(1)) | ||
149 | ->method('createResolvedType') | ||
150 | ->with($type, array(), $parentResolvedType) | ||
151 | ->will($this->returnValue($resolvedType)); | ||
152 | |||
153 | $resolvedType->expects($this->once()) | ||
154 | ->method('createBuilder') | ||
155 | ->with($this->factory, 'name', $options) | ||
156 | ->will($this->returnValue('BUILDER')); | ||
157 | |||
158 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', $type, null, $options)); | ||
159 | } | ||
160 | |||
161 | public function testCreateNamedBuilderWithResolvedTypeInstance() | ||
162 | { | ||
163 | $options = array('a' => '1', 'b' => '2'); | ||
164 | $resolvedType = $this->getMockResolvedType(); | ||
165 | |||
166 | $resolvedType->expects($this->once()) | ||
167 | ->method('createBuilder') | ||
168 | ->with($this->factory, 'name', $options) | ||
169 | ->will($this->returnValue('BUILDER')); | ||
170 | |||
171 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', $resolvedType, null, $options)); | ||
172 | } | ||
173 | |||
174 | public function testCreateNamedBuilderFillsDataOption() | ||
175 | { | ||
176 | $givenOptions = array('a' => '1', 'b' => '2'); | ||
177 | $expectedOptions = array_merge($givenOptions, array('data' => 'DATA')); | ||
178 | $resolvedType = $this->getMockResolvedType(); | ||
179 | |||
180 | $this->registry->expects($this->once()) | ||
181 | ->method('getType') | ||
182 | ->with('type') | ||
183 | ->will($this->returnValue($resolvedType)); | ||
184 | |||
185 | $resolvedType->expects($this->once()) | ||
186 | ->method('createBuilder') | ||
187 | ->with($this->factory, 'name', $expectedOptions) | ||
188 | ->will($this->returnValue('BUILDER')); | ||
189 | |||
190 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', 'type', 'DATA', $givenOptions)); | ||
191 | } | ||
192 | |||
193 | public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() | ||
194 | { | ||
195 | $options = array('a' => '1', 'b' => '2', 'data' => 'CUSTOM'); | ||
196 | $resolvedType = $this->getMockResolvedType(); | ||
197 | |||
198 | $this->registry->expects($this->once()) | ||
199 | ->method('getType') | ||
200 | ->with('type') | ||
201 | ->will($this->returnValue($resolvedType)); | ||
202 | |||
203 | $resolvedType->expects($this->once()) | ||
204 | ->method('createBuilder') | ||
205 | ->with($this->factory, 'name', $options) | ||
206 | ->will($this->returnValue('BUILDER')); | ||
207 | |||
208 | $this->assertSame('BUILDER', $this->factory->createNamedBuilder('name', 'type', 'DATA', $options)); | ||
209 | } | ||
210 | |||
211 | /** | ||
212 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
213 | * @expectedExceptionMessage Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "stdClass" given | ||
214 | */ | ||
215 | public function testCreateNamedBuilderThrowsUnderstandableException() | ||
216 | { | ||
217 | $this->factory->createNamedBuilder('name', new \stdClass()); | ||
218 | } | ||
219 | |||
220 | public function testCreateUsesTypeNameIfTypeGivenAsString() | ||
221 | { | ||
222 | $options = array('a' => '1', 'b' => '2'); | ||
223 | $resolvedType = $this->getMockResolvedType(); | ||
224 | $builder = $this->getMockFormBuilder(); | ||
225 | |||
226 | $this->registry->expects($this->once()) | ||
227 | ->method('getType') | ||
228 | ->with('TYPE') | ||
229 | ->will($this->returnValue($resolvedType)); | ||
230 | |||
231 | $resolvedType->expects($this->once()) | ||
232 | ->method('createBuilder') | ||
233 | ->with($this->factory, 'TYPE', $options) | ||
234 | ->will($this->returnValue($builder)); | ||
235 | |||
236 | $builder->expects($this->once()) | ||
237 | ->method('getForm') | ||
238 | ->will($this->returnValue('FORM')); | ||
239 | |||
240 | $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); | ||
241 | } | ||
242 | |||
243 | public function testCreateUsesTypeNameIfTypeGivenAsObject() | ||
244 | { | ||
245 | $options = array('a' => '1', 'b' => '2'); | ||
246 | $resolvedType = $this->getMockResolvedType(); | ||
247 | $builder = $this->getMockFormBuilder(); | ||
248 | |||
249 | $resolvedType->expects($this->once()) | ||
250 | ->method('getName') | ||
251 | ->will($this->returnValue('TYPE')); | ||
252 | |||
253 | $resolvedType->expects($this->once()) | ||
254 | ->method('createBuilder') | ||
255 | ->with($this->factory, 'TYPE', $options) | ||
256 | ->will($this->returnValue($builder)); | ||
257 | |||
258 | $builder->expects($this->once()) | ||
259 | ->method('getForm') | ||
260 | ->will($this->returnValue('FORM')); | ||
261 | |||
262 | $this->assertSame('FORM', $this->factory->create($resolvedType, null, $options)); | ||
263 | } | ||
264 | |||
265 | public function testCreateNamed() | ||
266 | { | ||
267 | $options = array('a' => '1', 'b' => '2'); | ||
268 | $resolvedType = $this->getMockResolvedType(); | ||
269 | $builder = $this->getMockFormBuilder(); | ||
270 | |||
271 | $this->registry->expects($this->once()) | ||
272 | ->method('getType') | ||
273 | ->with('type') | ||
274 | ->will($this->returnValue($resolvedType)); | ||
275 | |||
276 | $resolvedType->expects($this->once()) | ||
277 | ->method('createBuilder') | ||
278 | ->with($this->factory, 'name', $options) | ||
279 | ->will($this->returnValue($builder)); | ||
280 | |||
281 | $builder->expects($this->once()) | ||
282 | ->method('getForm') | ||
283 | ->will($this->returnValue('FORM')); | ||
284 | |||
285 | $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); | ||
286 | } | ||
287 | |||
288 | public function testCreateBuilderForPropertyWithoutTypeGuesser() | ||
289 | { | ||
290 | $registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); | ||
291 | $factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory') | ||
292 | ->setMethods(array('createNamedBuilder')) | ||
293 | ->setConstructorArgs(array($registry, $this->resolvedTypeFactory)) | ||
294 | ->getMock(); | ||
295 | |||
296 | $factory->expects($this->once()) | ||
297 | ->method('createNamedBuilder') | ||
298 | ->with('firstName', 'text', null, array()) | ||
299 | ->will($this->returnValue('builderInstance')); | ||
300 | |||
301 | $builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); | ||
302 | |||
303 | $this->assertEquals('builderInstance', $builder); | ||
304 | } | ||
305 | |||
306 | public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() | ||
307 | { | ||
308 | $this->guesser1->expects($this->once()) | ||
309 | ->method('guessType') | ||
310 | ->with('Application\Author', 'firstName') | ||
311 | ->will($this->returnValue(new TypeGuess( | ||
312 | 'text', | ||
313 | array('max_length' => 10), | ||
314 | Guess::MEDIUM_CONFIDENCE | ||
315 | ))); | ||
316 | |||
317 | $this->guesser2->expects($this->once()) | ||
318 | ->method('guessType') | ||
319 | ->with('Application\Author', 'firstName') | ||
320 | ->will($this->returnValue(new TypeGuess( | ||
321 | 'password', | ||
322 | array('max_length' => 7), | ||
323 | Guess::HIGH_CONFIDENCE | ||
324 | ))); | ||
325 | |||
326 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
327 | |||
328 | $factory->expects($this->once()) | ||
329 | ->method('createNamedBuilder') | ||
330 | ->with('firstName', 'password', null, array('max_length' => 7)) | ||
331 | ->will($this->returnValue('builderInstance')); | ||
332 | |||
333 | $builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); | ||
334 | |||
335 | $this->assertEquals('builderInstance', $builder); | ||
336 | } | ||
337 | |||
338 | public function testCreateBuilderCreatesTextFormIfNoGuess() | ||
339 | { | ||
340 | $this->guesser1->expects($this->once()) | ||
341 | ->method('guessType') | ||
342 | ->with('Application\Author', 'firstName') | ||
343 | ->will($this->returnValue(null)); | ||
344 | |||
345 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
346 | |||
347 | $factory->expects($this->once()) | ||
348 | ->method('createNamedBuilder') | ||
349 | ->with('firstName', 'text') | ||
350 | ->will($this->returnValue('builderInstance')); | ||
351 | |||
352 | $builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); | ||
353 | |||
354 | $this->assertEquals('builderInstance', $builder); | ||
355 | } | ||
356 | |||
357 | public function testOptionsCanBeOverridden() | ||
358 | { | ||
359 | $this->guesser1->expects($this->once()) | ||
360 | ->method('guessType') | ||
361 | ->with('Application\Author', 'firstName') | ||
362 | ->will($this->returnValue(new TypeGuess( | ||
363 | 'text', | ||
364 | array('max_length' => 10), | ||
365 | Guess::MEDIUM_CONFIDENCE | ||
366 | ))); | ||
367 | |||
368 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
369 | |||
370 | $factory->expects($this->once()) | ||
371 | ->method('createNamedBuilder') | ||
372 | ->with('firstName', 'text', null, array('max_length' => 11)) | ||
373 | ->will($this->returnValue('builderInstance')); | ||
374 | |||
375 | $builder = $factory->createBuilderForProperty( | ||
376 | 'Application\Author', | ||
377 | 'firstName', | ||
378 | null, | ||
379 | array('max_length' => 11) | ||
380 | ); | ||
381 | |||
382 | $this->assertEquals('builderInstance', $builder); | ||
383 | } | ||
384 | |||
385 | public function testCreateBuilderUsesMaxLengthIfFound() | ||
386 | { | ||
387 | $this->guesser1->expects($this->once()) | ||
388 | ->method('guessMaxLength') | ||
389 | ->with('Application\Author', 'firstName') | ||
390 | ->will($this->returnValue(new ValueGuess( | ||
391 | 15, | ||
392 | Guess::MEDIUM_CONFIDENCE | ||
393 | ))); | ||
394 | |||
395 | $this->guesser2->expects($this->once()) | ||
396 | ->method('guessMaxLength') | ||
397 | ->with('Application\Author', 'firstName') | ||
398 | ->will($this->returnValue(new ValueGuess( | ||
399 | 20, | ||
400 | Guess::HIGH_CONFIDENCE | ||
401 | ))); | ||
402 | |||
403 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
404 | |||
405 | $factory->expects($this->once()) | ||
406 | ->method('createNamedBuilder') | ||
407 | ->with('firstName', 'text', null, array('max_length' => 20)) | ||
408 | ->will($this->returnValue('builderInstance')); | ||
409 | |||
410 | $builder = $factory->createBuilderForProperty( | ||
411 | 'Application\Author', | ||
412 | 'firstName' | ||
413 | ); | ||
414 | |||
415 | $this->assertEquals('builderInstance', $builder); | ||
416 | } | ||
417 | |||
418 | public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() | ||
419 | { | ||
420 | $this->guesser1->expects($this->once()) | ||
421 | ->method('guessRequired') | ||
422 | ->with('Application\Author', 'firstName') | ||
423 | ->will($this->returnValue(new ValueGuess( | ||
424 | true, | ||
425 | Guess::MEDIUM_CONFIDENCE | ||
426 | ))); | ||
427 | |||
428 | $this->guesser2->expects($this->once()) | ||
429 | ->method('guessRequired') | ||
430 | ->with('Application\Author', 'firstName') | ||
431 | ->will($this->returnValue(new ValueGuess( | ||
432 | false, | ||
433 | Guess::HIGH_CONFIDENCE | ||
434 | ))); | ||
435 | |||
436 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
437 | |||
438 | $factory->expects($this->once()) | ||
439 | ->method('createNamedBuilder') | ||
440 | ->with('firstName', 'text', null, array('required' => false)) | ||
441 | ->will($this->returnValue('builderInstance')); | ||
442 | |||
443 | $builder = $factory->createBuilderForProperty( | ||
444 | 'Application\Author', | ||
445 | 'firstName' | ||
446 | ); | ||
447 | |||
448 | $this->assertEquals('builderInstance', $builder); | ||
449 | } | ||
450 | |||
451 | public function testCreateBuilderUsesPatternIfFound() | ||
452 | { | ||
453 | $this->guesser1->expects($this->once()) | ||
454 | ->method('guessPattern') | ||
455 | ->with('Application\Author', 'firstName') | ||
456 | ->will($this->returnValue(new ValueGuess( | ||
457 | '[a-z]', | ||
458 | Guess::MEDIUM_CONFIDENCE | ||
459 | ))); | ||
460 | |||
461 | $this->guesser2->expects($this->once()) | ||
462 | ->method('guessPattern') | ||
463 | ->with('Application\Author', 'firstName') | ||
464 | ->will($this->returnValue(new ValueGuess( | ||
465 | '[a-zA-Z]', | ||
466 | Guess::HIGH_CONFIDENCE | ||
467 | ))); | ||
468 | |||
469 | $factory = $this->getMockFactory(array('createNamedBuilder')); | ||
470 | |||
471 | $factory->expects($this->once()) | ||
472 | ->method('createNamedBuilder') | ||
473 | ->with('firstName', 'text', null, array('pattern' => '[a-zA-Z]')) | ||
474 | ->will($this->returnValue('builderInstance')); | ||
475 | |||
476 | $builder = $factory->createBuilderForProperty( | ||
477 | 'Application\Author', | ||
478 | 'firstName' | ||
479 | ); | ||
480 | |||
481 | $this->assertEquals('builderInstance', $builder); | ||
482 | } | ||
483 | |||
484 | private function getMockFactory(array $methods = array()) | ||
485 | { | ||
486 | return $this->getMockBuilder('Symfony\Component\Form\FormFactory') | ||
487 | ->setMethods($methods) | ||
488 | ->setConstructorArgs(array($this->registry, $this->resolvedTypeFactory)) | ||
489 | ->getMock(); | ||
490 | } | ||
491 | |||
492 | private function getMockResolvedType() | ||
493 | { | ||
494 | return $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
495 | } | ||
496 | |||
497 | private function getMockType() | ||
498 | { | ||
499 | return $this->getMock('Symfony\Component\Form\FormTypeInterface'); | ||
500 | } | ||
501 | |||
502 | private function getMockFormBuilder() | ||
503 | { | ||
504 | return $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); | ||
505 | } | ||
506 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php deleted file mode 100644 index 763286c2..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\Test\FormIntegrationTestCase as BaseFormIntegrationTestCase; | ||
15 | |||
16 | /** | ||
17 | * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormIntegrationTestCase instead. | ||
18 | */ | ||
19 | abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php deleted file mode 100644 index 39882e85..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\Test\FormPerformanceTestCase as BaseFormPerformanceTestCase; | ||
15 | |||
16 | /** | ||
17 | * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormPerformanceTestCase instead. | ||
18 | */ | ||
19 | abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php deleted file mode 100644 index 0c8bb6b4..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\FormRegistry; | ||
15 | use Symfony\Component\Form\FormTypeGuesserChain; | ||
16 | use Symfony\Component\Form\Tests\Fixtures\TestExtension; | ||
17 | use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; | ||
18 | use Symfony\Component\Form\Tests\Fixtures\FooSubType; | ||
19 | use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension; | ||
20 | use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension; | ||
21 | use Symfony\Component\Form\Tests\Fixtures\FooType; | ||
22 | |||
23 | /** | ||
24 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
25 | */ | ||
26 | class FormRegistryTest extends \PHPUnit_Framework_TestCase | ||
27 | { | ||
28 | /** | ||
29 | * @var FormRegistry | ||
30 | */ | ||
31 | private $registry; | ||
32 | |||
33 | /** | ||
34 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
35 | */ | ||
36 | private $resolvedTypeFactory; | ||
37 | |||
38 | /** | ||
39 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
40 | */ | ||
41 | private $guesser1; | ||
42 | |||
43 | /** | ||
44 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
45 | */ | ||
46 | private $guesser2; | ||
47 | |||
48 | /** | ||
49 | * @var TestExtension | ||
50 | */ | ||
51 | private $extension1; | ||
52 | |||
53 | /** | ||
54 | * @var TestExtension | ||
55 | */ | ||
56 | private $extension2; | ||
57 | |||
58 | protected function setUp() | ||
59 | { | ||
60 | $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactory'); | ||
61 | $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); | ||
62 | $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); | ||
63 | $this->extension1 = new TestExtension($this->guesser1); | ||
64 | $this->extension2 = new TestExtension($this->guesser2); | ||
65 | $this->registry = new FormRegistry(array( | ||
66 | $this->extension1, | ||
67 | $this->extension2, | ||
68 | ), $this->resolvedTypeFactory); | ||
69 | } | ||
70 | |||
71 | public function testGetTypeFromExtension() | ||
72 | { | ||
73 | $type = new FooType(); | ||
74 | $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
75 | |||
76 | $this->extension2->addType($type); | ||
77 | |||
78 | $this->resolvedTypeFactory->expects($this->once()) | ||
79 | ->method('createResolvedType') | ||
80 | ->with($type) | ||
81 | ->will($this->returnValue($resolvedType)); | ||
82 | |||
83 | $resolvedType->expects($this->any()) | ||
84 | ->method('getName') | ||
85 | ->will($this->returnValue('foo')); | ||
86 | |||
87 | $resolvedType = $this->registry->getType('foo'); | ||
88 | |||
89 | $this->assertSame($resolvedType, $this->registry->getType('foo')); | ||
90 | } | ||
91 | |||
92 | public function testGetTypeWithTypeExtensions() | ||
93 | { | ||
94 | $type = new FooType(); | ||
95 | $ext1 = new FooTypeBarExtension(); | ||
96 | $ext2 = new FooTypeBazExtension(); | ||
97 | $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
98 | |||
99 | $this->extension2->addType($type); | ||
100 | $this->extension1->addTypeExtension($ext1); | ||
101 | $this->extension2->addTypeExtension($ext2); | ||
102 | |||
103 | $this->resolvedTypeFactory->expects($this->once()) | ||
104 | ->method('createResolvedType') | ||
105 | ->with($type, array($ext1, $ext2)) | ||
106 | ->will($this->returnValue($resolvedType)); | ||
107 | |||
108 | $resolvedType->expects($this->any()) | ||
109 | ->method('getName') | ||
110 | ->will($this->returnValue('foo')); | ||
111 | |||
112 | $this->assertSame($resolvedType, $this->registry->getType('foo')); | ||
113 | } | ||
114 | |||
115 | public function testGetTypeConnectsParent() | ||
116 | { | ||
117 | $parentType = new FooType(); | ||
118 | $type = new FooSubType(); | ||
119 | $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
120 | $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
121 | |||
122 | $this->extension1->addType($parentType); | ||
123 | $this->extension2->addType($type); | ||
124 | |||
125 | $this->resolvedTypeFactory->expects($this->at(0)) | ||
126 | ->method('createResolvedType') | ||
127 | ->with($parentType) | ||
128 | ->will($this->returnValue($parentResolvedType)); | ||
129 | |||
130 | $this->resolvedTypeFactory->expects($this->at(1)) | ||
131 | ->method('createResolvedType') | ||
132 | ->with($type, array(), $parentResolvedType) | ||
133 | ->will($this->returnValue($resolvedType)); | ||
134 | |||
135 | $parentResolvedType->expects($this->any()) | ||
136 | ->method('getName') | ||
137 | ->will($this->returnValue('foo')); | ||
138 | |||
139 | $resolvedType->expects($this->any()) | ||
140 | ->method('getName') | ||
141 | ->will($this->returnValue('foo_sub_type')); | ||
142 | |||
143 | $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type')); | ||
144 | } | ||
145 | |||
146 | public function testGetTypeConnectsParentIfGetParentReturnsInstance() | ||
147 | { | ||
148 | $type = new FooSubTypeWithParentInstance(); | ||
149 | $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
150 | $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
151 | |||
152 | $this->extension1->addType($type); | ||
153 | |||
154 | $this->resolvedTypeFactory->expects($this->at(0)) | ||
155 | ->method('createResolvedType') | ||
156 | ->with($this->isInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType')) | ||
157 | ->will($this->returnValue($parentResolvedType)); | ||
158 | |||
159 | $this->resolvedTypeFactory->expects($this->at(1)) | ||
160 | ->method('createResolvedType') | ||
161 | ->with($type, array(), $parentResolvedType) | ||
162 | ->will($this->returnValue($resolvedType)); | ||
163 | |||
164 | $parentResolvedType->expects($this->any()) | ||
165 | ->method('getName') | ||
166 | ->will($this->returnValue('foo')); | ||
167 | |||
168 | $resolvedType->expects($this->any()) | ||
169 | ->method('getName') | ||
170 | ->will($this->returnValue('foo_sub_type_parent_instance')); | ||
171 | |||
172 | $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance')); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
177 | */ | ||
178 | public function testGetTypeThrowsExceptionIfParentNotFound() | ||
179 | { | ||
180 | $type = new FooSubType(); | ||
181 | |||
182 | $this->extension1->addType($type); | ||
183 | |||
184 | $this->registry->getType($type); | ||
185 | } | ||
186 | |||
187 | /** | ||
188 | * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException | ||
189 | */ | ||
190 | public function testGetTypeThrowsExceptionIfTypeNotFound() | ||
191 | { | ||
192 | $this->registry->getType('bar'); | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
197 | */ | ||
198 | public function testGetTypeThrowsExceptionIfNoString() | ||
199 | { | ||
200 | $this->registry->getType(array()); | ||
201 | } | ||
202 | |||
203 | public function testHasTypeAfterLoadingFromExtension() | ||
204 | { | ||
205 | $type = new FooType(); | ||
206 | $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
207 | |||
208 | $this->resolvedTypeFactory->expects($this->once()) | ||
209 | ->method('createResolvedType') | ||
210 | ->with($type) | ||
211 | ->will($this->returnValue($resolvedType)); | ||
212 | |||
213 | $resolvedType->expects($this->any()) | ||
214 | ->method('getName') | ||
215 | ->will($this->returnValue('foo')); | ||
216 | |||
217 | $this->assertFalse($this->registry->hasType('foo')); | ||
218 | |||
219 | $this->extension2->addType($type); | ||
220 | |||
221 | $this->assertTrue($this->registry->hasType('foo')); | ||
222 | } | ||
223 | |||
224 | public function testGetTypeGuesser() | ||
225 | { | ||
226 | $expectedGuesser = new FormTypeGuesserChain(array($this->guesser1, $this->guesser2)); | ||
227 | |||
228 | $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); | ||
229 | |||
230 | $registry = new FormRegistry( | ||
231 | array($this->getMock('Symfony\Component\Form\FormExtensionInterface')), | ||
232 | $this->resolvedTypeFactory); | ||
233 | |||
234 | $this->assertNull($registry->getTypeGuesser()); | ||
235 | } | ||
236 | |||
237 | public function testGetExtensions() | ||
238 | { | ||
239 | $expectedExtensions = array($this->extension1, $this->extension2); | ||
240 | |||
241 | $this->assertEquals($expectedExtensions, $this->registry->getExtensions()); | ||
242 | } | ||
243 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php deleted file mode 100644 index 69b048f7..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Test; | ||
13 | |||
14 | class FormRendererTest extends \PHPUnit_Framework_TestCase | ||
15 | { | ||
16 | public function testHumanize() | ||
17 | { | ||
18 | $renderer = $this->getMockBuilder('Symfony\Component\Form\FormRenderer') | ||
19 | ->setMethods(null) | ||
20 | ->disableOriginalConstructor() | ||
21 | ->getMock() | ||
22 | ; | ||
23 | |||
24 | $this->assertEquals('Is active', $renderer->humanize('is_active')); | ||
25 | $this->assertEquals('Is active', $renderer->humanize('isActive')); | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php deleted file mode 100644 index 235eb6ed..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Guess; | ||
13 | |||
14 | use Symfony\Component\Form\Guess\Guess; | ||
15 | |||
16 | class TestGuess extends Guess {} | ||
17 | |||
18 | class GuessTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | public function testGetBestGuessReturnsGuessWithHighestConfidence() | ||
21 | { | ||
22 | $guess1 = new TestGuess(Guess::MEDIUM_CONFIDENCE); | ||
23 | $guess2 = new TestGuess(Guess::LOW_CONFIDENCE); | ||
24 | $guess3 = new TestGuess(Guess::HIGH_CONFIDENCE); | ||
25 | |||
26 | $this->assertSame($guess3, Guess::getBestGuess(array($guess1, $guess2, $guess3))); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @expectedException \InvalidArgumentException | ||
31 | */ | ||
32 | public function testGuessExpectsValidConfidence() | ||
33 | { | ||
34 | new TestGuess(5); | ||
35 | } | ||
36 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php deleted file mode 100644 index 9d3a997f..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ /dev/null | |||
@@ -1,219 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\NativeRequestHandler; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class NativeRequestHandlerTest extends AbstractRequestHandlerTest | ||
20 | { | ||
21 | private static $serverBackup; | ||
22 | |||
23 | public static function setUpBeforeClass() | ||
24 | { | ||
25 | self::$serverBackup = $_SERVER; | ||
26 | } | ||
27 | |||
28 | protected function setUp() | ||
29 | { | ||
30 | parent::setUp(); | ||
31 | |||
32 | $_GET = array(); | ||
33 | $_POST = array(); | ||
34 | $_FILES = array(); | ||
35 | $_SERVER = array( | ||
36 | // PHPUnit needs this entry | ||
37 | 'SCRIPT_NAME' => self::$serverBackup['SCRIPT_NAME'], | ||
38 | ); | ||
39 | } | ||
40 | |||
41 | protected function tearDown() | ||
42 | { | ||
43 | parent::tearDown(); | ||
44 | |||
45 | $_GET = array(); | ||
46 | $_POST = array(); | ||
47 | $_FILES = array(); | ||
48 | $_SERVER = self::$serverBackup; | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException | ||
53 | */ | ||
54 | public function testRequestShouldBeNull() | ||
55 | { | ||
56 | $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), 'request'); | ||
57 | } | ||
58 | |||
59 | public function testMethodOverrideHeaderTakesPrecedenceIfPost() | ||
60 | { | ||
61 | $form = $this->getMockForm('param1', 'PUT'); | ||
62 | |||
63 | $this->setRequestData('POST', array( | ||
64 | 'param1' => 'DATA', | ||
65 | )); | ||
66 | |||
67 | $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; | ||
68 | |||
69 | $form->expects($this->once()) | ||
70 | ->method('submit') | ||
71 | ->with('DATA'); | ||
72 | |||
73 | $this->requestHandler->handleRequest($form, $this->request); | ||
74 | } | ||
75 | |||
76 | public function testConvertEmptyUploadedFilesToNull() | ||
77 | { | ||
78 | $form = $this->getMockForm('param1', 'POST', false); | ||
79 | |||
80 | $this->setRequestData('POST', array(), array('param1' => array( | ||
81 | 'name' => '', | ||
82 | 'type' => '', | ||
83 | 'tmp_name' => '', | ||
84 | 'error' => UPLOAD_ERR_NO_FILE, | ||
85 | 'size' => 0 | ||
86 | ))); | ||
87 | |||
88 | $form->expects($this->once()) | ||
89 | ->method('submit') | ||
90 | ->with($this->identicalTo(null)); | ||
91 | |||
92 | $this->requestHandler->handleRequest($form, $this->request); | ||
93 | } | ||
94 | |||
95 | public function testFixBuggyFilesArray() | ||
96 | { | ||
97 | $form = $this->getMockForm('param1', 'POST', false); | ||
98 | |||
99 | $this->setRequestData('POST', array(), array('param1' => array( | ||
100 | 'name' => array( | ||
101 | 'field' => 'upload.txt', | ||
102 | ), | ||
103 | 'type' => array( | ||
104 | 'field' => 'text/plain', | ||
105 | ), | ||
106 | 'tmp_name' => array( | ||
107 | 'field' => 'owfdskjasdfsa', | ||
108 | ), | ||
109 | 'error' => array( | ||
110 | 'field' => UPLOAD_ERR_OK, | ||
111 | ), | ||
112 | 'size' => array( | ||
113 | 'field' => 100, | ||
114 | ), | ||
115 | ))); | ||
116 | |||
117 | $form->expects($this->once()) | ||
118 | ->method('submit') | ||
119 | ->with(array( | ||
120 | 'field' => array( | ||
121 | 'name' => 'upload.txt', | ||
122 | 'type' => 'text/plain', | ||
123 | 'tmp_name' => 'owfdskjasdfsa', | ||
124 | 'error' => UPLOAD_ERR_OK, | ||
125 | 'size' => 100, | ||
126 | ), | ||
127 | )); | ||
128 | |||
129 | $this->requestHandler->handleRequest($form, $this->request); | ||
130 | } | ||
131 | |||
132 | public function testFixBuggyNestedFilesArray() | ||
133 | { | ||
134 | $form = $this->getMockForm('param1', 'POST'); | ||
135 | |||
136 | $this->setRequestData('POST', array(), array('param1' => array( | ||
137 | 'name' => array( | ||
138 | 'field' => array('subfield' => 'upload.txt'), | ||
139 | ), | ||
140 | 'type' => array( | ||
141 | 'field' => array('subfield' => 'text/plain'), | ||
142 | ), | ||
143 | 'tmp_name' => array( | ||
144 | 'field' => array('subfield' => 'owfdskjasdfsa'), | ||
145 | ), | ||
146 | 'error' => array( | ||
147 | 'field' => array('subfield' => UPLOAD_ERR_OK), | ||
148 | ), | ||
149 | 'size' => array( | ||
150 | 'field' => array('subfield' => 100), | ||
151 | ), | ||
152 | ))); | ||
153 | |||
154 | $form->expects($this->once()) | ||
155 | ->method('submit') | ||
156 | ->with(array( | ||
157 | 'field' => array( | ||
158 | 'subfield' => array( | ||
159 | 'name' => 'upload.txt', | ||
160 | 'type' => 'text/plain', | ||
161 | 'tmp_name' => 'owfdskjasdfsa', | ||
162 | 'error' => UPLOAD_ERR_OK, | ||
163 | 'size' => 100, | ||
164 | ), | ||
165 | ), | ||
166 | )); | ||
167 | |||
168 | $this->requestHandler->handleRequest($form, $this->request); | ||
169 | } | ||
170 | |||
171 | public function testMethodOverrideHeaderIgnoredIfNotPost() | ||
172 | { | ||
173 | $form = $this->getMockForm('param1', 'POST'); | ||
174 | |||
175 | $this->setRequestData('GET', array( | ||
176 | 'param1' => 'DATA', | ||
177 | )); | ||
178 | |||
179 | $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; | ||
180 | |||
181 | $form->expects($this->never()) | ||
182 | ->method('submit'); | ||
183 | |||
184 | $this->requestHandler->handleRequest($form, $this->request); | ||
185 | } | ||
186 | |||
187 | protected function setRequestData($method, $data, $files = array()) | ||
188 | { | ||
189 | if ('GET' === $method) { | ||
190 | $_GET = $data; | ||
191 | $_FILES = array(); | ||
192 | } else { | ||
193 | $_POST = $data; | ||
194 | $_FILES = $files; | ||
195 | } | ||
196 | |||
197 | $_SERVER = array( | ||
198 | 'REQUEST_METHOD' => $method, | ||
199 | // PHPUnit needs this entry | ||
200 | 'SCRIPT_NAME' => self::$serverBackup['SCRIPT_NAME'], | ||
201 | ); | ||
202 | } | ||
203 | |||
204 | protected function getRequestHandler() | ||
205 | { | ||
206 | return new NativeRequestHandler(); | ||
207 | } | ||
208 | |||
209 | protected function getMockFile() | ||
210 | { | ||
211 | return array( | ||
212 | 'name' => 'upload.txt', | ||
213 | 'type' => 'text/plain', | ||
214 | 'tmp_name' => 'owfdskjasdfsa', | ||
215 | 'error' => UPLOAD_ERR_OK, | ||
216 | 'size' => 100, | ||
217 | ); | ||
218 | } | ||
219 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php deleted file mode 100644 index bb32a241..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ /dev/null | |||
@@ -1,280 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\ResolvedFormType; | ||
15 | use Symfony\Component\Form\FormView; | ||
16 | use Symfony\Component\Form\FormBuilder; | ||
17 | use Symfony\Component\Form\Form; | ||
18 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
19 | |||
20 | /** | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | */ | ||
23 | class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase | ||
24 | { | ||
25 | /** | ||
26 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
27 | */ | ||
28 | private $dispatcher; | ||
29 | |||
30 | /** | ||
31 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
32 | */ | ||
33 | private $factory; | ||
34 | |||
35 | /** | ||
36 | * @var \PHPUnit_Framework_MockObject_MockObject | ||
37 | */ | ||
38 | private $dataMapper; | ||
39 | |||
40 | protected function setUp() | ||
41 | { | ||
42 | if (!class_exists('Symfony\Component\OptionsResolver\OptionsResolver')) { | ||
43 | $this->markTestSkipped('The "OptionsResolver" component is not available'); | ||
44 | } | ||
45 | |||
46 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
47 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
48 | } | ||
49 | |||
50 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
51 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
52 | $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
53 | } | ||
54 | |||
55 | public function testCreateBuilder() | ||
56 | { | ||
57 | if (version_compare(\PHPUnit_Runner_Version::id(), '3.7', '<')) { | ||
58 | $this->markTestSkipped('This test requires PHPUnit 3.7.'); | ||
59 | } | ||
60 | |||
61 | $parentType = $this->getMockFormType(); | ||
62 | $type = $this->getMockFormType(); | ||
63 | $extension1 = $this->getMockFormTypeExtension(); | ||
64 | $extension2 = $this->getMockFormTypeExtension(); | ||
65 | |||
66 | $parentResolvedType = new ResolvedFormType($parentType); | ||
67 | $resolvedType = new ResolvedFormType($type, array($extension1, $extension2), $parentResolvedType); | ||
68 | |||
69 | $test = $this; | ||
70 | $i = 0; | ||
71 | |||
72 | $assertIndex = function ($index) use (&$i, $test) { | ||
73 | return function () use (&$i, $test, $index) { | ||
74 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
75 | $test->assertEquals($index, $i, 'Executed at index '.$index); | ||
76 | |||
77 | ++$i; | ||
78 | }; | ||
79 | }; | ||
80 | |||
81 | $assertIndexAndAddOption = function ($index, $option, $default) use ($assertIndex) { | ||
82 | $assertIndex = $assertIndex($index); | ||
83 | |||
84 | return function (OptionsResolverInterface $resolver) use ($assertIndex, $index, $option, $default) { | ||
85 | $assertIndex(); | ||
86 | |||
87 | $resolver->setDefaults(array($option => $default)); | ||
88 | }; | ||
89 | }; | ||
90 | |||
91 | // First the default options are generated for the super type | ||
92 | $parentType->expects($this->once()) | ||
93 | ->method('setDefaultOptions') | ||
94 | ->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default'))); | ||
95 | |||
96 | // The form type itself | ||
97 | $type->expects($this->once()) | ||
98 | ->method('setDefaultOptions') | ||
99 | ->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default'))); | ||
100 | |||
101 | // And its extensions | ||
102 | $extension1->expects($this->once()) | ||
103 | ->method('setDefaultOptions') | ||
104 | ->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default'))); | ||
105 | |||
106 | $extension2->expects($this->once()) | ||
107 | ->method('setDefaultOptions') | ||
108 | ->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default'))); | ||
109 | |||
110 | $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); | ||
111 | $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); | ||
112 | |||
113 | // Then the form is built for the super type | ||
114 | $parentType->expects($this->once()) | ||
115 | ->method('buildForm') | ||
116 | ->with($this->anything(), $resolvedOptions) | ||
117 | ->will($this->returnCallback($assertIndex(4))); | ||
118 | |||
119 | // Then the type itself | ||
120 | $type->expects($this->once()) | ||
121 | ->method('buildForm') | ||
122 | ->with($this->anything(), $resolvedOptions) | ||
123 | ->will($this->returnCallback($assertIndex(5))); | ||
124 | |||
125 | // Then its extensions | ||
126 | $extension1->expects($this->once()) | ||
127 | ->method('buildForm') | ||
128 | ->with($this->anything(), $resolvedOptions) | ||
129 | ->will($this->returnCallback($assertIndex(6))); | ||
130 | |||
131 | $extension2->expects($this->once()) | ||
132 | ->method('buildForm') | ||
133 | ->with($this->anything(), $resolvedOptions) | ||
134 | ->will($this->returnCallback($assertIndex(7))); | ||
135 | |||
136 | $factory = $this->getMockFormFactory(); | ||
137 | $builder = $resolvedType->createBuilder($factory, 'name', $givenOptions); | ||
138 | |||
139 | $this->assertSame($resolvedType, $builder->getType()); | ||
140 | } | ||
141 | |||
142 | public function testCreateView() | ||
143 | { | ||
144 | $parentType = $this->getMockFormType(); | ||
145 | $type = $this->getMockFormType(); | ||
146 | $field1Type = $this->getMockFormType(); | ||
147 | $field2Type = $this->getMockFormType(); | ||
148 | $extension1 = $this->getMockFormTypeExtension(); | ||
149 | $extension2 = $this->getMockFormTypeExtension(); | ||
150 | |||
151 | $parentResolvedType = new ResolvedFormType($parentType); | ||
152 | $resolvedType = new ResolvedFormType($type, array($extension1, $extension2), $parentResolvedType); | ||
153 | $field1ResolvedType = new ResolvedFormType($field1Type); | ||
154 | $field2ResolvedType = new ResolvedFormType($field2Type); | ||
155 | |||
156 | $options = array('a' => '1', 'b' => '2'); | ||
157 | $form = $this->getBuilder('name', $options) | ||
158 | ->setCompound(true) | ||
159 | ->setDataMapper($this->dataMapper) | ||
160 | ->setType($resolvedType) | ||
161 | ->add($this->getBuilder('foo')->setType($field1ResolvedType)) | ||
162 | ->add($this->getBuilder('bar')->setType($field2ResolvedType)) | ||
163 | ->getForm(); | ||
164 | |||
165 | $test = $this; | ||
166 | $i = 0; | ||
167 | |||
168 | $assertIndexAndNbOfChildViews = function ($index, $nbOfChildViews) use (&$i, $test) { | ||
169 | return function (FormView $view) use (&$i, $test, $index, $nbOfChildViews) { | ||
170 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
171 | $test->assertEquals($index, $i, 'Executed at index '.$index); | ||
172 | $test->assertCount($nbOfChildViews, $view); | ||
173 | |||
174 | ++$i; | ||
175 | }; | ||
176 | }; | ||
177 | |||
178 | // First the super type | ||
179 | $parentType->expects($this->once()) | ||
180 | ->method('buildView') | ||
181 | ->with($this->anything(), $form, $options) | ||
182 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(0, 0))); | ||
183 | |||
184 | // Then the type itself | ||
185 | $type->expects($this->once()) | ||
186 | ->method('buildView') | ||
187 | ->with($this->anything(), $form, $options) | ||
188 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(1, 0))); | ||
189 | |||
190 | // Then its extensions | ||
191 | $extension1->expects($this->once()) | ||
192 | ->method('buildView') | ||
193 | ->with($this->anything(), $form, $options) | ||
194 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(2, 0))); | ||
195 | |||
196 | $extension2->expects($this->once()) | ||
197 | ->method('buildView') | ||
198 | ->with($this->anything(), $form, $options) | ||
199 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(3, 0))); | ||
200 | |||
201 | // Now the first child form | ||
202 | $field1Type->expects($this->once()) | ||
203 | ->method('buildView') | ||
204 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(4, 0))); | ||
205 | $field1Type->expects($this->once()) | ||
206 | ->method('finishView') | ||
207 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(5, 0))); | ||
208 | |||
209 | // And the second child form | ||
210 | $field2Type->expects($this->once()) | ||
211 | ->method('buildView') | ||
212 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(6, 0))); | ||
213 | $field2Type->expects($this->once()) | ||
214 | ->method('finishView') | ||
215 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(7, 0))); | ||
216 | |||
217 | // Again first the parent | ||
218 | $parentType->expects($this->once()) | ||
219 | ->method('finishView') | ||
220 | ->with($this->anything(), $form, $options) | ||
221 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(8, 2))); | ||
222 | |||
223 | // Then the type itself | ||
224 | $type->expects($this->once()) | ||
225 | ->method('finishView') | ||
226 | ->with($this->anything(), $form, $options) | ||
227 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(9, 2))); | ||
228 | |||
229 | // Then its extensions | ||
230 | $extension1->expects($this->once()) | ||
231 | ->method('finishView') | ||
232 | ->with($this->anything(), $form, $options) | ||
233 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(10, 2))); | ||
234 | |||
235 | $extension2->expects($this->once()) | ||
236 | ->method('finishView') | ||
237 | ->with($this->anything(), $form, $options) | ||
238 | ->will($this->returnCallback($assertIndexAndNbOfChildViews(11, 2))); | ||
239 | |||
240 | $parentView = new FormView(); | ||
241 | $view = $resolvedType->createView($form, $parentView); | ||
242 | |||
243 | $this->assertSame($parentView, $view->parent); | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
248 | */ | ||
249 | private function getMockFormType() | ||
250 | { | ||
251 | return $this->getMock('Symfony\Component\Form\FormTypeInterface'); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
256 | */ | ||
257 | private function getMockFormTypeExtension() | ||
258 | { | ||
259 | return $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); | ||
260 | } | ||
261 | |||
262 | /** | ||
263 | * @return \PHPUnit_Framework_MockObject_MockObject | ||
264 | */ | ||
265 | private function getMockFormFactory() | ||
266 | { | ||
267 | return $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * @param string $name | ||
272 | * @param array $options | ||
273 | * | ||
274 | * @return FormBuilder | ||
275 | */ | ||
276 | protected function getBuilder($name = 'name', array $options = array()) | ||
277 | { | ||
278 | return new FormBuilder($name, null, $this->dispatcher, $this->factory, $options); | ||
279 | } | ||
280 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php deleted file mode 100644 index bedad676..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php +++ /dev/null | |||
@@ -1,1045 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests; | ||
13 | |||
14 | use Symfony\Component\Form\Form; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\Form\FormEvents; | ||
17 | use Symfony\Component\PropertyAccess\PropertyPath; | ||
18 | use Symfony\Component\Form\FormConfigBuilder; | ||
19 | use Symfony\Component\Form\FormError; | ||
20 | use Symfony\Component\Form\Exception\TransformationFailedException; | ||
21 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
22 | use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; | ||
23 | use Symfony\Component\Form\Tests\Fixtures\FixedFilterListener; | ||
24 | |||
25 | class SimpleFormTest_Countable implements \Countable | ||
26 | { | ||
27 | private $count; | ||
28 | |||
29 | public function __construct($count) | ||
30 | { | ||
31 | $this->count = $count; | ||
32 | } | ||
33 | |||
34 | public function count() | ||
35 | { | ||
36 | return $this->count; | ||
37 | } | ||
38 | } | ||
39 | |||
40 | class SimpleFormTest_Traversable implements \IteratorAggregate | ||
41 | { | ||
42 | private $iterator; | ||
43 | |||
44 | public function __construct($count) | ||
45 | { | ||
46 | $this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : array()); | ||
47 | } | ||
48 | |||
49 | public function getIterator() | ||
50 | { | ||
51 | return $this->iterator; | ||
52 | } | ||
53 | } | ||
54 | |||
55 | class SimpleFormTest extends AbstractFormTest | ||
56 | { | ||
57 | public function testDataIsInitializedToConfiguredValue() | ||
58 | { | ||
59 | $model = new FixedDataTransformer(array( | ||
60 | 'default' => 'foo', | ||
61 | )); | ||
62 | $view = new FixedDataTransformer(array( | ||
63 | 'foo' => 'bar', | ||
64 | )); | ||
65 | |||
66 | $config = new FormConfigBuilder('name', null, $this->dispatcher); | ||
67 | $config->addViewTransformer($view); | ||
68 | $config->addModelTransformer($model); | ||
69 | $config->setData('default'); | ||
70 | $form = new Form($config); | ||
71 | |||
72 | $this->assertSame('default', $form->getData()); | ||
73 | $this->assertSame('foo', $form->getNormData()); | ||
74 | $this->assertSame('bar', $form->getViewData()); | ||
75 | } | ||
76 | |||
77 | // https://github.com/symfony/symfony/commit/d4f4038f6daf7cf88ca7c7ab089473cce5ebf7d8#commitcomment-1632879 | ||
78 | public function testDataIsInitializedFromSubmit() | ||
79 | { | ||
80 | $mock = $this->getMockBuilder('\stdClass') | ||
81 | ->setMethods(array('preSetData', 'preSubmit')) | ||
82 | ->getMock(); | ||
83 | $mock->expects($this->at(0)) | ||
84 | ->method('preSetData'); | ||
85 | $mock->expects($this->at(1)) | ||
86 | ->method('preSubmit'); | ||
87 | |||
88 | $config = new FormConfigBuilder('name', null, $this->dispatcher); | ||
89 | $config->addEventListener(FormEvents::PRE_SET_DATA, array($mock, 'preSetData')); | ||
90 | $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit')); | ||
91 | $form = new Form($config); | ||
92 | |||
93 | // no call to setData() or similar where the object would be | ||
94 | // initialized otherwise | ||
95 | |||
96 | $form->submit('foobar'); | ||
97 | } | ||
98 | |||
99 | // https://github.com/symfony/symfony/pull/7789 | ||
100 | public function testFalseIsConvertedToNull() | ||
101 | { | ||
102 | $mock = $this->getMockBuilder('\stdClass') | ||
103 | ->setMethods(array('preBind')) | ||
104 | ->getMock(); | ||
105 | $mock->expects($this->once()) | ||
106 | ->method('preBind') | ||
107 | ->with($this->callback(function ($event) { | ||
108 | return null === $event->getData(); | ||
109 | })); | ||
110 | |||
111 | $config = new FormConfigBuilder('name', null, $this->dispatcher); | ||
112 | $config->addEventListener(FormEvents::PRE_BIND, array($mock, 'preBind')); | ||
113 | $form = new Form($config); | ||
114 | |||
115 | $form->bind(false); | ||
116 | |||
117 | $this->assertTrue($form->isValid()); | ||
118 | $this->assertNull($form->getData()); | ||
119 | } | ||
120 | |||
121 | /** | ||
122 | * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException | ||
123 | */ | ||
124 | public function testSubmitThrowsExceptionIfAlreadySubmitted() | ||
125 | { | ||
126 | $this->form->submit(array()); | ||
127 | $this->form->submit(array()); | ||
128 | } | ||
129 | |||
130 | public function testSubmitIsIgnoredIfDisabled() | ||
131 | { | ||
132 | $form = $this->getBuilder() | ||
133 | ->setDisabled(true) | ||
134 | ->setData('initial') | ||
135 | ->getForm(); | ||
136 | |||
137 | $form->submit('new'); | ||
138 | |||
139 | $this->assertEquals('initial', $form->getData()); | ||
140 | $this->assertTrue($form->isSubmitted()); | ||
141 | } | ||
142 | |||
143 | public function testNeverRequiredIfParentNotRequired() | ||
144 | { | ||
145 | $parent = $this->getBuilder()->setRequired(false)->getForm(); | ||
146 | $child = $this->getBuilder()->setRequired(true)->getForm(); | ||
147 | |||
148 | $child->setParent($parent); | ||
149 | |||
150 | $this->assertFalse($child->isRequired()); | ||
151 | } | ||
152 | |||
153 | public function testRequired() | ||
154 | { | ||
155 | $parent = $this->getBuilder()->setRequired(true)->getForm(); | ||
156 | $child = $this->getBuilder()->setRequired(true)->getForm(); | ||
157 | |||
158 | $child->setParent($parent); | ||
159 | |||
160 | $this->assertTrue($child->isRequired()); | ||
161 | } | ||
162 | |||
163 | public function testNotRequired() | ||
164 | { | ||
165 | $parent = $this->getBuilder()->setRequired(true)->getForm(); | ||
166 | $child = $this->getBuilder()->setRequired(false)->getForm(); | ||
167 | |||
168 | $child->setParent($parent); | ||
169 | |||
170 | $this->assertFalse($child->isRequired()); | ||
171 | } | ||
172 | |||
173 | public function testAlwaysDisabledIfParentDisabled() | ||
174 | { | ||
175 | $parent = $this->getBuilder()->setDisabled(true)->getForm(); | ||
176 | $child = $this->getBuilder()->setDisabled(false)->getForm(); | ||
177 | |||
178 | $child->setParent($parent); | ||
179 | |||
180 | $this->assertTrue($child->isDisabled()); | ||
181 | } | ||
182 | |||
183 | public function testDisabled() | ||
184 | { | ||
185 | $parent = $this->getBuilder()->setDisabled(false)->getForm(); | ||
186 | $child = $this->getBuilder()->setDisabled(true)->getForm(); | ||
187 | |||
188 | $child->setParent($parent); | ||
189 | |||
190 | $this->assertTrue($child->isDisabled()); | ||
191 | } | ||
192 | |||
193 | public function testNotDisabled() | ||
194 | { | ||
195 | $parent = $this->getBuilder()->setDisabled(false)->getForm(); | ||
196 | $child = $this->getBuilder()->setDisabled(false)->getForm(); | ||
197 | |||
198 | $child->setParent($parent); | ||
199 | |||
200 | $this->assertFalse($child->isDisabled()); | ||
201 | } | ||
202 | |||
203 | public function testGetRootReturnsRootOfParent() | ||
204 | { | ||
205 | $parent = $this->getMockForm(); | ||
206 | $parent->expects($this->once()) | ||
207 | ->method('getRoot') | ||
208 | ->will($this->returnValue('ROOT')); | ||
209 | |||
210 | $this->form->setParent($parent); | ||
211 | |||
212 | $this->assertEquals('ROOT', $this->form->getRoot()); | ||
213 | } | ||
214 | |||
215 | public function testGetRootReturnsSelfIfNoParent() | ||
216 | { | ||
217 | $this->assertSame($this->form, $this->form->getRoot()); | ||
218 | } | ||
219 | |||
220 | public function testEmptyIfEmptyArray() | ||
221 | { | ||
222 | $this->form->setData(array()); | ||
223 | |||
224 | $this->assertTrue($this->form->isEmpty()); | ||
225 | } | ||
226 | |||
227 | public function testEmptyIfEmptyCountable() | ||
228 | { | ||
229 | $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); | ||
230 | |||
231 | $this->form->setData(new SimpleFormTest_Countable(0)); | ||
232 | |||
233 | $this->assertTrue($this->form->isEmpty()); | ||
234 | } | ||
235 | |||
236 | public function testNotEmptyIfFilledCountable() | ||
237 | { | ||
238 | $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); | ||
239 | |||
240 | $this->form->setData(new SimpleFormTest_Countable(1)); | ||
241 | |||
242 | $this->assertFalse($this->form->isEmpty()); | ||
243 | } | ||
244 | |||
245 | public function testEmptyIfEmptyTraversable() | ||
246 | { | ||
247 | $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); | ||
248 | |||
249 | $this->form->setData(new SimpleFormTest_Traversable(0)); | ||
250 | |||
251 | $this->assertTrue($this->form->isEmpty()); | ||
252 | } | ||
253 | |||
254 | public function testNotEmptyIfFilledTraversable() | ||
255 | { | ||
256 | $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); | ||
257 | |||
258 | $this->form->setData(new SimpleFormTest_Traversable(1)); | ||
259 | |||
260 | $this->assertFalse($this->form->isEmpty()); | ||
261 | } | ||
262 | |||
263 | public function testEmptyIfNull() | ||
264 | { | ||
265 | $this->form->setData(null); | ||
266 | |||
267 | $this->assertTrue($this->form->isEmpty()); | ||
268 | } | ||
269 | |||
270 | public function testEmptyIfEmptyString() | ||
271 | { | ||
272 | $this->form->setData(''); | ||
273 | |||
274 | $this->assertTrue($this->form->isEmpty()); | ||
275 | } | ||
276 | |||
277 | public function testNotEmptyIfText() | ||
278 | { | ||
279 | $this->form->setData('foobar'); | ||
280 | |||
281 | $this->assertFalse($this->form->isEmpty()); | ||
282 | } | ||
283 | |||
284 | public function testValidIfSubmitted() | ||
285 | { | ||
286 | $form = $this->getBuilder()->getForm(); | ||
287 | $form->submit('foobar'); | ||
288 | |||
289 | $this->assertTrue($form->isValid()); | ||
290 | } | ||
291 | |||
292 | public function testValidIfSubmittedAndDisabled() | ||
293 | { | ||
294 | $form = $this->getBuilder()->setDisabled(true)->getForm(); | ||
295 | $form->submit('foobar'); | ||
296 | |||
297 | $this->assertTrue($form->isValid()); | ||
298 | } | ||
299 | |||
300 | public function testNotValidIfNotSubmitted() | ||
301 | { | ||
302 | $this->assertFalse($this->form->isValid()); | ||
303 | } | ||
304 | |||
305 | public function testNotValidIfErrors() | ||
306 | { | ||
307 | $form = $this->getBuilder()->getForm(); | ||
308 | $form->submit('foobar'); | ||
309 | $form->addError(new FormError('Error!')); | ||
310 | |||
311 | $this->assertFalse($form->isValid()); | ||
312 | } | ||
313 | |||
314 | public function testHasErrors() | ||
315 | { | ||
316 | $this->form->addError(new FormError('Error!')); | ||
317 | |||
318 | $this->assertCount(1, $this->form->getErrors()); | ||
319 | } | ||
320 | |||
321 | public function testHasNoErrors() | ||
322 | { | ||
323 | $this->assertCount(0, $this->form->getErrors()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException | ||
328 | */ | ||
329 | public function testSetParentThrowsExceptionIfAlreadySubmitted() | ||
330 | { | ||
331 | $this->form->submit(array()); | ||
332 | $this->form->setParent($this->getBuilder('parent')->getForm()); | ||
333 | } | ||
334 | |||
335 | public function testSubmitted() | ||
336 | { | ||
337 | $form = $this->getBuilder()->getForm(); | ||
338 | $form->submit('foobar'); | ||
339 | |||
340 | $this->assertTrue($form->isSubmitted()); | ||
341 | } | ||
342 | |||
343 | public function testNotSubmitted() | ||
344 | { | ||
345 | $this->assertFalse($this->form->isSubmitted()); | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException | ||
350 | */ | ||
351 | public function testSetDataThrowsExceptionIfAlreadySubmitted() | ||
352 | { | ||
353 | $this->form->submit(array()); | ||
354 | $this->form->setData(null); | ||
355 | } | ||
356 | |||
357 | public function testSetDataClonesObjectIfNotByReference() | ||
358 | { | ||
359 | $data = new \stdClass(); | ||
360 | $form = $this->getBuilder('name', null, '\stdClass')->setByReference(false)->getForm(); | ||
361 | $form->setData($data); | ||
362 | |||
363 | $this->assertNotSame($data, $form->getData()); | ||
364 | $this->assertEquals($data, $form->getData()); | ||
365 | } | ||
366 | |||
367 | public function testSetDataDoesNotCloneObjectIfByReference() | ||
368 | { | ||
369 | $data = new \stdClass(); | ||
370 | $form = $this->getBuilder('name', null, '\stdClass')->setByReference(true)->getForm(); | ||
371 | $form->setData($data); | ||
372 | |||
373 | $this->assertSame($data, $form->getData()); | ||
374 | } | ||
375 | |||
376 | public function testSetDataExecutesTransformationChain() | ||
377 | { | ||
378 | // use real event dispatcher now | ||
379 | $form = $this->getBuilder('name', new EventDispatcher()) | ||
380 | ->addEventSubscriber(new FixedFilterListener(array( | ||
381 | 'preSetData' => array( | ||
382 | 'app' => 'filtered', | ||
383 | ), | ||
384 | ))) | ||
385 | ->addModelTransformer(new FixedDataTransformer(array( | ||
386 | '' => '', | ||
387 | 'filtered' => 'norm', | ||
388 | ))) | ||
389 | ->addViewTransformer(new FixedDataTransformer(array( | ||
390 | '' => '', | ||
391 | 'norm' => 'client', | ||
392 | ))) | ||
393 | ->getForm(); | ||
394 | |||
395 | $form->setData('app'); | ||
396 | |||
397 | $this->assertEquals('filtered', $form->getData()); | ||
398 | $this->assertEquals('norm', $form->getNormData()); | ||
399 | $this->assertEquals('client', $form->getViewData()); | ||
400 | } | ||
401 | |||
402 | public function testSetDataExecutesViewTransformersInOrder() | ||
403 | { | ||
404 | $form = $this->getBuilder() | ||
405 | ->addViewTransformer(new FixedDataTransformer(array( | ||
406 | '' => '', | ||
407 | 'first' => 'second', | ||
408 | ))) | ||
409 | ->addViewTransformer(new FixedDataTransformer(array( | ||
410 | '' => '', | ||
411 | 'second' => 'third', | ||
412 | ))) | ||
413 | ->getForm(); | ||
414 | |||
415 | $form->setData('first'); | ||
416 | |||
417 | $this->assertEquals('third', $form->getViewData()); | ||
418 | } | ||
419 | |||
420 | public function testSetDataExecutesModelTransformersInReverseOrder() | ||
421 | { | ||
422 | $form = $this->getBuilder() | ||
423 | ->addModelTransformer(new FixedDataTransformer(array( | ||
424 | '' => '', | ||
425 | 'second' => 'third', | ||
426 | ))) | ||
427 | ->addModelTransformer(new FixedDataTransformer(array( | ||
428 | '' => '', | ||
429 | 'first' => 'second', | ||
430 | ))) | ||
431 | ->getForm(); | ||
432 | |||
433 | $form->setData('first'); | ||
434 | |||
435 | $this->assertEquals('third', $form->getNormData()); | ||
436 | } | ||
437 | |||
438 | /* | ||
439 | * When there is no data transformer, the data must have the same format | ||
440 | * in all three representations | ||
441 | */ | ||
442 | public function testSetDataConvertsScalarToStringIfNoTransformer() | ||
443 | { | ||
444 | $form = $this->getBuilder()->getForm(); | ||
445 | |||
446 | $form->setData(1); | ||
447 | |||
448 | $this->assertSame('1', $form->getData()); | ||
449 | $this->assertSame('1', $form->getNormData()); | ||
450 | $this->assertSame('1', $form->getViewData()); | ||
451 | } | ||
452 | |||
453 | /* | ||
454 | * Data in client format should, if possible, always be a string to | ||
455 | * facilitate differentiation between '0' and '' | ||
456 | */ | ||
457 | public function testSetDataConvertsScalarToStringIfOnlyModelTransformer() | ||
458 | { | ||
459 | $form = $this->getBuilder() | ||
460 | ->addModelTransformer(new FixedDataTransformer(array( | ||
461 | '' => '', | ||
462 | 1 => 23, | ||
463 | ))) | ||
464 | ->getForm(); | ||
465 | |||
466 | $form->setData(1); | ||
467 | |||
468 | $this->assertSame(1, $form->getData()); | ||
469 | $this->assertSame(23, $form->getNormData()); | ||
470 | $this->assertSame('23', $form->getViewData()); | ||
471 | } | ||
472 | |||
473 | /* | ||
474 | * NULL remains NULL in app and norm format to remove the need to treat | ||
475 | * empty values and NULL explicitly in the application | ||
476 | */ | ||
477 | public function testSetDataConvertsNullToStringIfNoTransformer() | ||
478 | { | ||
479 | $form = $this->getBuilder()->getForm(); | ||
480 | |||
481 | $form->setData(null); | ||
482 | |||
483 | $this->assertNull($form->getData()); | ||
484 | $this->assertNull($form->getNormData()); | ||
485 | $this->assertSame('', $form->getViewData()); | ||
486 | } | ||
487 | |||
488 | public function testSetDataIsIgnoredIfDataIsLocked() | ||
489 | { | ||
490 | $form = $this->getBuilder() | ||
491 | ->setData('default') | ||
492 | ->setDataLocked(true) | ||
493 | ->getForm(); | ||
494 | |||
495 | $form->setData('foobar'); | ||
496 | |||
497 | $this->assertSame('default', $form->getData()); | ||
498 | } | ||
499 | |||
500 | public function testSubmitConvertsEmptyToNullIfNoTransformer() | ||
501 | { | ||
502 | $form = $this->getBuilder()->getForm(); | ||
503 | |||
504 | $form->submit(''); | ||
505 | |||
506 | $this->assertNull($form->getData()); | ||
507 | $this->assertNull($form->getNormData()); | ||
508 | $this->assertSame('', $form->getViewData()); | ||
509 | } | ||
510 | |||
511 | public function testSubmitExecutesTransformationChain() | ||
512 | { | ||
513 | // use real event dispatcher now | ||
514 | $form = $this->getBuilder('name', new EventDispatcher()) | ||
515 | ->addEventSubscriber(new FixedFilterListener(array( | ||
516 | 'preSubmit' => array( | ||
517 | 'client' => 'filteredclient', | ||
518 | ), | ||
519 | 'onSubmit' => array( | ||
520 | 'norm' => 'filterednorm', | ||
521 | ), | ||
522 | ))) | ||
523 | ->addViewTransformer(new FixedDataTransformer(array( | ||
524 | '' => '', | ||
525 | // direction is reversed! | ||
526 | 'norm' => 'filteredclient', | ||
527 | 'filterednorm' => 'cleanedclient' | ||
528 | ))) | ||
529 | ->addModelTransformer(new FixedDataTransformer(array( | ||
530 | '' => '', | ||
531 | // direction is reversed! | ||
532 | 'app' => 'filterednorm', | ||
533 | ))) | ||
534 | ->getForm(); | ||
535 | |||
536 | $form->submit('client'); | ||
537 | |||
538 | $this->assertEquals('app', $form->getData()); | ||
539 | $this->assertEquals('filterednorm', $form->getNormData()); | ||
540 | $this->assertEquals('cleanedclient', $form->getViewData()); | ||
541 | } | ||
542 | |||
543 | public function testSubmitExecutesViewTransformersInReverseOrder() | ||
544 | { | ||
545 | $form = $this->getBuilder() | ||
546 | ->addViewTransformer(new FixedDataTransformer(array( | ||
547 | '' => '', | ||
548 | 'third' => 'second', | ||
549 | ))) | ||
550 | ->addViewTransformer(new FixedDataTransformer(array( | ||
551 | '' => '', | ||
552 | 'second' => 'first', | ||
553 | ))) | ||
554 | ->getForm(); | ||
555 | |||
556 | $form->submit('first'); | ||
557 | |||
558 | $this->assertEquals('third', $form->getNormData()); | ||
559 | } | ||
560 | |||
561 | public function testSubmitExecutesModelTransformersInOrder() | ||
562 | { | ||
563 | $form = $this->getBuilder() | ||
564 | ->addModelTransformer(new FixedDataTransformer(array( | ||
565 | '' => '', | ||
566 | 'second' => 'first', | ||
567 | ))) | ||
568 | ->addModelTransformer(new FixedDataTransformer(array( | ||
569 | '' => '', | ||
570 | 'third' => 'second', | ||
571 | ))) | ||
572 | ->getForm(); | ||
573 | |||
574 | $form->submit('first'); | ||
575 | |||
576 | $this->assertEquals('third', $form->getData()); | ||
577 | } | ||
578 | |||
579 | public function testSynchronizedByDefault() | ||
580 | { | ||
581 | $this->assertTrue($this->form->isSynchronized()); | ||
582 | } | ||
583 | |||
584 | public function testSynchronizedAfterSubmission() | ||
585 | { | ||
586 | $this->form->submit('foobar'); | ||
587 | |||
588 | $this->assertTrue($this->form->isSynchronized()); | ||
589 | } | ||
590 | |||
591 | public function testNotSynchronizedIfViewReverseTransformationFailed() | ||
592 | { | ||
593 | $transformer = $this->getDataTransformer(); | ||
594 | $transformer->expects($this->once()) | ||
595 | ->method('reverseTransform') | ||
596 | ->will($this->throwException(new TransformationFailedException())); | ||
597 | |||
598 | $form = $this->getBuilder() | ||
599 | ->addViewTransformer($transformer) | ||
600 | ->getForm(); | ||
601 | |||
602 | $form->submit('foobar'); | ||
603 | |||
604 | $this->assertFalse($form->isSynchronized()); | ||
605 | } | ||
606 | |||
607 | public function testNotSynchronizedIfModelReverseTransformationFailed() | ||
608 | { | ||
609 | $transformer = $this->getDataTransformer(); | ||
610 | $transformer->expects($this->once()) | ||
611 | ->method('reverseTransform') | ||
612 | ->will($this->throwException(new TransformationFailedException())); | ||
613 | |||
614 | $form = $this->getBuilder() | ||
615 | ->addModelTransformer($transformer) | ||
616 | ->getForm(); | ||
617 | |||
618 | $form->submit('foobar'); | ||
619 | |||
620 | $this->assertFalse($form->isSynchronized()); | ||
621 | } | ||
622 | |||
623 | public function testEmptyDataCreatedBeforeTransforming() | ||
624 | { | ||
625 | $form = $this->getBuilder() | ||
626 | ->setEmptyData('foo') | ||
627 | ->addViewTransformer(new FixedDataTransformer(array( | ||
628 | '' => '', | ||
629 | // direction is reversed! | ||
630 | 'bar' => 'foo', | ||
631 | ))) | ||
632 | ->getForm(); | ||
633 | |||
634 | $form->submit(''); | ||
635 | |||
636 | $this->assertEquals('bar', $form->getData()); | ||
637 | } | ||
638 | |||
639 | public function testEmptyDataFromClosure() | ||
640 | { | ||
641 | $test = $this; | ||
642 | $form = $this->getBuilder() | ||
643 | ->setEmptyData(function ($form) use ($test) { | ||
644 | // the form instance is passed to the closure to allow use | ||
645 | // of form data when creating the empty value | ||
646 | $test->assertInstanceOf('Symfony\Component\Form\FormInterface', $form); | ||
647 | |||
648 | return 'foo'; | ||
649 | }) | ||
650 | ->addViewTransformer(new FixedDataTransformer(array( | ||
651 | '' => '', | ||
652 | // direction is reversed! | ||
653 | 'bar' => 'foo', | ||
654 | ))) | ||
655 | ->getForm(); | ||
656 | |||
657 | $form->submit(''); | ||
658 | |||
659 | $this->assertEquals('bar', $form->getData()); | ||
660 | } | ||
661 | |||
662 | public function testSubmitResetsErrors() | ||
663 | { | ||
664 | $this->form->addError(new FormError('Error!')); | ||
665 | $this->form->submit('foobar'); | ||
666 | |||
667 | $this->assertSame(array(), $this->form->getErrors()); | ||
668 | } | ||
669 | |||
670 | public function testCreateView() | ||
671 | { | ||
672 | $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
673 | $view = $this->getMock('Symfony\Component\Form\FormView'); | ||
674 | $form = $this->getBuilder()->setType($type)->getForm(); | ||
675 | |||
676 | $type->expects($this->once()) | ||
677 | ->method('createView') | ||
678 | ->with($form) | ||
679 | ->will($this->returnValue($view)); | ||
680 | |||
681 | $this->assertSame($view, $form->createView()); | ||
682 | } | ||
683 | |||
684 | public function testCreateViewWithParent() | ||
685 | { | ||
686 | $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
687 | $view = $this->getMock('Symfony\Component\Form\FormView'); | ||
688 | $parentForm = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
689 | $parentView = $this->getMock('Symfony\Component\Form\FormView'); | ||
690 | $form = $this->getBuilder()->setType($type)->getForm(); | ||
691 | $form->setParent($parentForm); | ||
692 | |||
693 | $parentForm->expects($this->once()) | ||
694 | ->method('createView') | ||
695 | ->will($this->returnValue($parentView)); | ||
696 | |||
697 | $type->expects($this->once()) | ||
698 | ->method('createView') | ||
699 | ->with($form, $parentView) | ||
700 | ->will($this->returnValue($view)); | ||
701 | |||
702 | $this->assertSame($view, $form->createView()); | ||
703 | } | ||
704 | |||
705 | public function testCreateViewWithExplicitParent() | ||
706 | { | ||
707 | $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); | ||
708 | $view = $this->getMock('Symfony\Component\Form\FormView'); | ||
709 | $parentView = $this->getMock('Symfony\Component\Form\FormView'); | ||
710 | $form = $this->getBuilder()->setType($type)->getForm(); | ||
711 | |||
712 | $type->expects($this->once()) | ||
713 | ->method('createView') | ||
714 | ->with($form, $parentView) | ||
715 | ->will($this->returnValue($view)); | ||
716 | |||
717 | $this->assertSame($view, $form->createView($parentView)); | ||
718 | } | ||
719 | |||
720 | public function testGetErrorsAsString() | ||
721 | { | ||
722 | $this->form->addError(new FormError('Error!')); | ||
723 | |||
724 | $this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString()); | ||
725 | } | ||
726 | |||
727 | public function testFormCanHaveEmptyName() | ||
728 | { | ||
729 | $form = $this->getBuilder('')->getForm(); | ||
730 | |||
731 | $this->assertEquals('', $form->getName()); | ||
732 | } | ||
733 | |||
734 | public function testSetNullParentWorksWithEmptyName() | ||
735 | { | ||
736 | $form = $this->getBuilder('')->getForm(); | ||
737 | $form->setParent(null); | ||
738 | |||
739 | $this->assertNull($form->getParent()); | ||
740 | } | ||
741 | |||
742 | /** | ||
743 | * @expectedException \Symfony\Component\Form\Exception\LogicException | ||
744 | * @expectedExceptionMessage A form with an empty name cannot have a parent form. | ||
745 | */ | ||
746 | public function testFormCannotHaveEmptyNameNotInRootLevel() | ||
747 | { | ||
748 | $this->getBuilder() | ||
749 | ->setCompound(true) | ||
750 | ->setDataMapper($this->getDataMapper()) | ||
751 | ->add($this->getBuilder('')) | ||
752 | ->getForm(); | ||
753 | } | ||
754 | |||
755 | public function testGetPropertyPathReturnsConfiguredPath() | ||
756 | { | ||
757 | $form = $this->getBuilder()->setPropertyPath('address.street')->getForm(); | ||
758 | |||
759 | $this->assertEquals(new PropertyPath('address.street'), $form->getPropertyPath()); | ||
760 | } | ||
761 | |||
762 | // see https://github.com/symfony/symfony/issues/3903 | ||
763 | public function testGetPropertyPathDefaultsToNameIfParentHasDataClass() | ||
764 | { | ||
765 | $parent = $this->getBuilder(null, null, 'stdClass') | ||
766 | ->setCompound(true) | ||
767 | ->setDataMapper($this->getDataMapper()) | ||
768 | ->getForm(); | ||
769 | $form = $this->getBuilder('name')->getForm(); | ||
770 | $parent->add($form); | ||
771 | |||
772 | $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); | ||
773 | } | ||
774 | |||
775 | // see https://github.com/symfony/symfony/issues/3903 | ||
776 | public function testGetPropertyPathDefaultsToIndexedNameIfParentDataClassIsNull() | ||
777 | { | ||
778 | $parent = $this->getBuilder() | ||
779 | ->setCompound(true) | ||
780 | ->setDataMapper($this->getDataMapper()) | ||
781 | ->getForm(); | ||
782 | $form = $this->getBuilder('name')->getForm(); | ||
783 | $parent->add($form); | ||
784 | |||
785 | $this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath()); | ||
786 | } | ||
787 | |||
788 | public function testGetPropertyPathDefaultsToNameIfFirstParentWithoutInheritDataHasDataClass() | ||
789 | { | ||
790 | $grandParent = $this->getBuilder(null, null, 'stdClass') | ||
791 | ->setCompound(true) | ||
792 | ->setDataMapper($this->getDataMapper()) | ||
793 | ->getForm(); | ||
794 | $parent = $this->getBuilder() | ||
795 | ->setCompound(true) | ||
796 | ->setDataMapper($this->getDataMapper()) | ||
797 | ->setInheritData(true) | ||
798 | ->getForm(); | ||
799 | $form = $this->getBuilder('name')->getForm(); | ||
800 | $grandParent->add($parent); | ||
801 | $parent->add($form); | ||
802 | |||
803 | $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); | ||
804 | } | ||
805 | |||
806 | public function testGetPropertyPathDefaultsToIndexedNameIfDataClassOfFirstParentWithoutInheritDataIsNull() | ||
807 | { | ||
808 | $grandParent = $this->getBuilder() | ||
809 | ->setCompound(true) | ||
810 | ->setDataMapper($this->getDataMapper()) | ||
811 | ->getForm(); | ||
812 | $parent = $this->getBuilder() | ||
813 | ->setCompound(true) | ||
814 | ->setDataMapper($this->getDataMapper()) | ||
815 | ->setInheritData(true) | ||
816 | ->getForm(); | ||
817 | $form = $this->getBuilder('name')->getForm(); | ||
818 | $grandParent->add($parent); | ||
819 | $parent->add($form); | ||
820 | |||
821 | $this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath()); | ||
822 | } | ||
823 | |||
824 | /** | ||
825 | * @expectedException \Symfony\Component\Form\Exception\LogicException | ||
826 | */ | ||
827 | public function testViewDataMustNotBeObjectIfDataClassIsNull() | ||
828 | { | ||
829 | $config = new FormConfigBuilder('name', null, $this->dispatcher); | ||
830 | $config->addViewTransformer(new FixedDataTransformer(array( | ||
831 | '' => '', | ||
832 | 'foo' => new \stdClass(), | ||
833 | ))); | ||
834 | $form = new Form($config); | ||
835 | |||
836 | $form->setData('foo'); | ||
837 | } | ||
838 | |||
839 | public function testViewDataMayBeArrayAccessIfDataClassIsNull() | ||
840 | { | ||
841 | $arrayAccess = $this->getMock('\ArrayAccess'); | ||
842 | $config = new FormConfigBuilder('name', null, $this->dispatcher); | ||
843 | $config->addViewTransformer(new FixedDataTransformer(array( | ||
844 | '' => '', | ||
845 | 'foo' => $arrayAccess, | ||
846 | ))); | ||
847 | $form = new Form($config); | ||
848 | |||
849 | $form->setData('foo'); | ||
850 | |||
851 | $this->assertSame($arrayAccess, $form->getViewData()); | ||
852 | } | ||
853 | |||
854 | /** | ||
855 | * @expectedException \Symfony\Component\Form\Exception\LogicException | ||
856 | */ | ||
857 | public function testViewDataMustBeObjectIfDataClassIsSet() | ||
858 | { | ||
859 | $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); | ||
860 | $config->addViewTransformer(new FixedDataTransformer(array( | ||
861 | '' => '', | ||
862 | 'foo' => array('bar' => 'baz'), | ||
863 | ))); | ||
864 | $form = new Form($config); | ||
865 | |||
866 | $form->setData('foo'); | ||
867 | } | ||
868 | |||
869 | /** | ||
870 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
871 | */ | ||
872 | public function testSetDataCannotInvokeItself() | ||
873 | { | ||
874 | // Cycle detection to prevent endless loops | ||
875 | $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); | ||
876 | $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | ||
877 | $event->getForm()->setData('bar'); | ||
878 | }); | ||
879 | $form = new Form($config); | ||
880 | |||
881 | $form->setData('foo'); | ||
882 | } | ||
883 | |||
884 | public function testSubmittingWrongDataIsIgnored() | ||
885 | { | ||
886 | $test = $this; | ||
887 | |||
888 | $child = $this->getBuilder('child', $this->dispatcher); | ||
889 | $child->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($test) { | ||
890 | // child form doesn't receive the wrong data that is submitted on parent | ||
891 | $test->assertNull($event->getData()); | ||
892 | }); | ||
893 | |||
894 | $parent = $this->getBuilder('parent', new EventDispatcher()) | ||
895 | ->setCompound(true) | ||
896 | ->setDataMapper($this->getDataMapper()) | ||
897 | ->add($child) | ||
898 | ->getForm(); | ||
899 | |||
900 | $parent->submit('not-an-array'); | ||
901 | } | ||
902 | |||
903 | public function testHandleRequestForwardsToRequestHandler() | ||
904 | { | ||
905 | $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface'); | ||
906 | |||
907 | $form = $this->getBuilder() | ||
908 | ->setRequestHandler($handler) | ||
909 | ->getForm(); | ||
910 | |||
911 | $handler->expects($this->once()) | ||
912 | ->method('handleRequest') | ||
913 | ->with($this->identicalTo($form), 'REQUEST'); | ||
914 | |||
915 | $this->assertSame($form, $form->handleRequest('REQUEST')); | ||
916 | } | ||
917 | |||
918 | public function testFormInheritsParentData() | ||
919 | { | ||
920 | $child = $this->getBuilder('child') | ||
921 | ->setInheritData(true); | ||
922 | |||
923 | $parent = $this->getBuilder('parent') | ||
924 | ->setCompound(true) | ||
925 | ->setDataMapper($this->getDataMapper()) | ||
926 | ->setData('foo') | ||
927 | ->addModelTransformer(new FixedDataTransformer(array( | ||
928 | 'foo' => 'norm[foo]', | ||
929 | ))) | ||
930 | ->addViewTransformer(new FixedDataTransformer(array( | ||
931 | 'norm[foo]' => 'view[foo]', | ||
932 | ))) | ||
933 | ->add($child) | ||
934 | ->getForm(); | ||
935 | |||
936 | $this->assertSame('foo', $parent->get('child')->getData()); | ||
937 | $this->assertSame('norm[foo]', $parent->get('child')->getNormData()); | ||
938 | $this->assertSame('view[foo]', $parent->get('child')->getViewData()); | ||
939 | } | ||
940 | |||
941 | /** | ||
942 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
943 | */ | ||
944 | public function testInheritDataDisallowsSetData() | ||
945 | { | ||
946 | $form = $this->getBuilder() | ||
947 | ->setInheritData(true) | ||
948 | ->getForm(); | ||
949 | |||
950 | $form->setData('foo'); | ||
951 | } | ||
952 | |||
953 | /** | ||
954 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
955 | */ | ||
956 | public function testGetDataRequiresParentToBeSetIfInheritData() | ||
957 | { | ||
958 | $form = $this->getBuilder() | ||
959 | ->setInheritData(true) | ||
960 | ->getForm(); | ||
961 | |||
962 | $form->getData(); | ||
963 | } | ||
964 | |||
965 | /** | ||
966 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
967 | */ | ||
968 | public function testGetNormDataRequiresParentToBeSetIfInheritData() | ||
969 | { | ||
970 | $form = $this->getBuilder() | ||
971 | ->setInheritData(true) | ||
972 | ->getForm(); | ||
973 | |||
974 | $form->getNormData(); | ||
975 | } | ||
976 | |||
977 | /** | ||
978 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
979 | */ | ||
980 | public function testGetViewDataRequiresParentToBeSetIfInheritData() | ||
981 | { | ||
982 | $form = $this->getBuilder() | ||
983 | ->setInheritData(true) | ||
984 | ->getForm(); | ||
985 | |||
986 | $form->getViewData(); | ||
987 | } | ||
988 | |||
989 | public function testPostSubmitDataIsNullIfInheritData() | ||
990 | { | ||
991 | $test = $this; | ||
992 | $form = $this->getBuilder() | ||
993 | ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($test) { | ||
994 | $test->assertNull($event->getData()); | ||
995 | }) | ||
996 | ->setInheritData(true) | ||
997 | ->getForm(); | ||
998 | |||
999 | $form->submit('foo'); | ||
1000 | } | ||
1001 | |||
1002 | public function testSubmitIsNeverFiredIfInheritData() | ||
1003 | { | ||
1004 | $test = $this; | ||
1005 | $form = $this->getBuilder() | ||
1006 | ->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) use ($test) { | ||
1007 | $test->fail('The SUBMIT event should not be fired'); | ||
1008 | }) | ||
1009 | ->setInheritData(true) | ||
1010 | ->getForm(); | ||
1011 | |||
1012 | $form->submit('foo'); | ||
1013 | } | ||
1014 | |||
1015 | public function testInitializeSetsDefaultData() | ||
1016 | { | ||
1017 | $config = $this->getBuilder()->setData('DEFAULT')->getFormConfig(); | ||
1018 | $form = $this->getMock('Symfony\Component\Form\Form', array('setData'), array($config)); | ||
1019 | |||
1020 | $form->expects($this->once()) | ||
1021 | ->method('setData') | ||
1022 | ->with($this->identicalTo('DEFAULT')); | ||
1023 | |||
1024 | /* @var Form $form */ | ||
1025 | $form->initialize(); | ||
1026 | } | ||
1027 | |||
1028 | /** | ||
1029 | * @expectedException \Symfony\Component\Form\Exception\RuntimeException | ||
1030 | */ | ||
1031 | public function testInitializeFailsIfParent() | ||
1032 | { | ||
1033 | $parent = $this->getBuilder()->setRequired(false)->getForm(); | ||
1034 | $child = $this->getBuilder()->setRequired(true)->getForm(); | ||
1035 | |||
1036 | $child->setParent($parent); | ||
1037 | |||
1038 | $child->initialize(); | ||
1039 | } | ||
1040 | |||
1041 | protected function createForm() | ||
1042 | { | ||
1043 | return $this->getBuilder()->getForm(); | ||
1044 | } | ||
1045 | } | ||