aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type')
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php135
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php28
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php162
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php38
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php949
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php200
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php52
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php37
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php477
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php781
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php83
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php578
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php34
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php47
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php36
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php59
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php63
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php51
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php149
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php54
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php649
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php30
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php21
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php61
24 files changed, 0 insertions, 4774 deletions
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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17abstract 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\CallbackTransformer;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Test\FormPerformanceTestCase;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
15use Symfony\Component\Form\Extension\Core\View\ChoiceView;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Form;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\FormError;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Form\FormError;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\PropertyAccess\PropertyPath;
15use Symfony\Component\Form\Form;
16use Symfony\Component\Form\CallbackTransformer;
17use Symfony\Component\Form\Tests\Fixtures\Author;
18use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
19use Symfony\Component\Form\FormError;
20
21class 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
53class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Intl\Util\IntlTestHelper;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Intl\Util\IntlTestHelper;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Intl\Util\IntlTestHelper;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15use Symfony\Component\Form\FormError;
16use Symfony\Component\Intl\Util\IntlTestHelper;
17
18class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use Symfony\Component\Form\Extension\Core\View\ChoiceView;
15
16class 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14use 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 */
19abstract 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
12namespace Symfony\Component\Form\Tests\Extension\Core\Type;
13
14class 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}