aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/form/Symfony/Component/Form/Tests/Extension
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension')
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php200
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php116
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php212
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php188
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php319
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php149
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php60
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php76
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php76
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php53
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php20
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php512
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php275
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php132
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php181
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php104
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php115
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php74
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php393
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php114
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php120
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php106
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php61
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhashbin35 -> 0 bytes
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php27
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php27
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php28
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php259
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php255
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php79
-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
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php81
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php75
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php78
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php301
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php286
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php54
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php748
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php145
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php85
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php49
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php46
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php1481
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php245
67 files changed, 0 insertions, 12779 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php
deleted file mode 100644
index 63eae9bf..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php
+++ /dev/null
@@ -1,200 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
15use Symfony\Component\Form\Extension\Core\View\ChoiceView;
16
17class ChoiceListTest extends \PHPUnit_Framework_TestCase
18{
19 private $obj1;
20
21 private $obj2;
22
23 private $obj3;
24
25 private $obj4;
26
27 private $list;
28
29 protected function setUp()
30 {
31 parent::setUp();
32
33 $this->obj1 = new \stdClass();
34 $this->obj2 = new \stdClass();
35 $this->obj3 = new \stdClass();
36 $this->obj4 = new \stdClass();
37
38 $this->list = new ChoiceList(
39 array(
40 'Group 1' => array($this->obj1, $this->obj2),
41 'Group 2' => array($this->obj3, $this->obj4),
42 ),
43 array(
44 'Group 1' => array('A', 'B'),
45 'Group 2' => array('C', 'D'),
46 ),
47 array($this->obj2, $this->obj3)
48 );
49 }
50
51 protected function tearDown()
52 {
53 parent::tearDown();
54
55 $this->obj1 = null;
56 $this->obj2 = null;
57 $this->obj3 = null;
58 $this->obj4 = null;
59 $this->list = null;
60 }
61
62 public function testInitArray()
63 {
64 $this->list = new ChoiceList(
65 array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
66 array('A', 'B', 'C', 'D'),
67 array($this->obj2)
68 );
69
70 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
71 $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
72 $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews());
73 $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews());
74 }
75
76 /**
77 * Necessary for interoperability with MongoDB cursors or ORM relations as
78 * choices parameter. A choice itself that is an object implementing \Traversable
79 * is not treated as hierarchical structure, but as-is.
80 */
81 public function testInitNestedTraversable()
82 {
83 $traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4));
84
85 $this->list = new ChoiceList(
86 new \ArrayIterator(array(
87 'Group' => array($this->obj1, $this->obj2),
88 'Not a Group' => $traversableChoice
89 )),
90 array(
91 'Group' => array('A', 'B'),
92 'Not a Group' => 'C',
93 ),
94 array($this->obj2)
95 );
96
97 $this->assertSame(array($this->obj1, $this->obj2, $traversableChoice), $this->list->getChoices());
98 $this->assertSame(array('0', '1', '2'), $this->list->getValues());
99 $this->assertEquals(array(
100 'Group' => array(1 => new ChoiceView($this->obj2, '1', 'B'))
101 ), $this->list->getPreferredViews());
102 $this->assertEquals(array(
103 'Group' => array(0 => new ChoiceView($this->obj1, '0', 'A')),
104 2 => new ChoiceView($traversableChoice, '2', 'C')
105 ), $this->list->getRemainingViews());
106 }
107
108 public function testInitNestedArray()
109 {
110 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
111 $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
112 $this->assertEquals(array(
113 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')),
114 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C'))
115 ), $this->list->getPreferredViews());
116 $this->assertEquals(array(
117 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')),
118 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D'))
119 ), $this->list->getRemainingViews());
120 }
121
122 public function testGetIndicesForChoices()
123 {
124 $choices = array($this->obj2, $this->obj3);
125 $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
126 }
127
128 public function testGetIndicesForChoicesIgnoresNonExistingChoices()
129 {
130 $choices = array($this->obj2, $this->obj3, 'foobar');
131 $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
132 }
133
134 public function testGetIndicesForValues()
135 {
136 // values and indices are always the same
137 $values = array('1', '2');
138 $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
139 }
140
141 public function testGetIndicesForValuesIgnoresNonExistingValues()
142 {
143 $values = array('1', '2', '5');
144 $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
145 }
146
147 public function testGetChoicesForValues()
148 {
149 $values = array('1', '2');
150 $this->assertSame(array($this->obj2, $this->obj3), $this->list->getChoicesForValues($values));
151 }
152
153 public function testGetChoicesForValuesCorrectOrderingOfResult()
154 {
155 $values = array('2', '1');
156 $this->assertSame(array($this->obj3, $this->obj2), $this->list->getChoicesForValues($values));
157 }
158
159 public function testGetChoicesForValuesIgnoresNonExistingValues()
160 {
161 $values = array('1', '2', '5');
162 $this->assertSame(array($this->obj2, $this->obj3), $this->list->getChoicesForValues($values));
163 }
164
165 public function testGetValuesForChoices()
166 {
167 $choices = array($this->obj2, $this->obj3);
168 $this->assertSame(array('1', '2'), $this->list->getValuesForChoices($choices));
169 }
170
171 public function testGetValuesForChoicesIgnoresNonExistingChoices()
172 {
173 $choices = array($this->obj2, $this->obj3, 'foobar');
174 $this->assertSame(array('1', '2'), $this->list->getValuesForChoices($choices));
175 }
176
177 /**
178 * @expectedException \InvalidArgumentException
179 */
180 public function testNonMatchingLabels()
181 {
182 $this->list = new ChoiceList(
183 array($this->obj1, $this->obj2),
184 array('A')
185 );
186 }
187
188 public function testLabelsContainingNull()
189 {
190 $this->list = new ChoiceList(
191 array($this->obj1, $this->obj2),
192 array('A', null)
193 );
194
195 $this->assertEquals(
196 array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)),
197 $this->list->getRemainingViews()
198 );
199 }
200}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php
deleted file mode 100644
index bcd309e0..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php
+++ /dev/null
@@ -1,116 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
15use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList;
16use Symfony\Component\Form\Extension\Core\View\ChoiceView;
17
18class LazyChoiceListTest extends \PHPUnit_Framework_TestCase
19{
20 private $list;
21
22 protected function setUp()
23 {
24 parent::setUp();
25
26 $this->list = new LazyChoiceListTest_Impl(new SimpleChoiceList(array(
27 'a' => 'A',
28 'b' => 'B',
29 'c' => 'C',
30 ), array('b')));
31 }
32
33 protected function tearDown()
34 {
35 parent::tearDown();
36
37 $this->list = null;
38 }
39
40 public function testGetChoices()
41 {
42 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices());
43 }
44
45 public function testGetValues()
46 {
47 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues());
48 }
49
50 public function testGetPreferredViews()
51 {
52 $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews());
53 }
54
55 public function testGetRemainingViews()
56 {
57 $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
58 }
59
60 public function testGetIndicesForChoices()
61 {
62 $choices = array('b', 'c');
63 $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
64 }
65
66 public function testGetIndicesForValues()
67 {
68 $values = array('b', 'c');
69 $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
70 }
71
72 public function testGetChoicesForValues()
73 {
74 $values = array('b', 'c');
75 $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values));
76 }
77
78 public function testGetValuesForChoices()
79 {
80 $choices = array('b', 'c');
81 $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices));
82 }
83
84 /**
85 * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException
86 */
87 public function testLoadChoiceListShouldReturnChoiceList()
88 {
89 $list = new LazyChoiceListTest_InvalidImpl();
90
91 $list->getChoices();
92 }
93}
94
95class LazyChoiceListTest_Impl extends LazyChoiceList
96{
97 private $choiceList;
98
99 public function __construct($choiceList)
100 {
101 $this->choiceList = $choiceList;
102 }
103
104 protected function loadChoiceList()
105 {
106 return $this->choiceList;
107 }
108}
109
110class LazyChoiceListTest_InvalidImpl extends LazyChoiceList
111{
112 protected function loadChoiceList()
113 {
114 return new \stdClass();
115 }
116}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php
deleted file mode 100644
index 69c5aa0f..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php
+++ /dev/null
@@ -1,212 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList;
15use Symfony\Component\Form\Extension\Core\View\ChoiceView;
16
17class ObjectChoiceListTest_EntityWithToString
18{
19 private $property;
20
21 public function __construct($property)
22 {
23 $this->property = $property;
24 }
25
26 public function __toString()
27 {
28 return $this->property;
29 }
30}
31
32class ObjectChoiceListTest extends \PHPUnit_Framework_TestCase
33{
34 private $obj1;
35
36 private $obj2;
37
38 private $obj3;
39
40 private $obj4;
41
42 /**
43 * @var ObjectChoiceList
44 */
45 private $list;
46
47 protected function setUp()
48 {
49 parent::setUp();
50
51 $this->obj1 = (object) array('name' => 'A');
52 $this->obj2 = (object) array('name' => 'B');
53 $this->obj3 = (object) array('name' => 'C');
54 $this->obj4 = (object) array('name' => 'D');
55
56 $this->list = new ObjectChoiceList(
57 array(
58 'Group 1' => array($this->obj1, $this->obj2),
59 'Group 2' => array($this->obj3, $this->obj4),
60 ),
61 'name',
62 array($this->obj2, $this->obj3)
63 );
64 }
65
66 protected function tearDown()
67 {
68 parent::tearDown();
69
70 $this->obj1 = null;
71 $this->obj2 = null;
72 $this->obj3 = null;
73 $this->obj4 = null;
74 $this->list = null;
75 }
76
77 public function testInitArray()
78 {
79 $this->list = new ObjectChoiceList(
80 array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
81 'name',
82 array($this->obj2)
83 );
84
85 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
86 $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
87 $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews());
88 $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews());
89 }
90
91 public function testInitNestedArray()
92 {
93 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
94 $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
95 $this->assertEquals(array(
96 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')),
97 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C'))
98 ), $this->list->getPreferredViews());
99 $this->assertEquals(array(
100 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')),
101 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D'))
102 ), $this->list->getRemainingViews());
103 }
104
105 public function testInitArrayWithGroupPath()
106 {
107 $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
108 $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
109 $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2');
110 $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2');
111
112 // Objects with NULL groups are not grouped
113 $obj5 = (object) array('name' => 'E', 'category' => null);
114
115 // Objects without the group property are not grouped either
116 // see https://github.com/symfony/symfony/commit/d9b7abb7c7a0f28e0ce970afc5e305dce5dccddf
117 $obj6 = (object) array('name' => 'F');
118
119 $this->list = new ObjectChoiceList(
120 array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6),
121 'name',
122 array($this->obj2, $this->obj3),
123 'category'
124 );
125
126 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6), $this->list->getChoices());
127 $this->assertSame(array('0', '1', '2', '3', '4', '5'), $this->list->getValues());
128 $this->assertEquals(array(
129 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')),
130 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C'))
131 ), $this->list->getPreferredViews());
132 $this->assertEquals(array(
133 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')),
134 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')),
135 4 => new ChoiceView($obj5, '4', 'E'),
136 5 => new ChoiceView($obj6, '5', 'F'),
137 ), $this->list->getRemainingViews());
138 }
139
140 /**
141 * @expectedException \InvalidArgumentException
142 */
143 public function testInitArrayWithGroupPathThrowsExceptionIfNestedArray()
144 {
145 $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1');
146 $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1');
147 $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2');
148 $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2');
149
150 new ObjectChoiceList(
151 array(
152 'Group 1' => array($this->obj1, $this->obj2),
153 'Group 2' => array($this->obj3, $this->obj4),
154 ),
155 'name',
156 array($this->obj2, $this->obj3),
157 'category'
158 );
159 }
160
161 public function testInitArrayWithValuePath()
162 {
163 $this->obj1 = (object) array('name' => 'A', 'id' => 10);
164 $this->obj2 = (object) array('name' => 'B', 'id' => 20);
165 $this->obj3 = (object) array('name' => 'C', 'id' => 30);
166 $this->obj4 = (object) array('name' => 'D', 'id' => 40);
167
168 $this->list = new ObjectChoiceList(
169 array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
170 'name',
171 array($this->obj2, $this->obj3),
172 null,
173 'id'
174 );
175
176 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
177 $this->assertSame(array('10', '20', '30', '40'), $this->list->getValues());
178 $this->assertEquals(array(1 => new ChoiceView($this->obj2, '20', 'B'), 2 => new ChoiceView($this->obj3, '30', 'C')), $this->list->getPreferredViews());
179 $this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews());
180 }
181
182 public function testInitArrayUsesToString()
183 {
184 $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
185 $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
186 $this->obj3 = new ObjectChoiceListTest_EntityWithToString('C');
187 $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D');
188
189 $this->list = new ObjectChoiceList(
190 array($this->obj1, $this->obj2, $this->obj3, $this->obj4)
191 );
192
193 $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
194 $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues());
195 $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews());
196 }
197
198 /**
199 * @expectedException \Symfony\Component\Form\Exception\StringCastException
200 */
201 public function testInitArrayThrowsExceptionIfToStringNotFound()
202 {
203 $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A');
204 $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B');
205 $this->obj3 = (object) array('name' => 'C');
206 $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D');
207
208 new ObjectChoiceList(
209 array($this->obj1, $this->obj2, $this->obj3, $this->obj4)
210 );
211 }
212}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php
deleted file mode 100644
index 69d27a18..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php
+++ /dev/null
@@ -1,188 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList;
15use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
16use Symfony\Component\Form\Extension\Core\View\ChoiceView;
17
18class SimpleChoiceListTest extends \PHPUnit_Framework_TestCase
19{
20 private $list;
21
22 private $numericList;
23
24 protected function setUp()
25 {
26 parent::setUp();
27
28 $choices = array(
29 'Group 1' => array('a' => 'A', 'b' => 'B'),
30 'Group 2' => array('c' => 'C', 'd' => 'D'),
31 );
32 $numericChoices = array(
33 'Group 1' => array(0 => 'A', 1 => 'B'),
34 'Group 2' => array(2 => 'C', 3 => 'D'),
35 );
36
37 $this->list = new SimpleChoiceList($choices, array('b', 'c'));
38
39 // Use COPY_CHOICE strategy to test for the various associated problems
40 $this->numericList = new SimpleChoiceList($numericChoices, array(1, 2));
41 }
42
43 protected function tearDown()
44 {
45 parent::tearDown();
46
47 $this->list = null;
48 $this->numericList = null;
49 }
50
51 public function testInitArray()
52 {
53 $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C');
54 $this->list = new SimpleChoiceList($choices, array('b'));
55
56 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices());
57 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues());
58 $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews());
59 $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
60 }
61
62 public function testInitNestedArray()
63 {
64 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices());
65 $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues());
66 $this->assertEquals(array(
67 'Group 1' => array(1 => new ChoiceView('b', 'b', 'B')),
68 'Group 2' => array(2 => new ChoiceView('c', 'c', 'C'))
69 ), $this->list->getPreferredViews());
70 $this->assertEquals(array(
71 'Group 1' => array(0 => new ChoiceView('a', 'a', 'A')),
72 'Group 2' => array(3 => new ChoiceView('d', 'd', 'D'))
73 ), $this->list->getRemainingViews());
74 }
75
76 public function testGetIndicesForChoices()
77 {
78 $choices = array('b', 'c');
79 $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
80 }
81
82 public function testGetIndicesForChoicesIgnoresNonExistingChoices()
83 {
84 $choices = array('b', 'c', 'foobar');
85 $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
86 }
87
88 public function testGetIndicesForChoicesDealsWithNumericChoices()
89 {
90 // Pass choices as strings although they are integers
91 $choices = array('0', '1');
92 $this->assertSame(array(0, 1), $this->numericList->getIndicesForChoices($choices));
93 }
94
95 public function testGetIndicesForValues()
96 {
97 $values = array('b', 'c');
98 $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
99 }
100
101 public function testGetIndicesForValuesIgnoresNonExistingValues()
102 {
103 $values = array('b', 'c', '100');
104 $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
105 }
106
107 public function testGetIndicesForValuesDealsWithNumericValues()
108 {
109 // Pass values as strings although they are integers
110 $values = array('0', '1');
111 $this->assertSame(array(0, 1), $this->numericList->getIndicesForValues($values));
112 }
113
114 public function testGetChoicesForValues()
115 {
116 $values = array('b', 'c');
117 $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values));
118 }
119
120 public function testGetChoicesForValuesIgnoresNonExistingValues()
121 {
122 $values = array('b', 'c', '100');
123 $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values));
124 }
125
126 public function testGetChoicesForValuesDealsWithNumericValues()
127 {
128 // Pass values as strings although they are integers
129 $values = array('0', '1');
130 $this->assertSame(array(0, 1), $this->numericList->getChoicesForValues($values));
131 }
132
133 public function testGetValuesForChoices()
134 {
135 $choices = array('b', 'c');
136 $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices));
137 }
138
139 public function testGetValuesForChoicesIgnoresNonExistingValues()
140 {
141 $choices = array('b', 'c', 'foobar');
142 $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices));
143 }
144
145 public function testGetValuesForChoicesDealsWithNumericValues()
146 {
147 // Pass values as strings although they are integers
148 $values = array('0', '1');
149
150 $this->assertSame(array('0', '1'), $this->numericList->getValuesForChoices($values));
151 }
152
153 /**
154 * @dataProvider dirtyValuesProvider
155 */
156 public function testGetValuesForChoicesDealsWithDirtyValues($choice, $value)
157 {
158 $choices = array(
159 '0' => 'Zero',
160 '1' => 'One',
161 '' => 'Empty',
162 '1.23' => 'Float',
163 'foo' => 'Foo',
164 'foo10' => 'Foo 10',
165 );
166
167 // use COPY_CHOICE strategy to test the problems
168 $this->list = new SimpleChoiceList($choices, array());
169
170 $this->assertSame(array($value), $this->list->getValuesForChoices(array($choice)));
171 }
172
173 public function dirtyValuesProvider()
174 {
175 return array(
176 array(0, '0'),
177 array('0', '0'),
178 array('1', '1'),
179 array(false, '0'),
180 array(true, '1'),
181 array('', ''),
182 array(null, ''),
183 array('1.23', '1.23'),
184 array('foo', 'foo'),
185 array('foo10', 'foo10'),
186 );
187 }
188}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php
deleted file mode 100644
index ee2e3351..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php
+++ /dev/null
@@ -1,319 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataMapper;
13
14use Symfony\Component\Form\FormConfigBuilder;
15use Symfony\Component\Form\FormConfigInterface;
16use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
17
18class PropertyPathMapperTest extends \PHPUnit_Framework_TestCase
19{
20 /**
21 * @var PropertyPathMapper
22 */
23 private $mapper;
24
25 /**
26 * @var \PHPUnit_Framework_MockObject_MockObject
27 */
28 private $dispatcher;
29
30 /**
31 * @var \PHPUnit_Framework_MockObject_MockObject
32 */
33 private $propertyAccessor;
34
35 protected function setUp()
36 {
37 if (!class_exists('Symfony\Component\EventDispatcher\Event')) {
38 $this->markTestSkipped('The "EventDispatcher" component is not available');
39 }
40
41 if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) {
42 $this->markTestSkipped('The "PropertyAccess" component is not available');
43 }
44
45 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
46 $this->propertyAccessor = $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface');
47 $this->mapper = new PropertyPathMapper($this->propertyAccessor);
48 }
49
50 /**
51 * @param $path
52 * @return \PHPUnit_Framework_MockObject_MockObject
53 */
54 private function getPropertyPath($path)
55 {
56 return $this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyPath')
57 ->setConstructorArgs(array($path))
58 ->setMethods(array('getValue', 'setValue'))
59 ->getMock();
60 }
61
62 /**
63 * @param FormConfigInterface $config
64 * @param Boolean $synchronized
65 * @return \PHPUnit_Framework_MockObject_MockObject
66 */
67 private function getForm(FormConfigInterface $config, $synchronized = true)
68 {
69 $form = $this->getMockBuilder('Symfony\Component\Form\Form')
70 ->setConstructorArgs(array($config))
71 ->setMethods(array('isSynchronized'))
72 ->getMock();
73
74 $form->expects($this->any())
75 ->method('isSynchronized')
76 ->will($this->returnValue($synchronized));
77
78 return $form;
79 }
80
81 /**
82 * @return \PHPUnit_Framework_MockObject_MockObject
83 */
84 private function getDataMapper()
85 {
86 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
87 }
88
89 public function testMapDataToFormsPassesObjectRefIfByReference()
90 {
91 $car = new \stdClass();
92 $engine = new \stdClass();
93 $propertyPath = $this->getPropertyPath('engine');
94
95 $this->propertyAccessor->expects($this->once())
96 ->method('getValue')
97 ->with($car, $propertyPath)
98 ->will($this->returnValue($engine));
99
100 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
101 $config->setByReference(true);
102 $config->setPropertyPath($propertyPath);
103 $form = $this->getForm($config);
104
105 $this->mapper->mapDataToForms($car, array($form));
106
107 // Can't use isIdentical() above because mocks always clone their
108 // arguments which can't be disabled in PHPUnit 3.6
109 $this->assertSame($engine, $form->getData());
110 }
111
112 public function testMapDataToFormsPassesObjectCloneIfNotByReference()
113 {
114 $car = new \stdClass();
115 $engine = new \stdClass();
116 $propertyPath = $this->getPropertyPath('engine');
117
118 $this->propertyAccessor->expects($this->once())
119 ->method('getValue')
120 ->with($car, $propertyPath)
121 ->will($this->returnValue($engine));
122
123 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
124 $config->setByReference(false);
125 $config->setPropertyPath($propertyPath);
126 $form = $this->getForm($config);
127
128 $this->mapper->mapDataToForms($car, array($form));
129
130 $this->assertNotSame($engine, $form->getData());
131 $this->assertEquals($engine, $form->getData());
132 }
133
134 public function testMapDataToFormsIgnoresEmptyPropertyPath()
135 {
136 $car = new \stdClass();
137
138 $config = new FormConfigBuilder(null, '\stdClass', $this->dispatcher);
139 $config->setByReference(true);
140 $form = $this->getForm($config);
141
142 $this->assertNull($form->getPropertyPath());
143
144 $this->mapper->mapDataToForms($car, array($form));
145
146 $this->assertNull($form->getData());
147 }
148
149 public function testMapDataToFormsIgnoresUnmapped()
150 {
151 $car = new \stdClass();
152 $propertyPath = $this->getPropertyPath('engine');
153
154 $this->propertyAccessor->expects($this->never())
155 ->method('getValue');
156
157 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
158 $config->setByReference(true);
159 $config->setMapped(false);
160 $config->setPropertyPath($propertyPath);
161 $form = $this->getForm($config);
162
163 $this->mapper->mapDataToForms($car, array($form));
164
165 $this->assertNull($form->getData());
166 }
167
168 public function testMapDataToFormsIgnoresEmptyData()
169 {
170 $propertyPath = $this->getPropertyPath('engine');
171
172 $this->propertyAccessor->expects($this->never())
173 ->method('getValue');
174
175 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
176 $config->setByReference(true);
177 $config->setPropertyPath($propertyPath);
178 $form = $this->getForm($config);
179
180 $this->mapper->mapDataToForms(null, array($form));
181
182 $this->assertNull($form->getData());
183 }
184
185 public function testMapFormsToDataWritesBackIfNotByReference()
186 {
187 $car = new \stdClass();
188 $engine = new \stdClass();
189 $propertyPath = $this->getPropertyPath('engine');
190
191 $this->propertyAccessor->expects($this->once())
192 ->method('setValue')
193 ->with($car, $propertyPath, $engine);
194
195 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
196 $config->setByReference(false);
197 $config->setPropertyPath($propertyPath);
198 $config->setData($engine);
199 $form = $this->getForm($config);
200
201 $this->mapper->mapFormsToData(array($form), $car);
202 }
203
204 public function testMapFormsToDataWritesBackIfByReferenceButNoReference()
205 {
206 $car = new \stdClass();
207 $engine = new \stdClass();
208 $propertyPath = $this->getPropertyPath('engine');
209
210 $this->propertyAccessor->expects($this->once())
211 ->method('setValue')
212 ->with($car, $propertyPath, $engine);
213
214 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
215 $config->setByReference(true);
216 $config->setPropertyPath($propertyPath);
217 $config->setData($engine);
218 $form = $this->getForm($config);
219
220 $this->mapper->mapFormsToData(array($form), $car);
221 }
222
223 public function testMapFormsToDataWritesBackIfByReferenceAndReference()
224 {
225 $car = new \stdClass();
226 $engine = new \stdClass();
227 $propertyPath = $this->getPropertyPath('engine');
228
229 // $car already contains the reference of $engine
230 $this->propertyAccessor->expects($this->once())
231 ->method('getValue')
232 ->with($car, $propertyPath)
233 ->will($this->returnValue($engine));
234
235 $this->propertyAccessor->expects($this->never())
236 ->method('setValue');
237
238 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
239 $config->setByReference(true);
240 $config->setPropertyPath($propertyPath);
241 $config->setData($engine);
242 $form = $this->getForm($config);
243
244 $this->mapper->mapFormsToData(array($form), $car);
245 }
246
247 public function testMapFormsToDataIgnoresUnmapped()
248 {
249 $car = new \stdClass();
250 $engine = new \stdClass();
251 $propertyPath = $this->getPropertyPath('engine');
252
253 $this->propertyAccessor->expects($this->never())
254 ->method('setValue');
255
256 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
257 $config->setByReference(true);
258 $config->setPropertyPath($propertyPath);
259 $config->setData($engine);
260 $config->setMapped(false);
261 $form = $this->getForm($config);
262
263 $this->mapper->mapFormsToData(array($form), $car);
264 }
265
266 public function testMapFormsToDataIgnoresEmptyData()
267 {
268 $car = new \stdClass();
269 $propertyPath = $this->getPropertyPath('engine');
270
271 $this->propertyAccessor->expects($this->never())
272 ->method('setValue');
273
274 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
275 $config->setByReference(true);
276 $config->setPropertyPath($propertyPath);
277 $config->setData(null);
278 $form = $this->getForm($config);
279
280 $this->mapper->mapFormsToData(array($form), $car);
281 }
282
283 public function testMapFormsToDataIgnoresUnsynchronized()
284 {
285 $car = new \stdClass();
286 $engine = new \stdClass();
287 $propertyPath = $this->getPropertyPath('engine');
288
289 $this->propertyAccessor->expects($this->never())
290 ->method('setValue');
291
292 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
293 $config->setByReference(true);
294 $config->setPropertyPath($propertyPath);
295 $config->setData($engine);
296 $form = $this->getForm($config, false);
297
298 $this->mapper->mapFormsToData(array($form), $car);
299 }
300
301 public function testMapFormsToDataIgnoresDisabled()
302 {
303 $car = new \stdClass();
304 $engine = new \stdClass();
305 $propertyPath = $this->getPropertyPath('engine');
306
307 $this->propertyAccessor->expects($this->never())
308 ->method('setValue');
309
310 $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher);
311 $config->setByReference(true);
312 $config->setPropertyPath($propertyPath);
313 $config->setData($engine);
314 $config->setDisabled(true);
315 $form = $this->getForm($config);
316
317 $this->mapper->mapFormsToData(array($form), $car);
318 }
319}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php
deleted file mode 100644
index bafe5c09..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php
+++ /dev/null
@@ -1,149 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;
15
16class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase
17{
18 private $transformer;
19
20 protected function setUp()
21 {
22 $this->transformer = new ArrayToPartsTransformer(array(
23 'first' => array('a', 'b', 'c'),
24 'second' => array('d', 'e', 'f'),
25 ));
26 }
27
28 protected function tearDown()
29 {
30 $this->transformer = null;
31 }
32
33 public function testTransform()
34 {
35 $input = array(
36 'a' => '1',
37 'b' => '2',
38 'c' => '3',
39 'd' => '4',
40 'e' => '5',
41 'f' => '6',
42 );
43
44 $output = array(
45 'first' => array(
46 'a' => '1',
47 'b' => '2',
48 'c' => '3',
49 ),
50 'second' => array(
51 'd' => '4',
52 'e' => '5',
53 'f' => '6',
54 ),
55 );
56
57 $this->assertSame($output, $this->transformer->transform($input));
58 }
59
60 public function testTransformEmpty()
61 {
62 $output = array(
63 'first' => null,
64 'second' => null,
65 );
66
67 $this->assertSame($output, $this->transformer->transform(null));
68 }
69
70 /**
71 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
72 */
73 public function testTransformRequiresArray()
74 {
75 $this->transformer->transform('12345');
76 }
77
78 public function testReverseTransform()
79 {
80 $input = array(
81 'first' => array(
82 'a' => '1',
83 'b' => '2',
84 'c' => '3',
85 ),
86 'second' => array(
87 'd' => '4',
88 'e' => '5',
89 'f' => '6',
90 ),
91 );
92
93 $output = array(
94 'a' => '1',
95 'b' => '2',
96 'c' => '3',
97 'd' => '4',
98 'e' => '5',
99 'f' => '6',
100 );
101
102 $this->assertSame($output, $this->transformer->reverseTransform($input));
103 }
104
105 public function testReverseTransformCompletelyEmpty()
106 {
107 $input = array(
108 'first' => '',
109 'second' => '',
110 );
111
112 $this->assertNull($this->transformer->reverseTransform($input));
113 }
114
115 public function testReverseTransformCompletelyNull()
116 {
117 $input = array(
118 'first' => null,
119 'second' => null,
120 );
121
122 $this->assertNull($this->transformer->reverseTransform($input));
123 }
124
125 /**
126 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
127 */
128 public function testReverseTransformPartiallyNull()
129 {
130 $input = array(
131 'first' => array(
132 'a' => '1',
133 'b' => '2',
134 'c' => '3',
135 ),
136 'second' => null,
137 );
138
139 $this->transformer->reverseTransform($input);
140 }
141
142 /**
143 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
144 */
145 public function testReverseTransformRequiresArray()
146 {
147 $this->transformer->reverseTransform('12345');
148 }
149}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php
deleted file mode 100644
index 41f8f956..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer;
15
16class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase
17{
18 const TRUE_VALUE = '1';
19
20 protected $transformer;
21
22 protected function setUp()
23 {
24 $this->transformer = new BooleanToStringTransformer(self::TRUE_VALUE);
25 }
26
27 protected function tearDown()
28 {
29 $this->transformer = null;
30 }
31
32 public function testTransform()
33 {
34 $this->assertEquals(self::TRUE_VALUE, $this->transformer->transform(true));
35 $this->assertNull($this->transformer->transform(false));
36 $this->assertNull($this->transformer->transform(null));
37 }
38
39 public function testTransformExpectsBoolean()
40 {
41 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
42
43 $this->transformer->transform('1');
44 }
45
46 public function testReverseTransformExpectsString()
47 {
48 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
49
50 $this->transformer->reverseTransform(1);
51 }
52
53 public function testReverseTransform()
54 {
55 $this->assertTrue($this->transformer->reverseTransform(self::TRUE_VALUE));
56 $this->assertTrue($this->transformer->reverseTransform('foobar'));
57 $this->assertTrue($this->transformer->reverseTransform(''));
58 $this->assertFalse($this->transformer->reverseTransform(null));
59 }
60}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php
deleted file mode 100644
index bbae0621..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
15use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer;
16
17class ChoiceToValueTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected $transformer;
20
21 protected function setUp()
22 {
23 $list = new SimpleChoiceList(array('' => 'A', 0 => 'B', 1 => 'C'));
24 $this->transformer = new ChoiceToValueTransformer($list);
25 }
26
27 protected function tearDown()
28 {
29 $this->transformer = null;
30 }
31
32 public function transformProvider()
33 {
34 return array(
35 // more extensive test set can be found in FormUtilTest
36 array(0, '0'),
37 array(false, '0'),
38 array('', ''),
39 );
40 }
41
42 /**
43 * @dataProvider transformProvider
44 */
45 public function testTransform($in, $out)
46 {
47 $this->assertSame($out, $this->transformer->transform($in));
48 }
49
50 public function reverseTransformProvider()
51 {
52 return array(
53 // values are expected to be valid choice keys already and stay
54 // the same
55 array('0', 0),
56 array('', null),
57 array(null, null),
58 );
59 }
60
61 /**
62 * @dataProvider reverseTransformProvider
63 */
64 public function testReverseTransform($in, $out)
65 {
66 $this->assertSame($out, $this->transformer->reverseTransform($in));
67 }
68
69 /**
70 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
71 */
72 public function testReverseTransformExpectsScalar()
73 {
74 $this->transformer->reverseTransform(array());
75 }
76}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php
deleted file mode 100644
index 57297193..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
15
16use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer;
17
18class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase
19{
20 protected $transformer;
21
22 protected function setUp()
23 {
24 $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B', 2 => 'C'));
25 $this->transformer = new ChoicesToValuesTransformer($list);
26 }
27
28 protected function tearDown()
29 {
30 $this->transformer = null;
31 }
32
33 public function testTransform()
34 {
35 // Value strategy in SimpleChoiceList is to copy and convert to string
36 $in = array(0, 1, 2);
37 $out = array('0', '1', '2');
38
39 $this->assertSame($out, $this->transformer->transform($in));
40 }
41
42 public function testTransformNull()
43 {
44 $this->assertSame(array(), $this->transformer->transform(null));
45 }
46
47 /**
48 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
49 */
50 public function testTransformExpectsArray()
51 {
52 $this->transformer->transform('foobar');
53 }
54
55 public function testReverseTransform()
56 {
57 // values are expected to be valid choices and stay the same
58 $in = array('0', '1', '2');
59 $out = array(0, 1, 2);
60
61 $this->assertSame($out, $this->transformer->reverseTransform($in));
62 }
63
64 public function testReverseTransformNull()
65 {
66 $this->assertSame(array(), $this->transformer->reverseTransform(null));
67 }
68
69 /**
70 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
71 */
72 public function testReverseTransformExpectsArray()
73 {
74 $this->transformer->reverseTransform('foobar');
75 }
76}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
deleted file mode 100644
index 2ee2f22d..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php
+++ /dev/null
@@ -1,53 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
15
16class DataTransformerChainTest extends \PHPUnit_Framework_TestCase
17{
18 public function testTransform()
19 {
20 $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
21 $transformer1->expects($this->once())
22 ->method('transform')
23 ->with($this->identicalTo('foo'))
24 ->will($this->returnValue('bar'));
25 $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
26 $transformer2->expects($this->once())
27 ->method('transform')
28 ->with($this->identicalTo('bar'))
29 ->will($this->returnValue('baz'));
30
31 $chain = new DataTransformerChain(array($transformer1, $transformer2));
32
33 $this->assertEquals('baz', $chain->transform('foo'));
34 }
35
36 public function testReverseTransform()
37 {
38 $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
39 $transformer2->expects($this->once())
40 ->method('reverseTransform')
41 ->with($this->identicalTo('foo'))
42 ->will($this->returnValue('bar'));
43 $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface');
44 $transformer1->expects($this->once())
45 ->method('reverseTransform')
46 ->with($this->identicalTo('bar'))
47 ->will($this->returnValue('baz'));
48
49 $chain = new DataTransformerChain(array($transformer1, $transformer2));
50
51 $this->assertEquals('baz', $chain->reverseTransform('foo'));
52 }
53}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php
deleted file mode 100644
index f7722c49..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php
+++ /dev/null
@@ -1,20 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase
15{
16 public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
17 {
18 self::assertEquals($expected->format('c'), $actual->format('c'));
19 }
20}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
deleted file mode 100644
index 4898b88d..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
+++ /dev/null
@@ -1,512 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
15
16class DateTimeToArrayTransformerTest extends DateTimeTestCase
17{
18 public function testTransform()
19 {
20 $transformer = new DateTimeToArrayTransformer('UTC', 'UTC');
21
22 $input = new \DateTime('2010-02-03 04:05:06 UTC');
23
24 $output = array(
25 'year' => '2010',
26 'month' => '2',
27 'day' => '3',
28 'hour' => '4',
29 'minute' => '5',
30 'second' => '6',
31 );
32
33 $this->assertSame($output, $transformer->transform($input));
34 }
35
36 public function testTransformEmpty()
37 {
38 $transformer = new DateTimeToArrayTransformer();
39
40 $output = array(
41 'year' => '',
42 'month' => '',
43 'day' => '',
44 'hour' => '',
45 'minute' => '',
46 'second' => '',
47 );
48
49 $this->assertSame($output, $transformer->transform(null));
50 }
51
52 public function testTransformEmptyWithFields()
53 {
54 $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second'));
55
56 $output = array(
57 'year' => '',
58 'minute' => '',
59 'second' => '',
60 );
61
62 $this->assertSame($output, $transformer->transform(null));
63 }
64
65 public function testTransformWithFields()
66 {
67 $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second'));
68
69 $input = new \DateTime('2010-02-03 04:05:06 UTC');
70
71 $output = array(
72 'year' => '2010',
73 'month' => '2',
74 'minute' => '5',
75 'second' => '6',
76 );
77
78 $this->assertSame($output, $transformer->transform($input));
79 }
80
81 public function testTransformWithPadding()
82 {
83 $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true);
84
85 $input = new \DateTime('2010-02-03 04:05:06 UTC');
86
87 $output = array(
88 'year' => '2010',
89 'month' => '02',
90 'day' => '03',
91 'hour' => '04',
92 'minute' => '05',
93 'second' => '06',
94 );
95
96 $this->assertSame($output, $transformer->transform($input));
97 }
98
99 public function testTransformDifferentTimezones()
100 {
101 $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
102
103 $input = new \DateTime('2010-02-03 04:05:06 America/New_York');
104
105 $dateTime = new \DateTime('2010-02-03 04:05:06 America/New_York');
106 $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
107 $output = array(
108 'year' => (string) (int) $dateTime->format('Y'),
109 'month' => (string) (int) $dateTime->format('m'),
110 'day' => (string) (int) $dateTime->format('d'),
111 'hour' => (string) (int) $dateTime->format('H'),
112 'minute' => (string) (int) $dateTime->format('i'),
113 'second' => (string) (int) $dateTime->format('s'),
114 );
115
116 $this->assertSame($output, $transformer->transform($input));
117 }
118
119 /**
120 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
121 */
122 public function testTransformRequiresDateTime()
123 {
124 $transformer = new DateTimeToArrayTransformer();
125 $transformer->reverseTransform('12345');
126 }
127
128 public function testReverseTransform()
129 {
130 $transformer = new DateTimeToArrayTransformer('UTC', 'UTC');
131
132 $input = array(
133 'year' => '2010',
134 'month' => '2',
135 'day' => '3',
136 'hour' => '4',
137 'minute' => '5',
138 'second' => '6',
139 );
140
141 $output = new \DateTime('2010-02-03 04:05:06 UTC');
142
143 $this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
144 }
145
146 public function testReverseTransformWithSomeZero()
147 {
148 $transformer = new DateTimeToArrayTransformer('UTC', 'UTC');
149
150 $input = array(
151 'year' => '2010',
152 'month' => '2',
153 'day' => '3',
154 'hour' => '4',
155 'minute' => '0',
156 'second' => '0',
157 );
158
159 $output = new \DateTime('2010-02-03 04:00:00 UTC');
160
161 $this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
162 }
163
164 public function testReverseTransformCompletelyEmpty()
165 {
166 $transformer = new DateTimeToArrayTransformer();
167
168 $input = array(
169 'year' => '',
170 'month' => '',
171 'day' => '',
172 'hour' => '',
173 'minute' => '',
174 'second' => '',
175 );
176
177 $this->assertNull($transformer->reverseTransform($input));
178 }
179
180 public function testReverseTransformCompletelyEmptySubsetOfFields()
181 {
182 $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day'));
183
184 $input = array(
185 'year' => '',
186 'month' => '',
187 'day' => '',
188 );
189
190 $this->assertNull($transformer->reverseTransform($input));
191 }
192
193 /**
194 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
195 */
196 public function testReverseTransformPartiallyEmptyYear()
197 {
198 $transformer = new DateTimeToArrayTransformer();
199 $transformer->reverseTransform(array(
200 'month' => '2',
201 'day' => '3',
202 'hour' => '4',
203 'minute' => '5',
204 'second' => '6',
205 ));
206 }
207
208 /**
209 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
210 */
211 public function testReverseTransformPartiallyEmptyMonth()
212 {
213 $transformer = new DateTimeToArrayTransformer();
214 $transformer->reverseTransform(array(
215 'year' => '2010',
216 'day' => '3',
217 'hour' => '4',
218 'minute' => '5',
219 'second' => '6',
220 ));
221 }
222
223 /**
224 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
225 */
226 public function testReverseTransformPartiallyEmptyDay()
227 {
228 $transformer = new DateTimeToArrayTransformer();
229 $transformer->reverseTransform(array(
230 'year' => '2010',
231 'month' => '2',
232 'hour' => '4',
233 'minute' => '5',
234 'second' => '6',
235 ));
236 }
237
238 /**
239 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
240 */
241 public function testReverseTransformPartiallyEmptyHour()
242 {
243 $transformer = new DateTimeToArrayTransformer();
244 $transformer->reverseTransform(array(
245 'year' => '2010',
246 'month' => '2',
247 'day' => '3',
248 'minute' => '5',
249 'second' => '6',
250 ));
251 }
252
253 /**
254 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
255 */
256 public function testReverseTransformPartiallyEmptyMinute()
257 {
258 $transformer = new DateTimeToArrayTransformer();
259 $transformer->reverseTransform(array(
260 'year' => '2010',
261 'month' => '2',
262 'day' => '3',
263 'hour' => '4',
264 'second' => '6',
265 ));
266 }
267
268 /**
269 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
270 */
271 public function testReverseTransformPartiallyEmptySecond()
272 {
273 $transformer = new DateTimeToArrayTransformer();
274 $transformer->reverseTransform(array(
275 'year' => '2010',
276 'month' => '2',
277 'day' => '3',
278 'hour' => '4',
279 'minute' => '5',
280 ));
281 }
282
283 public function testReverseTransformNull()
284 {
285 $transformer = new DateTimeToArrayTransformer();
286
287 $this->assertNull($transformer->reverseTransform(null));
288 }
289
290 public function testReverseTransformDifferentTimezones()
291 {
292 $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong');
293
294 $input = array(
295 'year' => '2010',
296 'month' => '2',
297 'day' => '3',
298 'hour' => '4',
299 'minute' => '5',
300 'second' => '6',
301 );
302
303 $output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong');
304 $output->setTimezone(new \DateTimeZone('America/New_York'));
305
306 $this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
307 }
308
309 public function testReverseTransformToDifferentTimezone()
310 {
311 $transformer = new DateTimeToArrayTransformer('Asia/Hong_Kong', 'UTC');
312
313 $input = array(
314 'year' => '2010',
315 'month' => '2',
316 'day' => '3',
317 'hour' => '4',
318 'minute' => '5',
319 'second' => '6',
320 );
321
322 $output = new \DateTime('2010-02-03 04:05:06 UTC');
323 $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
324
325 $this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
326 }
327
328 /**
329 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
330 */
331 public function testReverseTransformRequiresArray()
332 {
333 $transformer = new DateTimeToArrayTransformer();
334 $transformer->reverseTransform('12345');
335 }
336
337 /**
338 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
339 */
340 public function testReverseTransformWithNegativeYear()
341 {
342 $transformer = new DateTimeToArrayTransformer();
343 $transformer->reverseTransform(array(
344 'year' => '-1',
345 'month' => '2',
346 'day' => '3',
347 'hour' => '4',
348 'minute' => '5',
349 'second' => '6',
350 ));
351 }
352
353 /**
354 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
355 */
356 public function testReverseTransformWithNegativeMonth()
357 {
358 $transformer = new DateTimeToArrayTransformer();
359 $transformer->reverseTransform(array(
360 'year' => '2010',
361 'month' => '-1',
362 'day' => '3',
363 'hour' => '4',
364 'minute' => '5',
365 'second' => '6',
366 ));
367 }
368
369 /**
370 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
371 */
372 public function testReverseTransformWithNegativeDay()
373 {
374 $transformer = new DateTimeToArrayTransformer();
375 $transformer->reverseTransform(array(
376 'year' => '2010',
377 'month' => '2',
378 'day' => '-1',
379 'hour' => '4',
380 'minute' => '5',
381 'second' => '6',
382 ));
383 }
384
385 /**
386 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
387 */
388 public function testReverseTransformWithNegativeHour()
389 {
390 $transformer = new DateTimeToArrayTransformer();
391 $transformer->reverseTransform(array(
392 'year' => '2010',
393 'month' => '2',
394 'day' => '3',
395 'hour' => '-1',
396 'minute' => '5',
397 'second' => '6',
398 ));
399 }
400
401 /**
402 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
403 */
404 public function testReverseTransformWithNegativeMinute()
405 {
406 $transformer = new DateTimeToArrayTransformer();
407 $transformer->reverseTransform(array(
408 'year' => '2010',
409 'month' => '2',
410 'day' => '3',
411 'hour' => '4',
412 'minute' => '-1',
413 'second' => '6',
414 ));
415 }
416
417 /**
418 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
419 */
420 public function testReverseTransformWithNegativeSecond()
421 {
422 $transformer = new DateTimeToArrayTransformer();
423 $transformer->reverseTransform(array(
424 'year' => '2010',
425 'month' => '2',
426 'day' => '3',
427 'hour' => '4',
428 'minute' => '5',
429 'second' => '-1',
430 ));
431 }
432
433 /**
434 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
435 */
436 public function testReverseTransformWithInvalidMonth()
437 {
438 $transformer = new DateTimeToArrayTransformer();
439 $transformer->reverseTransform(array(
440 'year' => '2010',
441 'month' => '13',
442 'day' => '3',
443 'hour' => '4',
444 'minute' => '5',
445 'second' => '6',
446 ));
447 }
448
449 /**
450 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
451 */
452 public function testReverseTransformWithInvalidDay()
453 {
454 $transformer = new DateTimeToArrayTransformer();
455 $transformer->reverseTransform(array(
456 'year' => '2010',
457 'month' => '2',
458 'day' => '31',
459 'hour' => '4',
460 'minute' => '5',
461 'second' => '6',
462 ));
463 }
464
465 /**
466 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
467 */
468 public function testReverseTransformWithStringDay()
469 {
470 $transformer = new DateTimeToArrayTransformer();
471 $transformer->reverseTransform(array(
472 'year' => '2010',
473 'month' => '2',
474 'day' => 'bazinga',
475 'hour' => '4',
476 'minute' => '5',
477 'second' => '6',
478 ));
479 }
480
481 /**
482 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
483 */
484 public function testReverseTransformWithStringMonth()
485 {
486 $transformer = new DateTimeToArrayTransformer();
487 $transformer->reverseTransform(array(
488 'year' => '2010',
489 'month' => 'bazinga',
490 'day' => '31',
491 'hour' => '4',
492 'minute' => '5',
493 'second' => '6',
494 ));
495 }
496
497 /**
498 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
499 */
500 public function testReverseTransformWithStringYear()
501 {
502 $transformer = new DateTimeToArrayTransformer();
503 $transformer->reverseTransform(array(
504 'year' => 'bazinga',
505 'month' => '2',
506 'day' => '31',
507 'hour' => '4',
508 'minute' => '5',
509 'second' => '6',
510 ));
511 }
512}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
deleted file mode 100644
index cb50fc36..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php
+++ /dev/null
@@ -1,275 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
18{
19 protected $dateTime;
20 protected $dateTimeWithoutSeconds;
21
22 protected function setUp()
23 {
24 parent::setUp();
25
26 // Since we test against "de_AT", we need the full implementation
27 IntlTestHelper::requireFullIntl($this);
28
29 \Locale::setDefault('de_AT');
30
31 $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
32 $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
33 }
34
35 protected function tearDown()
36 {
37 $this->dateTime = null;
38 $this->dateTimeWithoutSeconds = null;
39 }
40
41 public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false)
42 {
43 if ($expected instanceof \DateTime && $actual instanceof \DateTime) {
44 $expected = $expected->format('c');
45 $actual = $actual->format('c');
46 }
47
48 parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
49 }
50
51 public function dataProvider()
52 {
53 return array(
54 array(\IntlDateFormatter::SHORT, null, null, '03.02.10 04:05', '2010-02-03 04:05:00 UTC'),
55 array(\IntlDateFormatter::MEDIUM, null, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'),
56 array(\IntlDateFormatter::LONG, null, null, '03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'),
57 array(\IntlDateFormatter::FULL, null, null, 'Mittwoch, 03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'),
58 array(\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, null, '03.02.10', '2010-02-03 00:00:00 UTC'),
59 array(\IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE, null, '03.02.2010', '2010-02-03 00:00:00 UTC'),
60 array(\IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, '03. Februar 2010', '2010-02-03 00:00:00 UTC'),
61 array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 03. Februar 2010', '2010-02-03 00:00:00 UTC'),
62 array(null, \IntlDateFormatter::SHORT, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'),
63 array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010 04:05:06', '2010-02-03 04:05:06 UTC'),
64 array(null, \IntlDateFormatter::LONG, null, '03.02.2010 04:05:06 GMT', '2010-02-03 04:05:06 UTC'),
65 // see below for extra test case for time format FULL
66 array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'),
67 array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'),
68 array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'),
69 array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'),
70 array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'),
71 array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'),
72 array(null, null, 'yyyy-MM-dd', '2010-02-03', '2010-02-03 00:00:00 UTC'),
73 array(null, null, 'yyyy-MM', '2010-02', '2010-02-01 00:00:00 UTC'),
74 array(null, null, 'yyyy', '2010', '2010-01-01 00:00:00 UTC'),
75 array(null, null, 'dd-MM-yyyy', '03-02-2010', '2010-02-03 00:00:00 UTC'),
76 array(null, null, 'HH:mm:ss', '04:05:06', '1970-01-01 04:05:06 UTC'),
77 array(null, null, 'HH:mm:00', '04:05:00', '1970-01-01 04:05:00 UTC'),
78 array(null, null, 'HH:mm', '04:05', '1970-01-01 04:05:00 UTC'),
79 array(null, null, 'HH', '04', '1970-01-01 04:00:00 UTC'),
80 );
81 }
82
83 /**
84 * @dataProvider dataProvider
85 */
86 public function testTransform($dateFormat, $timeFormat, $pattern, $output, $input)
87 {
88 $transformer = new DateTimeToLocalizedStringTransformer(
89 'UTC',
90 'UTC',
91 $dateFormat,
92 $timeFormat,
93 \IntlDateFormatter::GREGORIAN,
94 $pattern
95 );
96
97 $input = new \DateTime($input);
98
99 $this->assertEquals($output, $transformer->transform($input));
100 }
101
102 public function testTransformFullTime()
103 {
104 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);
105
106 $this->assertEquals('03.02.2010 04:05:06 GMT', $transformer->transform($this->dateTime));
107 }
108
109 public function testTransformToDifferentLocale()
110 {
111 \Locale::setDefault('en_US');
112
113 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
114
115 $this->assertEquals('Feb 3, 2010, 4:05 AM', $transformer->transform($this->dateTime));
116 }
117
118 public function testTransformEmpty()
119 {
120 $transformer = new DateTimeToLocalizedStringTransformer();
121
122 $this->assertSame('', $transformer->transform(null));
123 }
124
125 public function testTransformWithDifferentTimezones()
126 {
127 $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
128
129 $input = new \DateTime('2010-02-03 04:05:06 America/New_York');
130
131 $dateTime = clone $input;
132 $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
133
134 $this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input));
135 }
136
137 public function testTransformWithDifferentPatterns()
138 {
139 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
140
141 $this->assertEquals('02*2010*03 04|05|06', $transformer->transform($this->dateTime));
142 }
143
144 /**
145 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
146 */
147 public function testTransformRequiresValidDateTime()
148 {
149 $transformer = new DateTimeToLocalizedStringTransformer();
150 $transformer->transform('2010-01-01');
151 }
152
153 public function testTransformWrapsIntlErrors()
154 {
155 $transformer = new DateTimeToLocalizedStringTransformer();
156
157 // HOW TO REPRODUCE?
158
159 //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException');
160
161 //$transformer->transform(1.5);
162 }
163
164 /**
165 * @dataProvider dataProvider
166 */
167 public function testReverseTransform($dateFormat, $timeFormat, $pattern, $input, $output)
168 {
169 $transformer = new DateTimeToLocalizedStringTransformer(
170 'UTC',
171 'UTC',
172 $dateFormat,
173 $timeFormat,
174 \IntlDateFormatter::GREGORIAN,
175 $pattern
176 );
177
178 $output = new \DateTime($output);
179
180 $this->assertEquals($output, $transformer->reverseTransform($input));
181 }
182
183 public function testReverseTransformFullTime()
184 {
185 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);
186
187 $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010 04:05:06 GMT+00:00'));
188 }
189
190 public function testReverseTransformFromDifferentLocale()
191 {
192 \Locale::setDefault('en_US');
193
194 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
195
196 $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
197 }
198
199 public function testReverseTransformWithDifferentTimezones()
200 {
201 $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong');
202
203 $dateTime = new \DateTime('2010-02-03 04:05:00 Asia/Hong_Kong');
204 $dateTime->setTimezone(new \DateTimeZone('America/New_York'));
205
206 $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010 04:05'));
207 }
208
209 public function testReverseTransformWithDifferentPatterns()
210 {
211 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss');
212
213 $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06'));
214 }
215
216 public function testReverseTransformEmpty()
217 {
218 $transformer = new DateTimeToLocalizedStringTransformer();
219
220 $this->assertNull($transformer->reverseTransform(''));
221 }
222
223 /**
224 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
225 */
226 public function testReverseTransformRequiresString()
227 {
228 $transformer = new DateTimeToLocalizedStringTransformer();
229 $transformer->reverseTransform(12345);
230 }
231
232 /**
233 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
234 */
235 public function testReverseTransformWrapsIntlErrors()
236 {
237 $transformer = new DateTimeToLocalizedStringTransformer();
238 $transformer->reverseTransform('12345');
239 }
240
241 /**
242 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
243 */
244 public function testValidateDateFormatOption()
245 {
246 new DateTimeToLocalizedStringTransformer(null, null, 'foobar');
247 }
248
249 /**
250 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
251 */
252 public function testValidateTimeFormatOption()
253 {
254 new DateTimeToLocalizedStringTransformer(null, null, null, 'foobar');
255 }
256
257 /**
258 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
259 */
260 public function testReverseTransformWithNonExistingDate()
261 {
262 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT);
263
264 $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
265 }
266
267 /**
268 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
269 */
270 public function testReverseTransformOutOfTimestampRange()
271 {
272 $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
273 $transformer->reverseTransform('1789-07-14');
274 }
275}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
deleted file mode 100644
index 98aeb772..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer;
15
16class DateTimeToRfc3339TransformerTest extends DateTimeTestCase
17{
18 protected $dateTime;
19 protected $dateTimeWithoutSeconds;
20
21 protected function setUp()
22 {
23 parent::setUp();
24
25 $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
26 $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC');
27 }
28
29 protected function tearDown()
30 {
31 $this->dateTime = null;
32 $this->dateTimeWithoutSeconds = null;
33 }
34
35 public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
36 {
37 if ($expected instanceof \DateTime && $actual instanceof \DateTime) {
38 $expected = $expected->format('c');
39 $actual = $actual->format('c');
40 }
41
42 parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase);
43 }
44
45 public function allProvider()
46 {
47 return array(
48 array('UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06Z'),
49 array('UTC', 'UTC', null, ''),
50 array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:06 America/New_York', '2010-02-03T17:05:06+08:00'),
51 array('America/New_York', 'Asia/Hong_Kong', null, ''),
52 array('UTC', 'Asia/Hong_Kong', '2010-02-03 04:05:06 UTC', '2010-02-03T12:05:06+08:00'),
53 array('America/New_York', 'UTC', '2010-02-03 04:05:06 America/New_York', '2010-02-03T09:05:06Z'),
54 );
55 }
56
57 public function transformProvider()
58 {
59 return $this->allProvider();
60 }
61
62 public function reverseTransformProvider()
63 {
64 return array_merge($this->allProvider(), array(
65 // format without seconds, as appears in some browsers
66 array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'),
67 array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'),
68 ));
69 }
70
71 /**
72 * @dataProvider transformProvider
73 */
74 public function testTransform($fromTz, $toTz, $from, $to)
75 {
76 $transformer = new DateTimeToRfc3339Transformer($fromTz, $toTz);
77
78 $this->assertSame($to, $transformer->transform(null !== $from ? new \DateTime($from) : null));
79 }
80
81 /**
82 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
83 */
84 public function testTransformRequiresValidDateTime()
85 {
86 $transformer = new DateTimeToRfc3339Transformer();
87 $transformer->transform('2010-01-01');
88 }
89
90 /**
91 * @dataProvider reverseTransformProvider
92 */
93 public function testReverseTransform($toTz, $fromTz, $to, $from)
94 {
95 $transformer = new DateTimeToRfc3339Transformer($toTz, $fromTz);
96
97 if (null !== $to) {
98 $this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from));
99 } else {
100 $this->assertSame($to, $transformer->reverseTransform($from));
101 }
102 }
103
104 /**
105 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
106 */
107 public function testReverseTransformRequiresString()
108 {
109 $transformer = new DateTimeToRfc3339Transformer();
110 $transformer->reverseTransform(12345);
111 }
112
113 /**
114 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
115 */
116 public function testReverseTransformWithNonExistingDate()
117 {
118 $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC');
119
120 $transformer->reverseTransform('2010-04-31T04:05Z');
121 }
122
123 /**
124 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
125 */
126 public function testReverseTransformExpectsValidDateString()
127 {
128 $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC');
129
130 $transformer->reverseTransform('2010-2010-2010');
131 }
132}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php
deleted file mode 100644
index 987df1d8..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php
+++ /dev/null
@@ -1,181 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
15
16class DateTimeToStringTransformerTest extends DateTimeTestCase
17{
18 public function dataProvider()
19 {
20 $data = array(
21 array('Y-m-d H:i:s', '2010-02-03 16:05:06', '2010-02-03 16:05:06 UTC'),
22 array('Y-m-d H:i:00', '2010-02-03 16:05:00', '2010-02-03 16:05:00 UTC'),
23 array('Y-m-d H:i', '2010-02-03 16:05', '2010-02-03 16:05:00 UTC'),
24 array('Y-m-d H', '2010-02-03 16', '2010-02-03 16:00:00 UTC'),
25 array('Y-m-d', '2010-02-03', '2010-02-03 00:00:00 UTC'),
26 array('Y-m', '2010-12', '2010-12-01 00:00:00 UTC'),
27 array('Y', '2010', '2010-01-01 00:00:00 UTC'),
28 array('d-m-Y', '03-02-2010', '2010-02-03 00:00:00 UTC'),
29 array('H:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'),
30 array('H:i:00', '16:05:00', '1970-01-01 16:05:00 UTC'),
31 array('H:i', '16:05', '1970-01-01 16:05:00 UTC'),
32 array('H', '16', '1970-01-01 16:00:00 UTC'),
33
34 // different day representations
35 array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'),
36 array('z', '33', '1970-02-03 00:00:00 UTC'),
37
38 // not bijective
39 // this will not work as php will use actual date to replace missing info
40 // and after change of date will lookup for closest Wednesday
41 // i.e. value: 2010-02, php value: 2010-02-(today i.e. 20), parsed date: 2010-02-24
42 //array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'),
43 //array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'),
44
45 // different month representations
46 array('Y-n-d', '2010-2-03', '2010-02-03 00:00:00 UTC'),
47 array('Y-M-d', '2010-Feb-03', '2010-02-03 00:00:00 UTC'),
48 array('Y-F-d', '2010-February-03', '2010-02-03 00:00:00 UTC'),
49
50 // different year representations
51 array('y-m-d', '10-02-03', '2010-02-03 00:00:00 UTC'),
52
53 // different time representations
54 array('G:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'),
55 array('g:i:s a', '4:05:06 pm', '1970-01-01 16:05:06 UTC'),
56 array('h:i:s a', '04:05:06 pm', '1970-01-01 16:05:06 UTC'),
57
58 // seconds since unix
59 array('U', '1265213106', '2010-02-03 16:05:06 UTC'),
60 );
61
62 // This test will fail < 5.3.9 - see https://bugs.php.net/51994
63 if (version_compare(phpversion(), '5.3.9', '>=')) {
64 $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC');
65 }
66
67 return $data;
68 }
69
70 /**
71 * @dataProvider dataProvider
72 */
73 public function testTransform($format, $output, $input)
74 {
75 $transformer = new DateTimeToStringTransformer('UTC', 'UTC', $format);
76
77 $input = new \DateTime($input);
78
79 $this->assertEquals($output, $transformer->transform($input));
80 }
81
82 public function testTransformEmpty()
83 {
84 $transformer = new DateTimeToStringTransformer();
85
86 $this->assertSame('', $transformer->transform(null));
87 }
88
89 public function testTransformWithDifferentTimezones()
90 {
91 $transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s');
92
93 $input = new \DateTime('2010-02-03 12:05:06 America/New_York');
94 $output = $input->format('Y-m-d H:i:s');
95 $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
96
97 $this->assertEquals($output, $transformer->transform($input));
98 }
99
100 public function testTransformExpectsDateTime()
101 {
102 $transformer = new DateTimeToStringTransformer();
103
104 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
105
106 $transformer->transform('1234');
107 }
108
109 /**
110 * @dataProvider dataProvider
111 */
112 public function testReverseTransformUsingPipe($format, $input, $output)
113 {
114 if (version_compare(phpversion(), '5.3.7', '<')) {
115 $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.');
116 }
117
118 $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true);
119
120 $output = new \DateTime($output);
121
122 $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
123 }
124
125 /**
126 * @dataProvider dataProvider
127 */
128 public function testReverseTransformWithoutUsingPipe($format, $input, $output)
129 {
130 $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, false);
131
132 $output = new \DateTime($output);
133
134 $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
135 }
136
137 public function testReverseTransformEmpty()
138 {
139 $reverseTransformer = new DateTimeToStringTransformer();
140
141 $this->assertNull($reverseTransformer->reverseTransform(''));
142 }
143
144 public function testReverseTransformWithDifferentTimezones()
145 {
146 $reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s');
147
148 $output = new \DateTime('2010-02-03 16:05:06 Asia/Hong_Kong');
149 $input = $output->format('Y-m-d H:i:s');
150 $output->setTimeZone(new \DateTimeZone('America/New_York'));
151
152 $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
153 }
154
155 public function testReverseTransformExpectsString()
156 {
157 $reverseTransformer = new DateTimeToStringTransformer();
158
159 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
160
161 $reverseTransformer->reverseTransform(1234);
162 }
163
164 public function testReverseTransformExpectsValidDateString()
165 {
166 $reverseTransformer = new DateTimeToStringTransformer();
167
168 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
169
170 $reverseTransformer->reverseTransform('2010-2010-2010');
171 }
172
173 public function testReverseTransformWithNonExistingDate()
174 {
175 $reverseTransformer = new DateTimeToStringTransformer();
176
177 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
178
179 $reverseTransformer->reverseTransform('2010-04-31');
180 }
181}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php
deleted file mode 100644
index b54f0c4c..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php
+++ /dev/null
@@ -1,104 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
15
16class DateTimeToTimestampTransformerTest extends DateTimeTestCase
17{
18 public function testTransform()
19 {
20 $transformer = new DateTimeToTimestampTransformer('UTC', 'UTC');
21
22 $input = new \DateTime('2010-02-03 04:05:06 UTC');
23 $output = $input->format('U');
24
25 $this->assertEquals($output, $transformer->transform($input));
26 }
27
28 public function testTransformEmpty()
29 {
30 $transformer = new DateTimeToTimestampTransformer();
31
32 $this->assertNull($transformer->transform(null));
33 }
34
35 public function testTransformWithDifferentTimezones()
36 {
37 $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
38
39 $input = new \DateTime('2010-02-03 04:05:06 America/New_York');
40 $output = $input->format('U');
41 $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
42
43 $this->assertEquals($output, $transformer->transform($input));
44 }
45
46 public function testTransformFromDifferentTimezone()
47 {
48 $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'UTC');
49
50 $input = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong');
51
52 $dateTime = clone $input;
53 $dateTime->setTimezone(new \DateTimeZone('UTC'));
54 $output = $dateTime->format('U');
55
56 $this->assertEquals($output, $transformer->transform($input));
57 }
58
59 public function testTransformExpectsDateTime()
60 {
61 $transformer = new DateTimeToTimestampTransformer();
62
63 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
64
65 $transformer->transform('1234');
66 }
67
68 public function testReverseTransform()
69 {
70 $reverseTransformer = new DateTimeToTimestampTransformer('UTC', 'UTC');
71
72 $output = new \DateTime('2010-02-03 04:05:06 UTC');
73 $input = $output->format('U');
74
75 $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
76 }
77
78 public function testReverseTransformEmpty()
79 {
80 $reverseTransformer = new DateTimeToTimestampTransformer();
81
82 $this->assertNull($reverseTransformer->reverseTransform(null));
83 }
84
85 public function testReverseTransformWithDifferentTimezones()
86 {
87 $reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York');
88
89 $output = new \DateTime('2010-02-03 04:05:06 America/New_York');
90 $input = $output->format('U');
91 $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
92
93 $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input));
94 }
95
96 public function testReverseTransformExpectsValidTimestamp()
97 {
98 $reverseTransformer = new DateTimeToTimestampTransformer();
99
100 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
101
102 $reverseTransformer->reverseTransform('2010-2010-2010');
103 }
104}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
deleted file mode 100644
index a90fa91b..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 parent::setUp();
22
23 // Since we test against "de_AT", we need the full implementation
24 IntlTestHelper::requireFullIntl($this);
25
26 \Locale::setDefault('de_AT');
27 }
28
29 public function testReverseTransform()
30 {
31 $transformer = new IntegerToLocalizedStringTransformer();
32
33 $this->assertEquals(1, $transformer->reverseTransform('1'));
34 $this->assertEquals(1, $transformer->reverseTransform('1,5'));
35 $this->assertEquals(1234, $transformer->reverseTransform('1234,5'));
36 $this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
37 }
38
39 public function testReverseTransformEmpty()
40 {
41 $transformer = new IntegerToLocalizedStringTransformer();
42
43 $this->assertNull($transformer->reverseTransform(''));
44 }
45
46 public function testReverseTransformWithGrouping()
47 {
48 $transformer = new IntegerToLocalizedStringTransformer(null, true);
49
50 $this->assertEquals(1234, $transformer->reverseTransform('1.234,5'));
51 $this->assertEquals(12345, $transformer->reverseTransform('12.345,912'));
52 $this->assertEquals(1234, $transformer->reverseTransform('1234,5'));
53 $this->assertEquals(12345, $transformer->reverseTransform('12345,912'));
54 }
55
56 /**
57 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
58 */
59 public function testReverseTransformExpectsString()
60 {
61 $transformer = new IntegerToLocalizedStringTransformer();
62
63 $transformer->reverseTransform(1);
64 }
65
66 /**
67 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
68 */
69 public function testReverseTransformExpectsValidNumber()
70 {
71 $transformer = new IntegerToLocalizedStringTransformer();
72
73 $transformer->reverseTransform('foo');
74 }
75
76 /**
77 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
78 */
79 public function testReverseTransformDisallowsNaN()
80 {
81 $transformer = new IntegerToLocalizedStringTransformer();
82
83 $transformer->reverseTransform('NaN');
84 }
85
86 /**
87 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
88 */
89 public function testReverseTransformDisallowsNaN2()
90 {
91 $transformer = new IntegerToLocalizedStringTransformer();
92
93 $transformer->reverseTransform('nan');
94 }
95
96 /**
97 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
98 */
99 public function testReverseTransformDisallowsInfinity()
100 {
101 $transformer = new IntegerToLocalizedStringTransformer();
102
103 $transformer->reverseTransform('∞');
104 }
105
106 /**
107 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
108 */
109 public function testReverseTransformDisallowsNegativeInfinity()
110 {
111 $transformer = new IntegerToLocalizedStringTransformer();
112
113 $transformer->reverseTransform('-∞');
114 }
115}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php
deleted file mode 100644
index 8b91fe10..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 parent::setUp();
22
23 // Since we test against "de_AT", we need the full implementation
24 IntlTestHelper::requireFullIntl($this);
25
26 \Locale::setDefault('de_AT');
27 }
28
29 public function testTransform()
30 {
31 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
32
33 $this->assertEquals('1,23', $transformer->transform(123));
34 }
35
36 public function testTransformExpectsNumeric()
37 {
38 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
39
40 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
41
42 $transformer->transform('abcd');
43 }
44
45 public function testTransformEmpty()
46 {
47 $transformer = new MoneyToLocalizedStringTransformer();
48
49 $this->assertSame('', $transformer->transform(null));
50 }
51
52 public function testReverseTransform()
53 {
54 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
55
56 $this->assertEquals(123, $transformer->reverseTransform('1,23'));
57 }
58
59 public function testReverseTransformExpectsString()
60 {
61 $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100);
62
63 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
64
65 $transformer->reverseTransform(12345);
66 }
67
68 public function testReverseTransformEmpty()
69 {
70 $transformer = new MoneyToLocalizedStringTransformer();
71
72 $this->assertNull($transformer->reverseTransform(''));
73 }
74}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
deleted file mode 100644
index c58e3f60..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
+++ /dev/null
@@ -1,393 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 parent::setUp();
22
23 // Since we test against "de_AT", we need the full implementation
24 IntlTestHelper::requireFullIntl($this);
25
26 \Locale::setDefault('de_AT');
27 }
28
29 public function provideTransformations()
30 {
31 return array(
32 array(null, '', 'de_AT'),
33 array(1, '1', 'de_AT'),
34 array(1.5, '1,5', 'de_AT'),
35 array(1234.5, '1234,5', 'de_AT'),
36 array(12345.912, '12345,912', 'de_AT'),
37 array(1234.5, '1234,5', 'ru'),
38 array(1234.5, '1234,5', 'fi'),
39 );
40 }
41
42 /**
43 * @dataProvider provideTransformations
44 */
45 public function testTransform($from, $to, $locale)
46 {
47 \Locale::setDefault($locale);
48
49 $transformer = new NumberToLocalizedStringTransformer();
50
51 $this->assertSame($to, $transformer->transform($from));
52 }
53
54 public function provideTransformationsWithGrouping()
55 {
56 return array(
57 array(1234.5, '1.234,5', 'de_AT'),
58 array(12345.912, '12.345,912', 'de_AT'),
59 array(1234.5, '1 234,5', 'fr'),
60 array(1234.5, '1 234,5', 'ru'),
61 array(1234.5, '1 234,5', 'fi'),
62 );
63 }
64
65 /**
66 * @dataProvider provideTransformationsWithGrouping
67 */
68 public function testTransformWithGrouping($from, $to, $locale)
69 {
70 \Locale::setDefault($locale);
71
72 $transformer = new NumberToLocalizedStringTransformer(null, true);
73
74 $this->assertSame($to, $transformer->transform($from));
75 }
76
77 public function testTransformWithPrecision()
78 {
79 $transformer = new NumberToLocalizedStringTransformer(2);
80
81 $this->assertEquals('1234,50', $transformer->transform(1234.5));
82 $this->assertEquals('678,92', $transformer->transform(678.916));
83 }
84
85 public function testTransformWithRoundingMode()
86 {
87 $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN);
88 $this->assertEquals('1234,547', $transformer->transform(1234.547), '->transform() only applies rounding mode if precision set');
89
90 $transformer = new NumberToLocalizedStringTransformer(2, null, NumberToLocalizedStringTransformer::ROUND_DOWN);
91 $this->assertEquals('1234,54', $transformer->transform(1234.547), '->transform() rounding-mode works');
92
93 }
94
95 /**
96 * @dataProvider provideTransformations
97 */
98 public function testReverseTransform($to, $from, $locale)
99 {
100 \Locale::setDefault($locale);
101
102 $transformer = new NumberToLocalizedStringTransformer();
103
104 $this->assertEquals($to, $transformer->reverseTransform($from));
105 }
106
107 /**
108 * @dataProvider provideTransformationsWithGrouping
109 */
110 public function testReverseTransformWithGrouping($to, $from, $locale)
111 {
112 \Locale::setDefault($locale);
113
114 $transformer = new NumberToLocalizedStringTransformer(null, true);
115
116 $this->assertEquals($to, $transformer->reverseTransform($from));
117 }
118
119 // https://github.com/symfony/symfony/issues/7609
120 public function testReverseTransformWithGroupingAndFixedSpaces()
121 {
122 if (!extension_loaded('mbstring')) {
123 $this->markTestSkipped('The "mbstring" extension is required for this test.');
124 }
125
126 \Locale::setDefault('ru');
127
128 $transformer = new NumberToLocalizedStringTransformer(null, true);
129
130 $this->assertEquals(1234.5, $transformer->reverseTransform("1\xc2\xa0234,5"));
131 }
132
133 public function testReverseTransformWithGroupingButWithoutGroupSeparator()
134 {
135 $transformer = new NumberToLocalizedStringTransformer(null, true);
136
137 // omit group separator
138 $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
139 $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912'));
140 }
141
142 public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
143 {
144 \Locale::setDefault('fr');
145 $transformer = new NumberToLocalizedStringTransformer(null, true);
146
147 // completely valid format
148 $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
149 // accept dots
150 $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
151 // omit group separator
152 $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
153 $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
154 }
155
156 /**
157 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
158 */
159 public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
160 {
161 $transformer = new NumberToLocalizedStringTransformer(null, true);
162
163 $transformer->reverseTransform('1.234.5');
164 }
165
166 /**
167 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
168 */
169 public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
170 {
171 $transformer = new NumberToLocalizedStringTransformer(null, true);
172
173 $transformer->reverseTransform('1234.5');
174 }
175
176 public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed()
177 {
178 \Locale::setDefault('fr');
179 $transformer = new NumberToLocalizedStringTransformer();
180
181 $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
182 $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
183 }
184
185 public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
186 {
187 \Locale::setDefault('bg');
188 $transformer = new NumberToLocalizedStringTransformer(null, true);
189
190 // completely valid format
191 $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5'));
192 // accept commas
193 $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5'));
194 // omit group separator
195 $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
196 $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
197 }
198
199 /**
200 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
201 */
202 public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
203 {
204 \Locale::setDefault('en');
205 $transformer = new NumberToLocalizedStringTransformer(null, true);
206
207 $transformer->reverseTransform('1,234,5');
208 }
209
210 /**
211 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
212 */
213 public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
214 {
215 \Locale::setDefault('en');
216 $transformer = new NumberToLocalizedStringTransformer(null, true);
217
218 $transformer->reverseTransform('1234,5');
219 }
220
221 public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed()
222 {
223 \Locale::setDefault('en');
224 $transformer = new NumberToLocalizedStringTransformer();
225
226 $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5'));
227 $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5'));
228 }
229
230 /**
231 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
232 */
233 public function testTransformExpectsNumeric()
234 {
235 $transformer = new NumberToLocalizedStringTransformer();
236
237 $transformer->transform('foo');
238 }
239
240 /**
241 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
242 */
243 public function testReverseTransformExpectsString()
244 {
245 $transformer = new NumberToLocalizedStringTransformer();
246
247 $transformer->reverseTransform(1);
248 }
249
250 /**
251 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
252 */
253 public function testReverseTransformExpectsValidNumber()
254 {
255 $transformer = new NumberToLocalizedStringTransformer();
256
257 $transformer->reverseTransform('foo');
258 }
259
260 /**
261 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
262 * @link https://github.com/symfony/symfony/issues/3161
263 */
264 public function testReverseTransformDisallowsNaN()
265 {
266 $transformer = new NumberToLocalizedStringTransformer();
267
268 $transformer->reverseTransform('NaN');
269 }
270
271 /**
272 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
273 */
274 public function testReverseTransformDisallowsNaN2()
275 {
276 $transformer = new NumberToLocalizedStringTransformer();
277
278 $transformer->reverseTransform('nan');
279 }
280
281 /**
282 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
283 */
284 public function testReverseTransformDisallowsInfinity()
285 {
286 $transformer = new NumberToLocalizedStringTransformer();
287
288 $transformer->reverseTransform('∞');
289 }
290
291 /**
292 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
293 */
294 public function testReverseTransformDisallowsInfinity2()
295 {
296 $transformer = new NumberToLocalizedStringTransformer();
297
298 $transformer->reverseTransform('∞,123');
299 }
300
301 /**
302 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
303 */
304 public function testReverseTransformDisallowsNegativeInfinity()
305 {
306 $transformer = new NumberToLocalizedStringTransformer();
307
308 $transformer->reverseTransform('-∞');
309 }
310
311 /**
312 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
313 */
314 public function testReverseTransformDisallowsLeadingExtraCharacters()
315 {
316 $transformer = new NumberToLocalizedStringTransformer();
317
318 $transformer->reverseTransform('foo123');
319 }
320
321 /**
322 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
323 * @expectedExceptionMessage The number contains unrecognized characters: "foo3"
324 */
325 public function testReverseTransformDisallowsCenteredExtraCharacters()
326 {
327 $transformer = new NumberToLocalizedStringTransformer();
328
329 $transformer->reverseTransform('12foo3');
330 }
331
332 /**
333 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
334 * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
335 */
336 public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
337 {
338 if (!extension_loaded('mbstring')) {
339 $this->markTestSkipped('The "mbstring" extension is required for this test.');
340 }
341
342 \Locale::setDefault('ru');
343
344 $transformer = new NumberToLocalizedStringTransformer(null, true);
345
346 $transformer->reverseTransform("12\xc2\xa0345,67foo8");
347 }
348
349 /**
350 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
351 * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
352 */
353 public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage()
354 {
355 if (!extension_loaded('mbstring')) {
356 $this->markTestSkipped('The "mbstring" extension is required for this test.');
357 }
358
359 \Locale::setDefault('ru');
360
361 $transformer = new NumberToLocalizedStringTransformer(null, true);
362
363 $transformer->reverseTransform("12\xc2\xa0345,67foo8 \xc2\xa0\t");
364 }
365
366 /**
367 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
368 * @expectedExceptionMessage The number contains unrecognized characters: "foo"
369 */
370 public function testReverseTransformDisallowsTrailingExtraCharacters()
371 {
372 $transformer = new NumberToLocalizedStringTransformer();
373
374 $transformer->reverseTransform('123foo');
375 }
376
377 /**
378 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
379 * @expectedExceptionMessage The number contains unrecognized characters: "foo"
380 */
381 public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
382 {
383 if (!extension_loaded('mbstring')) {
384 $this->markTestSkipped('The "mbstring" extension is required for this test.');
385 }
386
387 \Locale::setDefault('ru');
388
389 $transformer = new NumberToLocalizedStringTransformer(null, true);
390
391 $transformer->reverseTransform("12\xc2\xa0345,678foo");
392 }
393}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
deleted file mode 100644
index 104941c9..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
+++ /dev/null
@@ -1,114 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
15use Symfony\Component\Intl\Util\IntlTestHelper;
16
17class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 parent::setUp();
22
23 // Since we test against "de_AT", we need the full implementation
24 IntlTestHelper::requireFullIntl($this);
25
26 \Locale::setDefault('de_AT');
27 }
28
29 public function testTransform()
30 {
31 $transformer = new PercentToLocalizedStringTransformer();
32
33 $this->assertEquals('10', $transformer->transform(0.1));
34 $this->assertEquals('15', $transformer->transform(0.15));
35 $this->assertEquals('12', $transformer->transform(0.1234));
36 $this->assertEquals('200', $transformer->transform(2));
37 }
38
39 public function testTransformEmpty()
40 {
41 $transformer = new PercentToLocalizedStringTransformer();
42
43 $this->assertEquals('', $transformer->transform(null));
44 }
45
46 public function testTransformWithInteger()
47 {
48 $transformer = new PercentToLocalizedStringTransformer(null, 'integer');
49
50 $this->assertEquals('0', $transformer->transform(0.1));
51 $this->assertEquals('1', $transformer->transform(1));
52 $this->assertEquals('15', $transformer->transform(15));
53 $this->assertEquals('16', $transformer->transform(15.9));
54 }
55
56 public function testTransformWithPrecision()
57 {
58 $transformer = new PercentToLocalizedStringTransformer(2);
59
60 $this->assertEquals('12,34', $transformer->transform(0.1234));
61 }
62
63 public function testReverseTransform()
64 {
65 $transformer = new PercentToLocalizedStringTransformer();
66
67 $this->assertEquals(0.1, $transformer->reverseTransform('10'));
68 $this->assertEquals(0.15, $transformer->reverseTransform('15'));
69 $this->assertEquals(0.12, $transformer->reverseTransform('12'));
70 $this->assertEquals(2, $transformer->reverseTransform('200'));
71 }
72
73 public function testReverseTransformEmpty()
74 {
75 $transformer = new PercentToLocalizedStringTransformer();
76
77 $this->assertNull($transformer->reverseTransform(''));
78 }
79
80 public function testReverseTransformWithInteger()
81 {
82 $transformer = new PercentToLocalizedStringTransformer(null, 'integer');
83
84 $this->assertEquals(10, $transformer->reverseTransform('10'));
85 $this->assertEquals(15, $transformer->reverseTransform('15'));
86 $this->assertEquals(12, $transformer->reverseTransform('12'));
87 $this->assertEquals(200, $transformer->reverseTransform('200'));
88 }
89
90 public function testReverseTransformWithPrecision()
91 {
92 $transformer = new PercentToLocalizedStringTransformer(2);
93
94 $this->assertEquals(0.1234, $transformer->reverseTransform('12,34'));
95 }
96
97 public function testTransformExpectsNumeric()
98 {
99 $transformer = new PercentToLocalizedStringTransformer();
100
101 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
102
103 $transformer->transform('foo');
104 }
105
106 public function testReverseTransformExpectsString()
107 {
108 $transformer = new PercentToLocalizedStringTransformer();
109
110 $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');
111
112 $transformer->reverseTransform(1);
113 }
114}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php
deleted file mode 100644
index 2c5298da..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php
+++ /dev/null
@@ -1,120 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
13
14use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer;
15
16class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase
17{
18 private $transformer;
19
20 protected function setUp()
21 {
22 $this->transformer = new ValueToDuplicatesTransformer(array('a', 'b', 'c'));
23 }
24
25 protected function tearDown()
26 {
27 $this->transformer = null;
28 }
29
30 public function testTransform()
31 {
32 $output = array(
33 'a' => 'Foo',
34 'b' => 'Foo',
35 'c' => 'Foo',
36 );
37
38 $this->assertSame($output, $this->transformer->transform('Foo'));
39 }
40
41 public function testTransformEmpty()
42 {
43 $output = array(
44 'a' => null,
45 'b' => null,
46 'c' => null,
47 );
48
49 $this->assertSame($output, $this->transformer->transform(null));
50 }
51
52 public function testReverseTransform()
53 {
54 $input = array(
55 'a' => 'Foo',
56 'b' => 'Foo',
57 'c' => 'Foo',
58 );
59
60 $this->assertSame('Foo', $this->transformer->reverseTransform($input));
61 }
62
63 public function testReverseTransformCompletelyEmpty()
64 {
65 $input = array(
66 'a' => '',
67 'b' => '',
68 'c' => '',
69 );
70
71 $this->assertNull($this->transformer->reverseTransform($input));
72 }
73
74 public function testReverseTransformCompletelyNull()
75 {
76 $input = array(
77 'a' => null,
78 'b' => null,
79 'c' => null,
80 );
81
82 $this->assertNull($this->transformer->reverseTransform($input));
83 }
84
85 /**
86 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
87 */
88 public function testReverseTransformPartiallyNull()
89 {
90 $input = array(
91 'a' => 'Foo',
92 'b' => 'Foo',
93 'c' => null,
94 );
95
96 $this->transformer->reverseTransform($input);
97 }
98
99 /**
100 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
101 */
102 public function testReverseTransformDifferences()
103 {
104 $input = array(
105 'a' => 'Foo',
106 'b' => 'Bar',
107 'c' => 'Foo',
108 );
109
110 $this->transformer->reverseTransform($input);
111 }
112
113 /**
114 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
115 */
116 public function testReverseTransformRequiresArray()
117 {
118 $this->transformer->reverseTransform('12345');
119 }
120}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
deleted file mode 100644
index a5d5c78a..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormEvent;
15use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener;
16use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList;
17
18class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase
19{
20 private $choiceList;
21
22 protected function setUp()
23 {
24 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
25 $this->markTestSkipped('The "EventDispatcher" component is not available');
26 }
27
28 parent::setUp();
29
30 $this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B'));
31 }
32
33 protected function tearDown()
34 {
35 parent::tearDown();
36
37 $listener = null;
38 }
39
40 public function testFixRadio()
41 {
42 $data = '1';
43 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
44 $event = new FormEvent($form, $data);
45
46 $listener = new FixRadioInputListener($this->choiceList, true);
47 $listener->preSubmit($event);
48
49 // Indices in SimpleChoiceList are zero-based generated integers
50 $this->assertEquals(array(2 => '1'), $event->getData());
51 }
52
53 public function testFixZero()
54 {
55 $data = '0';
56 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
57 $event = new FormEvent($form, $data);
58
59 $listener = new FixRadioInputListener($this->choiceList, true);
60 $listener->preSubmit($event);
61
62 // Indices in SimpleChoiceList are zero-based generated integers
63 $this->assertEquals(array(1 => '0'), $event->getData());
64 }
65
66 public function testFixEmptyString()
67 {
68 $data = '';
69 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
70 $event = new FormEvent($form, $data);
71
72 $listener = new FixRadioInputListener($this->choiceList, true);
73 $listener->preSubmit($event);
74
75 // Indices in SimpleChoiceList are zero-based generated integers
76 $this->assertEquals(array(0 => ''), $event->getData());
77 }
78
79 public function testConvertEmptyStringToPlaceholderIfNotFound()
80 {
81 $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));
82
83 $data = '';
84 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
85 $event = new FormEvent($form, $data);
86
87 $listener = new FixRadioInputListener($list, true);
88 $listener->preSubmit($event);
89
90 $this->assertEquals(array('placeholder' => ''), $event->getData());
91 }
92
93 public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed()
94 {
95 $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B'));
96
97 $data = '';
98 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
99 $event = new FormEvent($form, $data);
100
101 $listener = new FixRadioInputListener($list, false);
102 $listener->preSubmit($event);
103
104 $this->assertEquals(array(), $event->getData());
105 }
106}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
deleted file mode 100644
index 2b84e4fd..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormEvent;
15use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener;
16
17class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
22 $this->markTestSkipped('The "EventDispatcher" component is not available');
23 }
24 }
25
26 public function testFixHttpUrl()
27 {
28 $data = "www.symfony.com";
29 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
30 $event = new FormEvent($form, $data);
31
32 $filter = new FixUrlProtocolListener('http');
33 $filter->onSubmit($event);
34
35 $this->assertEquals('http://www.symfony.com', $event->getData());
36 }
37
38 public function testSkipKnownUrl()
39 {
40 $data = "http://www.symfony.com";
41 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
42 $event = new FormEvent($form, $data);
43
44 $filter = new FixUrlProtocolListener('http');
45 $filter->onSubmit($event);
46
47 $this->assertEquals('http://www.symfony.com', $event->getData());
48 }
49
50 public function testSkipOtherProtocol()
51 {
52 $data = "ftp://www.symfony.com";
53 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
54 $event = new FormEvent($form, $data);
55
56 $filter = new FixUrlProtocolListener('http');
57 $filter->onSubmit($event);
58
59 $this->assertEquals('ftp://www.symfony.com', $event->getData());
60 }
61}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash
deleted file mode 100644
index b636f4b8..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash
+++ /dev/null
Binary files differ
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php
deleted file mode 100644
index 6f46c9d7..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php
+++ /dev/null
@@ -1,27 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormBuilder;
15
16class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest
17{
18 protected function getData(array $data)
19 {
20 return new \ArrayObject($data);
21 }
22
23 protected function getBuilder($name = 'name')
24 {
25 return new FormBuilder($name, '\ArrayObject', $this->dispatcher, $this->factory);
26 }
27}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php
deleted file mode 100644
index c0f3d597..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php
+++ /dev/null
@@ -1,27 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormBuilder;
15
16class MergeCollectionListenerArrayTest extends MergeCollectionListenerTest
17{
18 protected function getData(array $data)
19 {
20 return $data;
21 }
22
23 protected function getBuilder($name = 'name')
24 {
25 return new FormBuilder($name, null, $this->dispatcher, $this->factory);
26 }
27}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php
deleted file mode 100644
index 5eb6c7b9..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\Tests\Fixtures\CustomArrayObject;
15use Symfony\Component\Form\FormBuilder;
16
17class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTest
18{
19 protected function getData(array $data)
20 {
21 return new CustomArrayObject($data);
22 }
23
24 protected function getBuilder($name = 'name')
25 {
26 return new FormBuilder($name, 'Symfony\Component\Form\Tests\Fixtures\CustomArrayObject', $this->dispatcher, $this->factory);
27 }
28}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
deleted file mode 100644
index dbd28c6b..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php
+++ /dev/null
@@ -1,259 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormEvent;
15use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener;
16
17abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase
18{
19 protected $dispatcher;
20 protected $factory;
21 protected $form;
22
23 protected function setUp()
24 {
25 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
26 $this->markTestSkipped('The "EventDispatcher" component is not available');
27 }
28
29 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
30 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
31 $this->form = $this->getForm('axes');
32 }
33
34 protected function tearDown()
35 {
36 $this->dispatcher = null;
37 $this->factory = null;
38 $this->form = null;
39 }
40
41 abstract protected function getBuilder($name = 'name');
42
43 protected function getForm($name = 'name', $propertyPath = null)
44 {
45 $propertyPath = $propertyPath ?: $name;
46
47 return $this->getBuilder($name)->setAttribute('property_path', $propertyPath)->getForm();
48 }
49
50 protected function getMockForm()
51 {
52 return $this->getMock('Symfony\Component\Form\Test\FormInterface');
53 }
54
55 public function getBooleanMatrix1()
56 {
57 return array(
58 array(true),
59 array(false),
60 );
61 }
62
63 public function getBooleanMatrix2()
64 {
65 return array(
66 array(true, true),
67 array(true, false),
68 array(false, true),
69 array(false, false),
70 );
71 }
72
73 abstract protected function getData(array $data);
74
75 /**
76 * @dataProvider getBooleanMatrix1
77 */
78 public function testAddExtraEntriesIfAllowAdd($allowDelete)
79 {
80 $originalData = $this->getData(array(1 => 'second'));
81 $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
82
83 $listener = new MergeCollectionListener(true, $allowDelete);
84
85 $this->form->setData($originalData);
86
87 $event = new FormEvent($this->form, $newData);
88 $listener->onSubmit($event);
89
90 // The original object was modified
91 if (is_object($originalData)) {
92 $this->assertSame($originalData, $event->getData());
93 }
94
95 // The original object matches the new object
96 $this->assertEquals($newData, $event->getData());
97 }
98
99 /**
100 * @dataProvider getBooleanMatrix1
101 */
102 public function testAddExtraEntriesIfAllowAddDontOverwriteExistingIndices($allowDelete)
103 {
104 $originalData = $this->getData(array(1 => 'first'));
105 $newData = $this->getData(array(0 => 'first', 1 => 'second'));
106
107 $listener = new MergeCollectionListener(true, $allowDelete);
108
109 $this->form->setData($originalData);
110
111 $event = new FormEvent($this->form, $newData);
112 $listener->onSubmit($event);
113
114 // The original object was modified
115 if (is_object($originalData)) {
116 $this->assertSame($originalData, $event->getData());
117 }
118
119 // The original object matches the new object
120 $this->assertEquals($this->getData(array(1 => 'first', 2 => 'second')), $event->getData());
121 }
122
123 /**
124 * @dataProvider getBooleanMatrix1
125 */
126 public function testDoNothingIfNotAllowAdd($allowDelete)
127 {
128 $originalDataArray = array(1 => 'second');
129 $originalData = $this->getData($originalDataArray);
130 $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
131
132 $listener = new MergeCollectionListener(false, $allowDelete);
133
134 $this->form->setData($originalData);
135
136 $event = new FormEvent($this->form, $newData);
137 $listener->onSubmit($event);
138
139 // We still have the original object
140 if (is_object($originalData)) {
141 $this->assertSame($originalData, $event->getData());
142 }
143
144 // Nothing was removed
145 $this->assertEquals($this->getData($originalDataArray), $event->getData());
146 }
147
148 /**
149 * @dataProvider getBooleanMatrix1
150 */
151 public function testRemoveMissingEntriesIfAllowDelete($allowAdd)
152 {
153 $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
154 $newData = $this->getData(array(1 => 'second'));
155
156 $listener = new MergeCollectionListener($allowAdd, true);
157
158 $this->form->setData($originalData);
159
160 $event = new FormEvent($this->form, $newData);
161 $listener->onSubmit($event);
162
163 // The original object was modified
164 if (is_object($originalData)) {
165 $this->assertSame($originalData, $event->getData());
166 }
167
168 // The original object matches the new object
169 $this->assertEquals($newData, $event->getData());
170 }
171
172 /**
173 * @dataProvider getBooleanMatrix1
174 */
175 public function testDoNothingIfNotAllowDelete($allowAdd)
176 {
177 $originalDataArray = array(0 => 'first', 1 => 'second', 2 => 'third');
178 $originalData = $this->getData($originalDataArray);
179 $newData = $this->getData(array(1 => 'second'));
180
181 $listener = new MergeCollectionListener($allowAdd, false);
182
183 $this->form->setData($originalData);
184
185 $event = new FormEvent($this->form, $newData);
186 $listener->onSubmit($event);
187
188 // We still have the original object
189 if (is_object($originalData)) {
190 $this->assertSame($originalData, $event->getData());
191 }
192
193 // Nothing was removed
194 $this->assertEquals($this->getData($originalDataArray), $event->getData());
195 }
196
197 /**
198 * @dataProvider getBooleanMatrix2
199 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
200 */
201 public function testRequireArrayOrTraversable($allowAdd, $allowDelete)
202 {
203 $newData = 'no array or traversable';
204 $event = new FormEvent($this->form, $newData);
205 $listener = new MergeCollectionListener($allowAdd, $allowDelete);
206 $listener->onSubmit($event);
207 }
208
209 public function testDealWithNullData()
210 {
211 $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
212 $newData = null;
213
214 $listener = new MergeCollectionListener(false, false);
215
216 $this->form->setData($originalData);
217
218 $event = new FormEvent($this->form, $newData);
219 $listener->onSubmit($event);
220
221 $this->assertSame($originalData, $event->getData());
222 }
223
224 /**
225 * @dataProvider getBooleanMatrix1
226 */
227 public function testDealWithNullOriginalDataIfAllowAdd($allowDelete)
228 {
229 $originalData = null;
230 $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
231
232 $listener = new MergeCollectionListener(true, $allowDelete);
233
234 $this->form->setData($originalData);
235
236 $event = new FormEvent($this->form, $newData);
237 $listener->onSubmit($event);
238
239 $this->assertSame($newData, $event->getData());
240 }
241
242 /**
243 * @dataProvider getBooleanMatrix1
244 */
245 public function testDontDealWithNullOriginalDataIfNotAllowAdd($allowDelete)
246 {
247 $originalData = null;
248 $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third'));
249
250 $listener = new MergeCollectionListener(false, $allowDelete);
251
252 $this->form->setData($originalData);
253
254 $event = new FormEvent($this->form, $newData);
255 $listener->onSubmit($event);
256
257 $this->assertNull($event->getData());
258 }
259}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
deleted file mode 100644
index 1367b3ef..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
+++ /dev/null
@@ -1,255 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener;
15use Symfony\Component\Form\FormBuilder;
16use Symfony\Component\Form\FormEvent;
17
18class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
19{
20 private $dispatcher;
21 private $factory;
22 private $form;
23
24 protected function setUp()
25 {
26 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
27 $this->markTestSkipped('The "EventDispatcher" component is not available');
28 }
29
30 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
31 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
32 $this->form = $this->getBuilder()
33 ->setCompound(true)
34 ->setDataMapper($this->getDataMapper())
35 ->getForm();
36 }
37
38 protected function tearDown()
39 {
40 $this->dispatcher = null;
41 $this->factory = null;
42 $this->form = null;
43 }
44
45 protected function getBuilder($name = 'name')
46 {
47 return new FormBuilder($name, null, $this->dispatcher, $this->factory);
48 }
49
50 protected function getForm($name = 'name')
51 {
52 return $this->getBuilder($name)->getForm();
53 }
54
55 /**
56 * @return \PHPUnit_Framework_MockObject_MockObject
57 */
58 private function getDataMapper()
59 {
60 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
61 }
62
63 protected function getMockForm()
64 {
65 return $this->getMock('Symfony\Component\Form\Test\FormInterface');
66 }
67
68 public function testPreSetDataResizesForm()
69 {
70 $this->form->add($this->getForm('0'));
71 $this->form->add($this->getForm('1'));
72
73 $this->factory->expects($this->at(0))
74 ->method('createNamed')
75 ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10, 'auto_initialize' => false))
76 ->will($this->returnValue($this->getForm('1')));
77 $this->factory->expects($this->at(1))
78 ->method('createNamed')
79 ->with(2, 'text', null, array('property_path' => '[2]', 'max_length' => 10, 'auto_initialize' => false))
80 ->will($this->returnValue($this->getForm('2')));
81
82 $data = array(1 => 'string', 2 => 'string');
83 $event = new FormEvent($this->form, $data);
84 $listener = new ResizeFormListener('text', array('max_length' => '10'), false, false);
85 $listener->preSetData($event);
86
87 $this->assertFalse($this->form->has('0'));
88 $this->assertTrue($this->form->has('1'));
89 $this->assertTrue($this->form->has('2'));
90 }
91
92 /**
93 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
94 */
95 public function testPreSetDataRequiresArrayOrTraversable()
96 {
97 $data = 'no array or traversable';
98 $event = new FormEvent($this->form, $data);
99 $listener = new ResizeFormListener('text', array(), false, false);
100 $listener->preSetData($event);
101 }
102
103 public function testPreSetDataDealsWithNullData()
104 {
105 $this->factory->expects($this->never())->method('createNamed');
106
107 $data = null;
108 $event = new FormEvent($this->form, $data);
109 $listener = new ResizeFormListener('text', array(), false, false);
110 $listener->preSetData($event);
111 }
112
113 public function testPreSubmitResizesUpIfAllowAdd()
114 {
115 $this->form->add($this->getForm('0'));
116
117 $this->factory->expects($this->once())
118 ->method('createNamed')
119 ->with(1, 'text', null, array('property_path' => '[1]', 'max_length' => 10, 'auto_initialize' => false))
120 ->will($this->returnValue($this->getForm('1')));
121
122 $data = array(0 => 'string', 1 => 'string');
123 $event = new FormEvent($this->form, $data);
124 $listener = new ResizeFormListener('text', array('max_length' => 10), true, false);
125 $listener->preSubmit($event);
126
127 $this->assertTrue($this->form->has('0'));
128 $this->assertTrue($this->form->has('1'));
129 }
130
131 public function testPreSubmitResizesDownIfAllowDelete()
132 {
133 $this->form->add($this->getForm('0'));
134 $this->form->add($this->getForm('1'));
135
136 $data = array(0 => 'string');
137 $event = new FormEvent($this->form, $data);
138 $listener = new ResizeFormListener('text', array(), false, true);
139 $listener->preSubmit($event);
140
141 $this->assertTrue($this->form->has('0'));
142 $this->assertFalse($this->form->has('1'));
143 }
144
145 // fix for https://github.com/symfony/symfony/pull/493
146 public function testPreSubmitRemovesZeroKeys()
147 {
148 $this->form->add($this->getForm('0'));
149
150 $data = array();
151 $event = new FormEvent($this->form, $data);
152 $listener = new ResizeFormListener('text', array(), false, true);
153 $listener->preSubmit($event);
154
155 $this->assertFalse($this->form->has('0'));
156 }
157
158 public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete()
159 {
160 $this->form->add($this->getForm('0'));
161 $this->form->add($this->getForm('1'));
162
163 $data = array(0 => 'string', 2 => 'string');
164 $event = new FormEvent($this->form, $data);
165 $listener = new ResizeFormListener('text', array(), false, false);
166 $listener->preSubmit($event);
167
168 $this->assertTrue($this->form->has('0'));
169 $this->assertTrue($this->form->has('1'));
170 $this->assertFalse($this->form->has('2'));
171 }
172
173 /**
174 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
175 */
176 public function testPreSubmitRequiresArrayOrTraversable()
177 {
178 $data = 'no array or traversable';
179 $event = new FormEvent($this->form, $data);
180 $listener = new ResizeFormListener('text', array(), false, false);
181 $listener->preSubmit($event);
182 }
183
184 public function testPreSubmitDealsWithNullData()
185 {
186 $this->form->add($this->getForm('1'));
187
188 $data = null;
189 $event = new FormEvent($this->form, $data);
190 $listener = new ResizeFormListener('text', array(), false, true);
191 $listener->preSubmit($event);
192
193 $this->assertFalse($this->form->has('1'));
194 }
195
196 // fixes https://github.com/symfony/symfony/pull/40
197 public function testPreSubmitDealsWithEmptyData()
198 {
199 $this->form->add($this->getForm('1'));
200
201 $data = '';
202 $event = new FormEvent($this->form, $data);
203 $listener = new ResizeFormListener('text', array(), false, true);
204 $listener->preSubmit($event);
205
206 $this->assertFalse($this->form->has('1'));
207 }
208
209 public function testOnSubmitNormDataRemovesEntriesMissingInTheFormIfAllowDelete()
210 {
211 $this->form->add($this->getForm('1'));
212
213 $data = array(0 => 'first', 1 => 'second', 2 => 'third');
214 $event = new FormEvent($this->form, $data);
215 $listener = new ResizeFormListener('text', array(), false, true);
216 $listener->onSubmit($event);
217
218 $this->assertEquals(array(1 => 'second'), $event->getData());
219 }
220
221 public function testOnSubmitNormDataDoesNothingIfNotAllowDelete()
222 {
223 $this->form->add($this->getForm('1'));
224
225 $data = array(0 => 'first', 1 => 'second', 2 => 'third');
226 $event = new FormEvent($this->form, $data);
227 $listener = new ResizeFormListener('text', array(), false, false);
228 $listener->onSubmit($event);
229
230 $this->assertEquals($data, $event->getData());
231 }
232
233 /**
234 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
235 */
236 public function testOnSubmitNormDataRequiresArrayOrTraversable()
237 {
238 $data = 'no array or traversable';
239 $event = new FormEvent($this->form, $data);
240 $listener = new ResizeFormListener('text', array(), false, false);
241 $listener->onSubmit($event);
242 }
243
244 public function testOnSubmitNormDataDealsWithNullData()
245 {
246 $this->form->add($this->getForm('1'));
247
248 $data = null;
249 $event = new FormEvent($this->form, $data);
250 $listener = new ResizeFormListener('text', array(), false, true);
251 $listener->onSubmit($event);
252
253 $this->assertEquals(array(), $event->getData());
254 }
255}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php
deleted file mode 100644
index 4e368933..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Core\EventListener;
13
14use Symfony\Component\Form\FormEvent;
15use Symfony\Component\Form\Extension\Core\EventListener\TrimListener;
16
17class TrimListenerTest extends \PHPUnit_Framework_TestCase
18{
19 protected function setUp()
20 {
21 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
22 $this->markTestSkipped('The "EventDispatcher" component is not available');
23 }
24 }
25
26 public function testTrim()
27 {
28 $data = " Foo! ";
29 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
30 $event = new FormEvent($form, $data);
31
32 $filter = new TrimListener();
33 $filter->preSubmit($event);
34
35 $this->assertEquals('Foo!', $event->getData());
36 }
37
38 public function testTrimSkipNonStrings()
39 {
40 $data = 1234;
41 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
42 $event = new FormEvent($form, $data);
43
44 $filter = new TrimListener();
45 $filter->preSubmit($event);
46
47 $this->assertSame(1234, $event->getData());
48 }
49
50 /**
51 * @dataProvider codePointProvider
52 */
53 public function testTrimUtf8($chars)
54 {
55 if (!function_exists('mb_check_encoding')) {
56 $this->markTestSkipped('The "mb_check_encoding" function is not available');
57 }
58
59 $data = mb_convert_encoding(pack('H*', implode('', $chars)), 'UTF-8', 'UCS-2BE');
60 $data = $data."ab\ncd".$data;
61
62 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
63 $event = new FormEvent($form, $data);
64
65 $filter = new TrimListener();
66 $filter->preSubmit($event);
67
68 $this->assertSame("ab\ncd", $event->getData(), 'TrimListener should trim character(s): '.implode(', ', $chars));
69 }
70
71 public function codePointProvider()
72 {
73 return array(
74 'General category: Separator' => array(array('0020', '00A0', '1680', '180E', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '200A', '2028', '2029', '202F', '205F', '3000')),
75 'General category: Other, control' => array(array('0009', '000A', '000B', '000C', '000D', '0085')),
76 //'General category: Other, format. ZERO WIDTH SPACE' => array(array('200B')),
77 );
78 }
79}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php
deleted file mode 100644
index bfa1e218..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
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}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
deleted file mode 100644
index a99b5444..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider;
13
14use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
15
16/**
17 * @runTestsInSeparateProcesses
18 */
19class DefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase
20{
21 protected $provider;
22
23 public static function setUpBeforeClass()
24 {
25 ini_set('session.save_handler', 'files');
26 ini_set('session.save_path', sys_get_temp_dir());
27 }
28
29 protected function setUp()
30 {
31 $this->provider = new DefaultCsrfProvider('SECRET');
32 }
33
34 protected function tearDown()
35 {
36 $this->provider = null;
37 }
38
39 public function testGenerateCsrfToken()
40 {
41 session_start();
42
43 $token = $this->provider->generateCsrfToken('foo');
44
45 $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
46 }
47
48 public function testGenerateCsrfTokenOnUnstartedSession()
49 {
50 session_id('touti');
51
52 if (!version_compare(PHP_VERSION, '5.4', '>=')) {
53 $this->markTestSkipped('This test requires PHP >= 5.4');
54 }
55
56 $this->assertSame(PHP_SESSION_NONE, session_status());
57
58 $token = $this->provider->generateCsrfToken('foo');
59
60 $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token);
61 $this->assertSame(PHP_SESSION_ACTIVE, session_status());
62 }
63
64 public function testIsCsrfTokenValidSucceeds()
65 {
66 session_start();
67
68 $token = sha1('SECRET'.'foo'.session_id());
69
70 $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token));
71 }
72
73 public function testIsCsrfTokenValidFails()
74 {
75 session_start();
76
77 $token = sha1('SECRET'.'bar'.session_id());
78
79 $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token));
80 }
81}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php
deleted file mode 100644
index 1dcc6b4c..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php
+++ /dev/null
@@ -1,75 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider;
13
14use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
15
16class SessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
17{
18 protected $provider;
19 protected $session;
20
21 protected function setUp()
22 {
23 if (!class_exists('Symfony\Component\HttpFoundation\Session\Session')) {
24 $this->markTestSkipped('The "HttpFoundation" component is not available');
25 }
26
27 $this->session = $this->getMock(
28 'Symfony\Component\HttpFoundation\Session\Session',
29 array(),
30 array(),
31 '',
32 false // don't call constructor
33 );
34 $this->provider = new SessionCsrfProvider($this->session, 'SECRET');
35 }
36
37 protected function tearDown()
38 {
39 $this->provider = null;
40 $this->session = null;
41 }
42
43 public function testGenerateCsrfToken()
44 {
45 $this->session->expects($this->once())
46 ->method('getId')
47 ->will($this->returnValue('ABCDEF'));
48
49 $token = $this->provider->generateCsrfToken('foo');
50
51 $this->assertEquals(sha1('SECRET'.'foo'.'ABCDEF'), $token);
52 }
53
54 public function testIsCsrfTokenValidSucceeds()
55 {
56 $this->session->expects($this->once())
57 ->method('getId')
58 ->will($this->returnValue('ABCDEF'));
59
60 $token = sha1('SECRET'.'foo'.'ABCDEF');
61
62 $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token));
63 }
64
65 public function testIsCsrfTokenValidFails()
66 {
67 $this->session->expects($this->once())
68 ->method('getId')
69 ->will($this->returnValue('ABCDEF'));
70
71 $token = sha1('SECRET'.'bar'.'ABCDEF');
72
73 $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token));
74 }
75}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
deleted file mode 100644
index 0bcfe74e..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
+++ /dev/null
@@ -1,78 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener;
13
14use Symfony\Component\Form\FormBuilder;
15use Symfony\Component\Form\FormEvent;
16use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
17
18class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase
19{
20 protected $dispatcher;
21 protected $factory;
22 protected $csrfProvider;
23
24 protected function setUp()
25 {
26 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
27 $this->markTestSkipped('The "EventDispatcher" component is not available');
28 }
29
30 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
31 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
32 $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface');
33 $this->form = $this->getBuilder('post')
34 ->setDataMapper($this->getDataMapper())
35 ->getForm();
36 }
37
38 protected function tearDown()
39 {
40 $this->dispatcher = null;
41 $this->factory = null;
42 $this->csrfProvider = null;
43 $this->form = null;
44 }
45
46 protected function getBuilder($name = 'name')
47 {
48 return new FormBuilder($name, null, $this->dispatcher, $this->factory, array('compound' => true));
49 }
50
51 protected function getForm($name = 'name')
52 {
53 return $this->getBuilder($name)->getForm();
54 }
55
56 protected function getDataMapper()
57 {
58 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
59 }
60
61 protected function getMockForm()
62 {
63 return $this->getMock('Symfony\Component\Form\Test\FormInterface');
64 }
65
66 // https://github.com/symfony/symfony/pull/5838
67 public function testStringFormData()
68 {
69 $data = "XP4HUzmHPi";
70 $event = new FormEvent($this->form, $data);
71
72 $validation = new CsrfValidationListener('csrf', $this->csrfProvider, 'unknown', 'Invalid.');
73 $validation->preSubmit($event);
74
75 // Validate accordingly
76 $this->assertSame($data, $event->getData());
77 }
78}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
deleted file mode 100644
index 0a1f0dc4..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php
+++ /dev/null
@@ -1,301 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Csrf\Type;
13
14use Symfony\Component\Form\AbstractType;
15use Symfony\Component\Form\FormBuilderInterface;
16use Symfony\Component\Form\FormError;
17use Symfony\Component\Form\Test\TypeTestCase;
18use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
19
20class FormTypeCsrfExtensionTest_ChildType extends AbstractType
21{
22 public function buildForm(FormBuilderInterface $builder, array $options)
23 {
24 // The form needs a child in order to trigger CSRF protection by
25 // default
26 $builder->add('name', 'text');
27 }
28
29 public function getName()
30 {
31 return 'csrf_collection_test';
32 }
33}
34
35class FormTypeCsrfExtensionTest extends TypeTestCase
36{
37 /**
38 * @var \PHPUnit_Framework_MockObject_MockObject
39 */
40 protected $csrfProvider;
41
42 /**
43 * @var \PHPUnit_Framework_MockObject_MockObject
44 */
45 protected $translator;
46
47 protected function setUp()
48 {
49 $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface');
50 $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
51
52 parent::setUp();
53 }
54
55 protected function tearDown()
56 {
57 $this->csrfProvider = null;
58 $this->translator = null;
59
60 parent::tearDown();
61 }
62
63 protected function getExtensions()
64 {
65 return array_merge(parent::getExtensions(), array(
66 new CsrfExtension($this->csrfProvider, $this->translator),
67 ));
68 }
69
70 public function testCsrfProtectionByDefaultIfRootAndCompound()
71 {
72 $view = $this->factory
73 ->create('form', null, array(
74 'csrf_field_name' => 'csrf',
75 'compound' => true,
76 ))
77 ->createView();
78
79 $this->assertTrue(isset($view['csrf']));
80 }
81
82 public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
83 {
84 $view = $this->factory
85 ->createNamedBuilder('root', 'form')
86 ->add($this->factory
87 ->createNamedBuilder('form', 'form', null, array(
88 'csrf_field_name' => 'csrf',
89 'compound' => true,
90 ))
91 )
92 ->getForm()
93 ->get('form')
94 ->createView();
95
96 $this->assertFalse(isset($view['csrf']));
97 }
98
99 public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
100 {
101 $view = $this->factory
102 ->create('form', null, array(
103 'csrf_field_name' => 'csrf',
104 'compound' => false,
105 ))
106 ->createView();
107
108 $this->assertFalse(isset($view['csrf']));
109 }
110
111 public function testCsrfProtectionCanBeDisabled()
112 {
113 $view = $this->factory
114 ->create('form', null, array(
115 'csrf_field_name' => 'csrf',
116 'csrf_protection' => false,
117 'compound' => true,
118 ))
119 ->createView();
120
121 $this->assertFalse(isset($view['csrf']));
122 }
123
124 public function testGenerateCsrfToken()
125 {
126 $this->csrfProvider->expects($this->once())
127 ->method('generateCsrfToken')
128 ->with('%INTENTION%')
129 ->will($this->returnValue('token'));
130
131 $view = $this->factory
132 ->create('form', null, array(
133 'csrf_field_name' => 'csrf',
134 'csrf_provider' => $this->csrfProvider,
135 'intention' => '%INTENTION%',
136 'compound' => true,
137 ))
138 ->createView();
139
140 $this->assertEquals('token', $view['csrf']->vars['value']);
141 }
142
143 public function provideBoolean()
144 {
145 return array(
146 array(true),
147 array(false),
148 );
149 }
150
151 /**
152 * @dataProvider provideBoolean
153 */
154 public function testValidateTokenOnSubmitIfRootAndCompound($valid)
155 {
156 $this->csrfProvider->expects($this->once())
157 ->method('isCsrfTokenValid')
158 ->with('%INTENTION%', 'token')
159 ->will($this->returnValue($valid));
160
161 $form = $this->factory
162 ->createBuilder('form', null, array(
163 'csrf_field_name' => 'csrf',
164 'csrf_provider' => $this->csrfProvider,
165 'intention' => '%INTENTION%',
166 'compound' => true,
167 ))
168 ->add('child', 'text')
169 ->getForm();
170
171 $form->submit(array(
172 'child' => 'foobar',
173 'csrf' => 'token',
174 ));
175
176 // Remove token from data
177 $this->assertSame(array('child' => 'foobar'), $form->getData());
178
179 // Validate accordingly
180 $this->assertSame($valid, $form->isValid());
181 }
182
183 public function testFailIfRootAndCompoundAndTokenMissing()
184 {
185 $this->csrfProvider->expects($this->never())
186 ->method('isCsrfTokenValid');
187
188 $form = $this->factory
189 ->createBuilder('form', null, array(
190 'csrf_field_name' => 'csrf',
191 'csrf_provider' => $this->csrfProvider,
192 'intention' => '%INTENTION%',
193 'compound' => true,
194 ))
195 ->add('child', 'text')
196 ->getForm();
197
198 $form->submit(array(
199 'child' => 'foobar',
200 // token is missing
201 ));
202
203 // Remove token from data
204 $this->assertSame(array('child' => 'foobar'), $form->getData());
205
206 // Validate accordingly
207 $this->assertFalse($form->isValid());
208 }
209
210 public function testDontValidateTokenIfCompoundButNoRoot()
211 {
212 $this->csrfProvider->expects($this->never())
213 ->method('isCsrfTokenValid');
214
215 $form = $this->factory
216 ->createNamedBuilder('root', 'form')
217 ->add($this->factory
218 ->createNamedBuilder('form', 'form', null, array(
219 'csrf_field_name' => 'csrf',
220 'csrf_provider' => $this->csrfProvider,
221 'intention' => '%INTENTION%',
222 'compound' => true,
223 ))
224 )
225 ->getForm()
226 ->get('form');
227
228 $form->submit(array(
229 'child' => 'foobar',
230 'csrf' => 'token',
231 ));
232 }
233
234 public function testDontValidateTokenIfRootButNotCompound()
235 {
236 $this->csrfProvider->expects($this->never())
237 ->method('isCsrfTokenValid');
238
239 $form = $this->factory
240 ->create('form', null, array(
241 'csrf_field_name' => 'csrf',
242 'csrf_provider' => $this->csrfProvider,
243 'intention' => '%INTENTION%',
244 'compound' => false,
245 ));
246
247 $form->submit(array(
248 'csrf' => 'token',
249 ));
250 }
251
252 public function testNoCsrfProtectionOnPrototype()
253 {
254 $prototypeView = $this->factory
255 ->create('collection', null, array(
256 'type' => new FormTypeCsrfExtensionTest_ChildType(),
257 'options' => array(
258 'csrf_field_name' => 'csrf',
259 ),
260 'prototype' => true,
261 'allow_add' => true,
262 ))
263 ->createView()
264 ->vars['prototype'];
265
266 $this->assertFalse(isset($prototypeView['csrf']));
267 $this->assertCount(1, $prototypeView);
268 }
269
270 public function testsTranslateCustomErrorMessage()
271 {
272 $this->csrfProvider->expects($this->once())
273 ->method('isCsrfTokenValid')
274 ->with('%INTENTION%', 'token')
275 ->will($this->returnValue(false));
276
277 $this->translator->expects($this->once())
278 ->method('trans')
279 ->with('Foobar')
280 ->will($this->returnValue('[trans]Foobar[/trans]'));
281
282 $form = $this->factory
283 ->createBuilder('form', null, array(
284 'csrf_field_name' => 'csrf',
285 'csrf_provider' => $this->csrfProvider,
286 'csrf_message' => 'Foobar',
287 'intention' => '%INTENTION%',
288 'compound' => true,
289 ))
290 ->getForm();
291
292 $form->submit(array(
293 'csrf' => 'token',
294 ));
295
296 $errors = $form->getErrors();
297
298 $this->assertGreaterThan(0, count($errors));
299 $this->assertEquals(new FormError('[trans]Foobar[/trans]'), $errors[0]);
300 }
301}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php
deleted file mode 100644
index 2ff072b2..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php
+++ /dev/null
@@ -1,286 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener;
13
14use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
15use Symfony\Component\Form\Form;
16use Symfony\Component\Form\FormConfigBuilder;
17use Symfony\Component\Form\FormEvent;
18use Symfony\Component\Form\Test\DeprecationErrorHandler;
19use Symfony\Component\HttpFoundation\Request;
20use Symfony\Component\HttpFoundation\File\UploadedFile;
21
22/**
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class BindRequestListenerTest extends \PHPUnit_Framework_TestCase
26{
27 private $values;
28
29 private $filesPlain;
30
31 private $filesNested;
32
33 /**
34 * @var UploadedFile
35 */
36 private $uploadedFile;
37
38 protected function setUp()
39 {
40 $path = tempnam(sys_get_temp_dir(), 'sf2');
41 touch($path);
42
43 $this->values = array(
44 'name' => 'Bernhard',
45 'image' => array('filename' => 'foobar.png'),
46 );
47
48 $this->filesPlain = array(
49 'image' => array(
50 'error' => UPLOAD_ERR_OK,
51 'name' => 'upload.png',
52 'size' => 123,
53 'tmp_name' => $path,
54 'type' => 'image/png'
55 ),
56 );
57
58 $this->filesNested = array(
59 'error' => array('image' => UPLOAD_ERR_OK),
60 'name' => array('image' => 'upload.png'),
61 'size' => array('image' => 123),
62 'tmp_name' => array('image' => $path),
63 'type' => array('image' => 'image/png'),
64 );
65
66 $this->uploadedFile = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK);
67 }
68
69 protected function tearDown()
70 {
71 unlink($this->uploadedFile->getRealPath());
72 }
73
74 public function requestMethodProvider()
75 {
76 return array(
77 array('POST'),
78 array('PUT'),
79 array('DELETE'),
80 array('PATCH'),
81 );
82 }
83
84 /**
85 * @dataProvider requestMethodProvider
86 */
87 public function testSubmitRequest($method)
88 {
89 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
90 $this->markTestSkipped('The "HttpFoundation" component is not available');
91 }
92
93 $values = array('author' => $this->values);
94 $files = array('author' => $this->filesNested);
95 $request = new Request(array(), $values, array(), array(), $files, array(
96 'REQUEST_METHOD' => $method,
97 ));
98
99 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
100 $config = new FormConfigBuilder('author', null, $dispatcher);
101 $form = new Form($config);
102 $event = new FormEvent($form, $request);
103
104 $listener = new BindRequestListener();
105 DeprecationErrorHandler::preBind($listener, $event);
106
107 $this->assertEquals(array(
108 'name' => 'Bernhard',
109 'image' => $this->uploadedFile,
110 ), $event->getData());
111 }
112
113 /**
114 * @dataProvider requestMethodProvider
115 */
116 public function testSubmitRequestWithEmptyName($method)
117 {
118 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
119 $this->markTestSkipped('The "HttpFoundation" component is not available');
120 }
121
122 $request = new Request(array(), $this->values, array(), array(), $this->filesPlain, array(
123 'REQUEST_METHOD' => $method,
124 ));
125
126 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
127 $config = new FormConfigBuilder('', null, $dispatcher);
128 $form = new Form($config);
129 $event = new FormEvent($form, $request);
130
131 $listener = new BindRequestListener();
132 DeprecationErrorHandler::preBind($listener, $event);
133
134 $this->assertEquals(array(
135 'name' => 'Bernhard',
136 'image' => $this->uploadedFile,
137 ), $event->getData());
138 }
139
140 /**
141 * @dataProvider requestMethodProvider
142 */
143 public function testSubmitEmptyRequestToCompoundForm($method)
144 {
145 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
146 $this->markTestSkipped('The "HttpFoundation" component is not available');
147 }
148
149 $request = new Request(array(), array(), array(), array(), array(), array(
150 'REQUEST_METHOD' => $method,
151 ));
152
153 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
154 $config = new FormConfigBuilder('author', null, $dispatcher);
155 $config->setCompound(true);
156 $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
157 $form = new Form($config);
158 $event = new FormEvent($form, $request);
159
160 $listener = new BindRequestListener();
161 DeprecationErrorHandler::preBind($listener, $event);
162
163 // Default to empty array
164 $this->assertEquals(array(), $event->getData());
165 }
166
167 /**
168 * @dataProvider requestMethodProvider
169 */
170 public function testSubmitEmptyRequestToSimpleForm($method)
171 {
172 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
173 $this->markTestSkipped('The "HttpFoundation" component is not available');
174 }
175
176 $request = new Request(array(), array(), array(), array(), array(), array(
177 'REQUEST_METHOD' => $method,
178 ));
179
180 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
181 $config = new FormConfigBuilder('author', null, $dispatcher);
182 $config->setCompound(false);
183 $form = new Form($config);
184 $event = new FormEvent($form, $request);
185
186 $listener = new BindRequestListener();
187 DeprecationErrorHandler::preBind($listener, $event);
188
189 // Default to null
190 $this->assertNull($event->getData());
191 }
192
193 public function testSubmitGetRequest()
194 {
195 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
196 $this->markTestSkipped('The "HttpFoundation" component is not available');
197 }
198
199 $values = array('author' => $this->values);
200 $request = new Request($values, array(), array(), array(), array(), array(
201 'REQUEST_METHOD' => 'GET',
202 ));
203
204 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
205 $config = new FormConfigBuilder('author', null, $dispatcher);
206 $form = new Form($config);
207 $event = new FormEvent($form, $request);
208
209 $listener = new BindRequestListener();
210 DeprecationErrorHandler::preBind($listener, $event);
211
212 $this->assertEquals(array(
213 'name' => 'Bernhard',
214 'image' => array('filename' => 'foobar.png'),
215 ), $event->getData());
216 }
217
218 public function testSubmitGetRequestWithEmptyName()
219 {
220 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
221 $this->markTestSkipped('The "HttpFoundation" component is not available');
222 }
223
224 $request = new Request($this->values, array(), array(), array(), array(), array(
225 'REQUEST_METHOD' => 'GET',
226 ));
227
228 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
229 $config = new FormConfigBuilder('', null, $dispatcher);
230 $form = new Form($config);
231 $event = new FormEvent($form, $request);
232
233 $listener = new BindRequestListener();
234 DeprecationErrorHandler::preBind($listener, $event);
235
236 $this->assertEquals(array(
237 'name' => 'Bernhard',
238 'image' => array('filename' => 'foobar.png'),
239 ), $event->getData());
240 }
241
242 public function testSubmitEmptyGetRequestToCompoundForm()
243 {
244 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
245 $this->markTestSkipped('The "HttpFoundation" component is not available');
246 }
247
248 $request = new Request(array(), array(), array(), array(), array(), array(
249 'REQUEST_METHOD' => 'GET',
250 ));
251
252 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
253 $config = new FormConfigBuilder('author', null, $dispatcher);
254 $config->setCompound(true);
255 $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface'));
256 $form = new Form($config);
257 $event = new FormEvent($form, $request);
258
259 $listener = new BindRequestListener();
260 DeprecationErrorHandler::preBind($listener, $event);
261
262 $this->assertEquals(array(), $event->getData());
263 }
264
265 public function testSubmitEmptyGetRequestToSimpleForm()
266 {
267 if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
268 $this->markTestSkipped('The "HttpFoundation" component is not available');
269 }
270
271 $request = new Request(array(), array(), array(), array(), array(), array(
272 'REQUEST_METHOD' => 'GET',
273 ));
274
275 $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
276 $config = new FormConfigBuilder('author', null, $dispatcher);
277 $config->setCompound(false);
278 $form = new Form($config);
279 $event = new FormEvent($form, $request);
280
281 $listener = new BindRequestListener();
282 DeprecationErrorHandler::preBind($listener, $event);
283
284 $this->assertNull($event->getData());
285 }
286}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
deleted file mode 100644
index 2d5cf776..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\HttpFoundation;
13
14use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
15use Symfony\Component\Form\Tests\AbstractRequestHandlerTest;
16use Symfony\Component\HttpFoundation\Request;
17
18/**
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 */
21class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
22{
23 /**
24 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
25 */
26 public function testRequestShouldNotBeNull()
27 {
28 $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'));
29 }
30 /**
31 * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
32 */
33 public function testRequestShouldBeInstanceOfRequest()
34 {
35 $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), new \stdClass());
36 }
37
38 protected function setRequestData($method, $data, $files = array())
39 {
40 $this->request = Request::create('http://localhost', $method, $data, array(), $files);
41 }
42
43 protected function getRequestHandler()
44 {
45 return new HttpFoundationRequestHandler();
46 }
47
48 protected function getMockFile()
49 {
50 return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
51 ->disableOriginalConstructor()
52 ->getMock();
53 }
54}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
deleted file mode 100644
index a8bdde8a..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php
+++ /dev/null
@@ -1,748 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints;
13
14use Symfony\Component\Form\FormBuilder;
15use Symfony\Component\Form\Exception\TransformationFailedException;
16use Symfony\Component\Form\CallbackTransformer;
17use Symfony\Component\Form\FormInterface;
18use Symfony\Component\Form\Extension\Validator\Constraints\Form;
19use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator;
20use Symfony\Component\Form\SubmitButtonBuilder;
21use Symfony\Component\Validator\Constraint;
22use Symfony\Component\Validator\Constraints\NotNull;
23use Symfony\Component\Validator\Constraints\NotBlank;
24
25/**
26 * @author Bernhard Schussek <bschussek@gmail.com>
27 */
28class FormValidatorTest extends \PHPUnit_Framework_TestCase
29{
30 /**
31 * @var \PHPUnit_Framework_MockObject_MockObject
32 */
33 private $dispatcher;
34
35 /**
36 * @var \PHPUnit_Framework_MockObject_MockObject
37 */
38 private $factory;
39
40 /**
41 * @var \PHPUnit_Framework_MockObject_MockObject
42 */
43 private $serverParams;
44
45 /**
46 * @var FormValidator
47 */
48 private $validator;
49
50 protected function setUp()
51 {
52 if (!class_exists('Symfony\Component\EventDispatcher\Event')) {
53 $this->markTestSkipped('The "EventDispatcher" component is not available');
54 }
55
56 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
57 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
58 $this->serverParams = $this->getMock(
59 'Symfony\Component\Form\Extension\Validator\Util\ServerParams',
60 array('getNormalizedIniPostMaxSize', 'getContentLength')
61 );
62 $this->validator = new FormValidator($this->serverParams);
63 }
64
65 public function testValidate()
66 {
67 $context = $this->getMockExecutionContext();
68 $object = $this->getMock('\stdClass');
69 $options = array('validation_groups' => array('group1', 'group2'));
70 $form = $this->getBuilder('name', '\stdClass', $options)
71 ->setData($object)
72 ->getForm();
73
74 $context->expects($this->at(0))
75 ->method('validate')
76 ->with($object, 'data', 'group1', true);
77 $context->expects($this->at(1))
78 ->method('validate')
79 ->with($object, 'data', 'group2', true);
80
81 $this->validator->initialize($context);
82 $this->validator->validate($form, new Form());
83 }
84
85 public function testValidateConstraints()
86 {
87 $context = $this->getMockExecutionContext();
88 $object = $this->getMock('\stdClass');
89 $constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
90 $constraint2 = new NotBlank(array('groups' => 'group2'));
91
92 $options = array(
93 'validation_groups' => array('group1', 'group2'),
94 'constraints' => array($constraint1, $constraint2),
95 );
96 $form = $this->getBuilder('name', '\stdClass', $options)
97 ->setData($object)
98 ->getForm();
99
100 // First default constraints
101 $context->expects($this->at(0))
102 ->method('validate')
103 ->with($object, 'data', 'group1', true);
104 $context->expects($this->at(1))
105 ->method('validate')
106 ->with($object, 'data', 'group2', true);
107
108 // Then custom constraints
109 $context->expects($this->at(2))
110 ->method('validateValue')
111 ->with($object, $constraint1, 'data', 'group1');
112 $context->expects($this->at(3))
113 ->method('validateValue')
114 ->with($object, $constraint2, 'data', 'group2');
115
116 $this->validator->initialize($context);
117 $this->validator->validate($form, new Form());
118 }
119
120 public function testDontValidateIfParentWithoutCascadeValidation()
121 {
122 $context = $this->getMockExecutionContext();
123 $object = $this->getMock('\stdClass');
124
125 $parent = $this->getBuilder('parent', null, array('cascade_validation' => false))
126 ->setCompound(true)
127 ->setDataMapper($this->getDataMapper())
128 ->getForm();
129 $options = array('validation_groups' => array('group1', 'group2'));
130 $form = $this->getBuilder('name', '\stdClass', $options)->getForm();
131 $parent->add($form);
132
133 $form->setData($object);
134
135 $context->expects($this->never())
136 ->method('validate');
137
138 $this->validator->initialize($context);
139 $this->validator->validate($form, new Form());
140 }
141
142 public function testValidateConstraintsEvenIfNoCascadeValidation()
143 {
144 $context = $this->getMockExecutionContext();
145 $object = $this->getMock('\stdClass');
146 $constraint1 = new NotNull(array('groups' => array('group1', 'group2')));
147 $constraint2 = new NotBlank(array('groups' => 'group2'));
148
149 $parent = $this->getBuilder('parent', null, array('cascade_validation' => false))
150 ->setCompound(true)
151 ->setDataMapper($this->getDataMapper())
152 ->getForm();
153 $options = array(
154 'validation_groups' => array('group1', 'group2'),
155 'constraints' => array($constraint1, $constraint2),
156 );
157 $form = $this->getBuilder('name', '\stdClass', $options)
158 ->setData($object)
159 ->getForm();
160 $parent->add($form);
161
162 $context->expects($this->at(0))
163 ->method('validateValue')
164 ->with($object, $constraint1, 'data', 'group1');
165 $context->expects($this->at(1))
166 ->method('validateValue')
167 ->with($object, $constraint2, 'data', 'group2');
168
169 $this->validator->initialize($context);
170 $this->validator->validate($form, new Form());
171 }
172
173 public function testDontValidateIfNoValidationGroups()
174 {
175 $context = $this->getMockExecutionContext();
176 $object = $this->getMock('\stdClass');
177
178 $form = $this->getBuilder('name', '\stdClass', array(
179 'validation_groups' => array(),
180 ))
181 ->setData($object)
182 ->getForm();
183
184 $form->setData($object);
185
186 $context->expects($this->never())
187 ->method('validate');
188
189 $this->validator->initialize($context);
190 $this->validator->validate($form, new Form());
191 }
192
193 public function testDontValidateConstraintsIfNoValidationGroups()
194 {
195 $context = $this->getMockExecutionContext();
196 $object = $this->getMock('\stdClass');
197 $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
198 $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
199
200 $options = array(
201 'validation_groups' => array(),
202 'constraints' => array($constraint1, $constraint2),
203 );
204 $form = $this->getBuilder('name', '\stdClass', $options)
205 ->setData($object)
206 ->getForm();
207
208 // Launch transformer
209 $form->submit(array());
210
211 $context->expects($this->never())
212 ->method('validate');
213
214 $this->validator->initialize($context);
215 $this->validator->validate($form, new Form());
216 }
217
218 public function testDontValidateIfNotSynchronized()
219 {
220 $context = $this->getMockExecutionContext();
221 $object = $this->getMock('\stdClass');
222
223 $form = $this->getBuilder('name', '\stdClass', array(
224 'invalid_message' => 'invalid_message_key',
225 // Invalid message parameters must be supported, because the
226 // invalid message can be a translation key
227 // see https://github.com/symfony/symfony/issues/5144
228 'invalid_message_parameters' => array('{{ foo }}' => 'bar'),
229 ))
230 ->setData($object)
231 ->addViewTransformer(new CallbackTransformer(
232 function ($data) { return $data; },
233 function () { throw new TransformationFailedException(); }
234 ))
235 ->getForm();
236
237 // Launch transformer
238 $form->submit('foo');
239
240 $context->expects($this->never())
241 ->method('validate');
242
243 $context->expects($this->once())
244 ->method('addViolation')
245 ->with(
246 'invalid_message_key',
247 array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'),
248 'foo'
249 );
250 $context->expects($this->never())
251 ->method('addViolationAt');
252
253 $this->validator->initialize($context);
254 $this->validator->validate($form, new Form());
255 }
256
257 public function testAddInvalidErrorEvenIfNoValidationGroups()
258 {
259 $context = $this->getMockExecutionContext();
260 $object = $this->getMock('\stdClass');
261
262 $form = $this->getBuilder('name', '\stdClass', array(
263 'invalid_message' => 'invalid_message_key',
264 // Invalid message parameters must be supported, because the
265 // invalid message can be a translation key
266 // see https://github.com/symfony/symfony/issues/5144
267 'invalid_message_parameters' => array('{{ foo }}' => 'bar'),
268 'validation_groups' => array(),
269 ))
270 ->setData($object)
271 ->addViewTransformer(new CallbackTransformer(
272 function ($data) { return $data; },
273 function () { throw new TransformationFailedException(); }
274 ))
275 ->getForm();
276
277 // Launch transformer
278 $form->submit('foo');
279
280 $context->expects($this->never())
281 ->method('validate');
282
283 $context->expects($this->once())
284 ->method('addViolation')
285 ->with(
286 'invalid_message_key',
287 array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'),
288 'foo'
289 );
290 $context->expects($this->never())
291 ->method('addViolationAt');
292
293 $this->validator->initialize($context);
294 $this->validator->validate($form, new Form());
295 }
296
297 public function testDontValidateConstraintsIfNotSynchronized()
298 {
299 $context = $this->getMockExecutionContext();
300 $object = $this->getMock('\stdClass');
301 $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint');
302 $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint');
303
304 $options = array(
305 'validation_groups' => array('group1', 'group2'),
306 'constraints' => array($constraint1, $constraint2),
307 );
308 $form = $this->getBuilder('name', '\stdClass', $options)
309 ->setData($object)
310 ->addViewTransformer(new CallbackTransformer(
311 function ($data) { return $data; },
312 function () { throw new TransformationFailedException(); }
313 ))
314 ->getForm();
315
316 // Launch transformer
317 $form->submit(array());
318
319 $context->expects($this->never())
320 ->method('validate');
321
322 $this->validator->initialize($context);
323 $this->validator->validate($form, new Form());
324 }
325
326 // https://github.com/symfony/symfony/issues/4359
327 public function testDontMarkInvalidIfAnyChildIsNotSynchronized()
328 {
329 $context = $this->getMockExecutionContext();
330 $object = $this->getMock('\stdClass');
331
332 $failingTransformer = new CallbackTransformer(
333 function ($data) { return $data; },
334 function () { throw new TransformationFailedException(); }
335 );
336
337 $form = $this->getBuilder('name', '\stdClass')
338 ->setData($object)
339 ->addViewTransformer($failingTransformer)
340 ->setCompound(true)
341 ->setDataMapper($this->getDataMapper())
342 ->add(
343 $this->getBuilder('child')
344 ->addViewTransformer($failingTransformer)
345 )
346 ->getForm();
347
348 // Launch transformer
349 $form->submit(array('child' => 'foo'));
350
351 $context->expects($this->never())
352 ->method('addViolation');
353 $context->expects($this->never())
354 ->method('addViolationAt');
355
356 $this->validator->initialize($context);
357 $this->validator->validate($form, new Form());
358 }
359
360 public function testHandleCallbackValidationGroups()
361 {
362 $context = $this->getMockExecutionContext();
363 $object = $this->getMock('\stdClass');
364 $options = array('validation_groups' => array($this, 'getValidationGroups'));
365 $form = $this->getBuilder('name', '\stdClass', $options)
366 ->setData($object)
367 ->getForm();
368
369 $context->expects($this->at(0))
370 ->method('validate')
371 ->with($object, 'data', 'group1', true);
372 $context->expects($this->at(1))
373 ->method('validate')
374 ->with($object, 'data', 'group2', true);
375
376 $this->validator->initialize($context);
377 $this->validator->validate($form, new Form());
378 }
379
380 public function testDontExecuteFunctionNames()
381 {
382 $context = $this->getMockExecutionContext();
383 $object = $this->getMock('\stdClass');
384 $options = array('validation_groups' => 'header');
385 $form = $this->getBuilder('name', '\stdClass', $options)
386 ->setData($object)
387 ->getForm();
388
389 $context->expects($this->once())
390 ->method('validate')
391 ->with($object, 'data', 'header', true);
392
393 $this->validator->initialize($context);
394 $this->validator->validate($form, new Form());
395 }
396
397 public function testHandleClosureValidationGroups()
398 {
399 $context = $this->getMockExecutionContext();
400 $object = $this->getMock('\stdClass');
401 $options = array('validation_groups' => function(FormInterface $form){
402 return array('group1', 'group2');
403 });
404 $form = $this->getBuilder('name', '\stdClass', $options)
405 ->setData($object)
406 ->getForm();
407
408 $context->expects($this->at(0))
409 ->method('validate')
410 ->with($object, 'data', 'group1', true);
411 $context->expects($this->at(1))
412 ->method('validate')
413 ->with($object, 'data', 'group2', true);
414
415 $this->validator->initialize($context);
416 $this->validator->validate($form, new Form());
417 }
418
419 public function testUseValidationGroupOfClickedButton()
420 {
421 $context = $this->getMockExecutionContext();
422 $object = $this->getMock('\stdClass');
423
424 $parent = $this->getBuilder('parent', null, array('cascade_validation' => true))
425 ->setCompound(true)
426 ->setDataMapper($this->getDataMapper())
427 ->getForm();
428 $form = $this->getForm('name', '\stdClass', array(
429 'validation_groups' => 'form_group',
430 ));
431
432 $parent->add($form);
433 $parent->add($this->getClickedSubmitButton('submit', array(
434 'validation_groups' => 'button_group',
435 )));
436
437 $form->setData($object);
438
439 $context->expects($this->once())
440 ->method('validate')
441 ->with($object, 'data', 'button_group', true);
442
443 $this->validator->initialize($context);
444 $this->validator->validate($form, new Form());
445 }
446
447 public function testDontUseValidationGroupOfUnclickedButton()
448 {
449 $context = $this->getMockExecutionContext();
450 $object = $this->getMock('\stdClass');
451
452 $parent = $this->getBuilder('parent', null, array('cascade_validation' => true))
453 ->setCompound(true)
454 ->setDataMapper($this->getDataMapper())
455 ->getForm();
456 $form = $this->getForm('name', '\stdClass', array(
457 'validation_groups' => 'form_group',
458 ));
459
460 $parent->add($form);
461 $parent->add($this->getSubmitButton('submit', array(
462 'validation_groups' => 'button_group',
463 )));
464
465 $form->setData($object);
466
467 $context->expects($this->once())
468 ->method('validate')
469 ->with($object, 'data', 'form_group', true);
470
471 $this->validator->initialize($context);
472 $this->validator->validate($form, new Form());
473 }
474
475 public function testUseInheritedValidationGroup()
476 {
477 $context = $this->getMockExecutionContext();
478 $object = $this->getMock('\stdClass');
479
480 $parentOptions = array(
481 'validation_groups' => 'group',
482 'cascade_validation' => true,
483 );
484 $parent = $this->getBuilder('parent', null, $parentOptions)
485 ->setCompound(true)
486 ->setDataMapper($this->getDataMapper())
487 ->getForm();
488 $form = $this->getBuilder('name', '\stdClass')->getForm();
489 $parent->add($form);
490
491 $form->setData($object);
492
493 $context->expects($this->once())
494 ->method('validate')
495 ->with($object, 'data', 'group', true);
496
497 $this->validator->initialize($context);
498 $this->validator->validate($form, new Form());
499 }
500
501 public function testUseInheritedCallbackValidationGroup()
502 {
503 $context = $this->getMockExecutionContext();
504 $object = $this->getMock('\stdClass');
505
506 $parentOptions = array(
507 'validation_groups' => array($this, 'getValidationGroups'),
508 'cascade_validation' => true,
509 );
510 $parent = $this->getBuilder('parent', null, $parentOptions)
511 ->setCompound(true)
512 ->setDataMapper($this->getDataMapper())
513 ->getForm();
514 $form = $this->getBuilder('name', '\stdClass')->getForm();
515 $parent->add($form);
516
517 $form->setData($object);
518
519 $context->expects($this->at(0))
520 ->method('validate')
521 ->with($object, 'data', 'group1', true);
522 $context->expects($this->at(1))
523 ->method('validate')
524 ->with($object, 'data', 'group2', true);
525
526 $this->validator->initialize($context);
527 $this->validator->validate($form, new Form());
528 }
529
530 public function testUseInheritedClosureValidationGroup()
531 {
532 $context = $this->getMockExecutionContext();
533 $object = $this->getMock('\stdClass');
534
535 $parentOptions = array(
536 'validation_groups' => function(FormInterface $form){
537 return array('group1', 'group2');
538 },
539 'cascade_validation' => true,
540 );
541 $parent = $this->getBuilder('parent', null, $parentOptions)
542 ->setCompound(true)
543 ->setDataMapper($this->getDataMapper())
544 ->getForm();
545 $form = $this->getBuilder('name', '\stdClass')->getForm();
546 $parent->add($form);
547
548 $form->setData($object);
549
550 $context->expects($this->at(0))
551 ->method('validate')
552 ->with($object, 'data', 'group1', true);
553 $context->expects($this->at(1))
554 ->method('validate')
555 ->with($object, 'data', 'group2', true);
556
557 $this->validator->initialize($context);
558 $this->validator->validate($form, new Form());
559 }
560
561 public function testAppendPropertyPath()
562 {
563 $context = $this->getMockExecutionContext();
564 $object = $this->getMock('\stdClass');
565 $form = $this->getBuilder('name', '\stdClass')
566 ->setData($object)
567 ->getForm();
568
569 $context->expects($this->once())
570 ->method('validate')
571 ->with($object, 'data', 'Default', true);
572
573 $this->validator->initialize($context);
574 $this->validator->validate($form, new Form());
575 }
576
577 public function testDontWalkScalars()
578 {
579 $context = $this->getMockExecutionContext();
580
581 $form = $this->getBuilder()
582 ->setData('scalar')
583 ->getForm();
584
585 $context->expects($this->never())
586 ->method('validate');
587
588 $this->validator->initialize($context);
589 $this->validator->validate($form, new Form());
590 }
591
592 public function testViolationIfExtraData()
593 {
594 $context = $this->getMockExecutionContext();
595
596 $form = $this->getBuilder('parent', null, array('extra_fields_message' => 'Extra!'))
597 ->setCompound(true)
598 ->setDataMapper($this->getDataMapper())
599 ->add($this->getBuilder('child'))
600 ->getForm();
601
602 $form->submit(array('foo' => 'bar'));
603
604 $context->expects($this->once())
605 ->method('addViolation')
606 ->with(
607 'Extra!',
608 array('{{ extra_fields }}' => 'foo'),
609 array('foo' => 'bar')
610 );
611 $context->expects($this->never())
612 ->method('addViolationAt');
613
614 $this->validator->initialize($context);
615 $this->validator->validate($form, new Form());
616 }
617
618 /**
619 * @dataProvider getPostMaxSizeFixtures
620 */
621 public function testPostMaxSizeViolation($contentLength, $iniMax, $nbViolation, array $params = array())
622 {
623 $this->serverParams->expects($this->once())
624 ->method('getContentLength')
625 ->will($this->returnValue($contentLength));
626 $this->serverParams->expects($this->any())
627 ->method('getNormalizedIniPostMaxSize')
628 ->will($this->returnValue($iniMax));
629
630 $context = $this->getMockExecutionContext();
631 $options = array('post_max_size_message' => 'Max {{ max }}!');
632 $form = $this->getBuilder('name', null, $options)->getForm();
633
634 for ($i = 0; $i < $nbViolation; ++$i) {
635 if (0 === $i && count($params) > 0) {
636 $context->expects($this->at($i))
637 ->method('addViolation')
638 ->with($options['post_max_size_message'], $params);
639 } else {
640 $context->expects($this->at($i))
641 ->method('addViolation');
642 }
643 }
644
645 $context->expects($this->never())
646 ->method('addViolationAt');
647
648 $this->validator->initialize($context);
649 $this->validator->validate($form, new Form());
650 }
651
652 public function getPostMaxSizeFixtures()
653 {
654 return array(
655 array(pow(1024, 3) + 1, '1G', 1, array('{{ max }}' => '1G')),
656 array(pow(1024, 3), '1G', 0),
657 array(pow(1024, 2) + 1, '1M', 1, array('{{ max }}' => '1M')),
658 array(pow(1024, 2), '1M', 0),
659 array(1024 + 1, '1K', 1, array('{{ max }}' => '1K')),
660 array(1024, '1K', 0),
661 array(null, '1K', 0),
662 array(1024, '', 0),
663 array(1024, 0, 0),
664 );
665 }
666
667 public function testNoViolationIfNotRoot()
668 {
669 $this->serverParams->expects($this->once())
670 ->method('getContentLength')
671 ->will($this->returnValue(1025));
672 $this->serverParams->expects($this->never())
673 ->method('getNormalizedIniPostMaxSize');
674
675 $context = $this->getMockExecutionContext();
676 $parent = $this->getBuilder()
677 ->setCompound(true)
678 ->setDataMapper($this->getDataMapper())
679 ->getForm();
680 $form = $this->getForm();
681 $parent->add($form);
682
683 $context->expects($this->never())
684 ->method('addViolation');
685 $context->expects($this->never())
686 ->method('addViolationAt');
687
688 $this->validator->initialize($context);
689 $this->validator->validate($form, new Form());
690 }
691
692 /**
693 * Access has to be public, as this method is called via callback array
694 * in {@link testValidateFormDataCanHandleCallbackValidationGroups()}
695 * and {@link testValidateFormDataUsesInheritedCallbackValidationGroup()}
696 */
697 public function getValidationGroups(FormInterface $form)
698 {
699 return array('group1', 'group2');
700 }
701
702 private function getMockExecutionContext()
703 {
704 return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface');
705 }
706
707 /**
708 * @param string $name
709 * @param string $dataClass
710 * @param array $options
711 *
712 * @return FormBuilder
713 */
714 private function getBuilder($name = 'name', $dataClass = null, array $options = array())
715 {
716 $options = array_replace(array(
717 'constraints' => array(),
718 'invalid_message_parameters' => array(),
719 ), $options);
720
721 return new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory, $options);
722 }
723
724 private function getForm($name = 'name', $dataClass = null, array $options = array())
725 {
726 return $this->getBuilder($name, $dataClass, $options)->getForm();
727 }
728
729 private function getSubmitButton($name = 'name', array $options = array())
730 {
731 $builder = new SubmitButtonBuilder($name, $options);
732
733 return $builder->getForm();
734 }
735
736 private function getClickedSubmitButton($name = 'name', array $options = array())
737 {
738 return $this->getSubmitButton($name, $options)->submit('');
739 }
740
741 /**
742 * @return \PHPUnit_Framework_MockObject_MockObject
743 */
744 private function getDataMapper()
745 {
746 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
747 }
748}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php
deleted file mode 100644
index 528f9463..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php
+++ /dev/null
@@ -1,145 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\EventListener;
13
14use Symfony\Component\Form\FormBuilder;
15use Symfony\Component\Form\FormEvent;
16use Symfony\Component\Form\Extension\Validator\Constraints\Form;
17use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener;
18use Symfony\Component\PropertyAccess\PropertyPath;
19use Symfony\Component\Validator\ConstraintViolation;
20
21class ValidationListenerTest extends \PHPUnit_Framework_TestCase
22{
23 /**
24 * @var \PHPUnit_Framework_MockObject_MockObject
25 */
26 private $dispatcher;
27
28 /**
29 * @var \PHPUnit_Framework_MockObject_MockObject
30 */
31 private $factory;
32
33 /**
34 * @var \PHPUnit_Framework_MockObject_MockObject
35 */
36 private $validator;
37
38 /**
39 * @var \PHPUnit_Framework_MockObject_MockObject
40 */
41 private $violationMapper;
42
43 /**
44 * @var ValidationListener
45 */
46 private $listener;
47
48 private $message;
49
50 private $messageTemplate;
51
52 private $params;
53
54 protected function setUp()
55 {
56 if (!class_exists('Symfony\Component\EventDispatcher\Event')) {
57 $this->markTestSkipped('The "EventDispatcher" component is not available');
58 }
59
60 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
61 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
62 $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
63 $this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface');
64 $this->listener = new ValidationListener($this->validator, $this->violationMapper);
65 $this->message = 'Message';
66 $this->messageTemplate = 'Message template';
67 $this->params = array('foo' => 'bar');
68 }
69
70 private function getConstraintViolation($code = null)
71 {
72 return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, 'prop.path', null, null, $code);
73 }
74
75 private function getBuilder($name = 'name', $propertyPath = null, $dataClass = null)
76 {
77 $builder = new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory);
78 $builder->setPropertyPath(new PropertyPath($propertyPath ?: $name));
79 $builder->setAttribute('error_mapping', array());
80 $builder->setErrorBubbling(false);
81 $builder->setMapped(true);
82
83 return $builder;
84 }
85
86 private function getForm($name = 'name', $propertyPath = null, $dataClass = null)
87 {
88 return $this->getBuilder($name, $propertyPath, $dataClass)->getForm();
89 }
90
91 private function getMockForm()
92 {
93 return $this->getMock('Symfony\Component\Form\Test\FormInterface');
94 }
95
96 // More specific mapping tests can be found in ViolationMapperTest
97 public function testMapViolation()
98 {
99 $violation = $this->getConstraintViolation();
100 $form = $this->getForm('street');
101
102 $this->validator->expects($this->once())
103 ->method('validate')
104 ->will($this->returnValue(array($violation)));
105
106 $this->violationMapper->expects($this->once())
107 ->method('mapViolation')
108 ->with($violation, $form, false);
109
110 $this->listener->validateForm(new FormEvent($form, null));
111 }
112
113 public function testMapViolationAllowsNonSyncIfInvalid()
114 {
115 $violation = $this->getConstraintViolation(Form::ERR_INVALID);
116 $form = $this->getForm('street');
117
118 $this->validator->expects($this->once())
119 ->method('validate')
120 ->will($this->returnValue(array($violation)));
121
122 $this->violationMapper->expects($this->once())
123 ->method('mapViolation')
124 // pass true now
125 ->with($violation, $form, true);
126
127 $this->listener->validateForm(new FormEvent($form, null));
128 }
129
130 public function testValidateIgnoresNonRoot()
131 {
132 $form = $this->getMockForm();
133 $form->expects($this->once())
134 ->method('isRoot')
135 ->will($this->returnValue(false));
136
137 $this->validator->expects($this->never())
138 ->method('validate');
139
140 $this->violationMapper->expects($this->never())
141 ->method('mapViolation');
142
143 $this->listener->validateForm(new FormEvent($form, null));
144 }
145}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
deleted file mode 100644
index 66194105..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php
+++ /dev/null
@@ -1,85 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
13
14use Symfony\Component\Form\FormInterface;
15
16class FormTypeValidatorExtensionTest extends TypeTestCase
17{
18 public function testValidationGroupNullByDefault()
19 {
20 $form = $this->factory->create('form');
21
22 $this->assertNull($form->getConfig()->getOption('validation_groups'));
23 }
24
25 public function testValidationGroupsTransformedToArray()
26 {
27 $form = $this->factory->create('form', null, array(
28 'validation_groups' => 'group',
29 ));
30
31 $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups'));
32 }
33
34 public function testValidationGroupsCanBeSetToArray()
35 {
36 $form = $this->factory->create('form', null, array(
37 'validation_groups' => array('group1', 'group2'),
38 ));
39
40 $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups'));
41 }
42
43 public function testValidationGroupsCanBeSetToFalse()
44 {
45 $form = $this->factory->create('form', null, array(
46 'validation_groups' => false,
47 ));
48
49 $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups'));
50 }
51
52 public function testValidationGroupsCanBeSetToCallback()
53 {
54 $form = $this->factory->create('form', null, array(
55 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'),
56 ));
57
58 $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
59 }
60
61 public function testValidationGroupsCanBeSetToClosure()
62 {
63 $form = $this->factory->create('form', null, array(
64 'validation_groups' => function(FormInterface $form){ return null; },
65 ));
66
67 $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups')));
68 }
69
70 public function testSubmitValidatesData()
71 {
72 $builder = $this->factory->createBuilder('form', null, array(
73 'validation_groups' => 'group',
74 ));
75 $builder->add('firstName', 'form');
76 $form = $builder->getForm();
77
78 $this->validator->expects($this->once())
79 ->method('validate')
80 ->with($this->equalTo($form));
81
82 // specific data is irrelevant
83 $form->submit(array());
84 }
85}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php
deleted file mode 100644
index d94d896a..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php
+++ /dev/null
@@ -1,49 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
13
14use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase;
15use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
16
17abstract class TypeTestCase extends BaseTypeTestCase
18{
19 protected $validator;
20
21 protected function setUp()
22 {
23 if (!class_exists('Symfony\Component\Validator\Constraint')) {
24 $this->markTestSkipped('The "Validator" component is not available');
25 }
26
27 $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface');
28 $metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface');
29 $this->validator->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
30 $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
31 $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata));
32
33 parent::setUp();
34 }
35
36 protected function tearDown()
37 {
38 $this->validator = null;
39
40 parent::tearDown();
41 }
42
43 protected function getExtensions()
44 {
45 return array_merge(parent::getExtensions(), array(
46 new ValidatorExtension($this->validator),
47 ));
48 }
49}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php
deleted file mode 100644
index 7ad5b771..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\Util;
13
14class ServerParamsTest extends \PHPUnit_Framework_TestCase
15{
16 /** @dataProvider getGetPostMaxSizeTestData */
17 public function testGetPostMaxSize($size, $bytes)
18 {
19 $serverParams = $this->getMock('Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize'));
20 $serverParams
21 ->expects($this->any())
22 ->method('getNormalizedIniPostMaxSize')
23 ->will($this->returnValue(strtoupper($size)));
24
25 $this->assertEquals($bytes, $serverParams->getPostMaxSize());
26 }
27
28 public function getGetPostMaxSizeTestData()
29 {
30 return array(
31 array('2k', 2048),
32 array('2 k', 2048),
33 array('8m', 8 * 1024 * 1024),
34 array('+2 k', 2048),
35 array('+2???k', 2048),
36 array('0x10', 16),
37 array('0xf', 15),
38 array('010', 8),
39 array('+0x10 k', 16 * 1024),
40 array('1g', 1024 * 1024 * 1024),
41 array('-1', -1),
42 array('0', 0),
43 array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm'
44 );
45 }
46}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
deleted file mode 100644
index c802ea7e..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
+++ /dev/null
@@ -1,1481 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper;
13
14use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
15use Symfony\Component\Form\Exception\TransformationFailedException;
16use Symfony\Component\Form\CallbackTransformer;
17use Symfony\Component\Form\Form;
18use Symfony\Component\Form\FormConfigBuilder;
19use Symfony\Component\Form\FormError;
20use Symfony\Component\PropertyAccess\PropertyPath;
21use Symfony\Component\Validator\ConstraintViolation;
22
23/**
24 * @author Bernhard Schussek <bschussek@gmail.com>
25 */
26class ViolationMapperTest extends \PHPUnit_Framework_TestCase
27{
28 const LEVEL_0 = 0;
29
30 const LEVEL_1 = 1;
31
32 const LEVEL_1B = 2;
33
34 const LEVEL_2 = 3;
35
36 /**
37 * @var \PHPUnit_Framework_MockObject_MockObject
38 */
39 private $dispatcher;
40
41 /**
42 * @var ViolationMapper
43 */
44 private $mapper;
45
46 /**
47 * @var string
48 */
49 private $message;
50
51 /**
52 * @var string
53 */
54 private $messageTemplate;
55
56 /**
57 * @var array
58 */
59 private $params;
60
61 protected function setUp()
62 {
63 if (!class_exists('Symfony\Component\EventDispatcher\Event')) {
64 $this->markTestSkipped('The "EventDispatcher" component is not available');
65 }
66
67 $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
68 $this->mapper = new ViolationMapper();
69 $this->message = 'Message';
70 $this->messageTemplate = 'Message template';
71 $this->params = array('foo' => 'bar');
72 }
73
74 protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $inheritData = false, $synchronized = true)
75 {
76 $config = new FormConfigBuilder($name, $dataClass, $this->dispatcher, array(
77 'error_mapping' => $errorMapping,
78 ));
79 $config->setMapped(true);
80 $config->setInheritData($inheritData);
81 $config->setPropertyPath($propertyPath);
82 $config->setCompound(true);
83 $config->setDataMapper($this->getDataMapper());
84
85 if (!$synchronized) {
86 $config->addViewTransformer(new CallbackTransformer(
87 function ($normData) { return $normData; },
88 function () { throw new TransformationFailedException(); }
89 ));
90 }
91
92 return new Form($config);
93 }
94
95 /**
96 * @return \PHPUnit_Framework_MockObject_MockObject
97 */
98 private function getDataMapper()
99 {
100 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
101 }
102
103 /**
104 * @param $propertyPath
105 *
106 * @return ConstraintViolation
107 */
108 protected function getConstraintViolation($propertyPath)
109 {
110 return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, $propertyPath, null);
111 }
112
113 /**
114 * @return FormError
115 */
116 protected function getFormError()
117 {
118 return new FormError($this->message, $this->messageTemplate, $this->params);
119 }
120
121 public function testMapToFormInheritingParentDataIfDataDoesNotMatch()
122 {
123 $violation = $this->getConstraintViolation('children[address].data.foo');
124 $parent = $this->getForm('parent');
125 $child = $this->getForm('address', 'address', null, array(), true);
126 $grandChild = $this->getForm('street');
127
128 $parent->add($child);
129 $child->add($grandChild);
130
131 $this->mapper->mapViolation($violation, $parent);
132
133 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
134 $this->assertEquals(array($this->getFormError()), $child->getErrors(), $child->getName().' should have an error, but has none');
135 $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
136 }
137
138 public function testFollowDotRules()
139 {
140 $violation = $this->getConstraintViolation('data.foo');
141 $parent = $this->getForm('parent', null, null, array(
142 'foo' => 'address',
143 ));
144 $child = $this->getForm('address', null, null, array(
145 '.' => 'street',
146 ));
147 $grandChild = $this->getForm('street', null, null, array(
148 '.' => 'name',
149 ));
150 $grandGrandChild = $this->getForm('name');
151
152 $parent->add($child);
153 $child->add($grandChild);
154 $grandChild->add($grandGrandChild);
155
156 $this->mapper->mapViolation($violation, $parent);
157
158 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
159 $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
160 $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
161 $this->assertEquals(array($this->getFormError()), $grandGrandChild->getErrors(), $grandGrandChild->getName().' should have an error, but has none');
162 }
163
164 public function testAbortMappingIfNotSynchronized()
165 {
166 $violation = $this->getConstraintViolation('children[address].data.street');
167 $parent = $this->getForm('parent');
168 $child = $this->getForm('address', 'address', null, array(), false, false);
169 // even though "street" is synchronized, it should not have any errors
170 // due to its parent not being synchronized
171 $grandChild = $this->getForm('street' , 'street');
172
173 $parent->add($child);
174 $child->add($grandChild);
175
176 // submit to invoke the transformer and mark the form unsynchronized
177 $parent->submit(array());
178
179 $this->mapper->mapViolation($violation, $parent);
180
181 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
182 $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
183 $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
184 }
185
186 public function testAbortDotRuleMappingIfNotSynchronized()
187 {
188 $violation = $this->getConstraintViolation('data.address');
189 $parent = $this->getForm('parent');
190 $child = $this->getForm('address', 'address', null, array(
191 '.' => 'street',
192 ), false, false);
193 // even though "street" is synchronized, it should not have any errors
194 // due to its parent not being synchronized
195 $grandChild = $this->getForm('street');
196
197 $parent->add($child);
198 $child->add($grandChild);
199
200 // submit to invoke the transformer and mark the form unsynchronized
201 $parent->submit(array());
202
203 $this->mapper->mapViolation($violation, $parent);
204
205 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
206 $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one');
207 $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one');
208 }
209
210 public function provideDefaultTests()
211 {
212 // The mapping must be deterministic! If a child has the property path "[street]",
213 // "data[street]" should be mapped, but "data.street" should not!
214 return array(
215 // mapping target, child name, its property path, grand child name, its property path, violation path
216 array(self::LEVEL_0, 'address', 'address', 'street', 'street', ''),
217 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data'),
218
219 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'),
220 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'),
221 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data'),
222 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'),
223 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'),
224 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'),
225 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'),
226 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street'),
227 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street.prop'),
228 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street]'),
229 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street].prop'),
230 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'),
231 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'),
232 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'),
233 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'),
234
235 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data'),
236 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'),
237 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data'),
238 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street'),
239 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'),
240 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
241 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'),
242 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street'),
243 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street.prop'),
244 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street]'),
245 array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street].prop'),
246 array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street'),
247 array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street.prop'),
248 array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street]'),
249 array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street].prop'),
250
251 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data'),
252 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'),
253 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data'),
254 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street'),
255 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'),
256 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
257 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'),
258 array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street'),
259 array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street.prop'),
260 array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street]'),
261 array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street].prop'),
262 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street'),
263 array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street.prop'),
264 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street]'),
265 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street].prop'),
266
267 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'),
268 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'),
269 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data'),
270 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
271 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'),
272 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
273 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'),
274 array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street'),
275 array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street.prop'),
276 array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street]'),
277 array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street].prop'),
278 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street'),
279 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street.prop'),
280 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street]'),
281 array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street].prop'),
282
283 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data'),
284 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data.prop'),
285 array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data'),
286 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street'),
287 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street.prop'),
288 array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street]'),
289 array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street].prop'),
290 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street'),
291 array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street.prop'),
292 array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street]'),
293 array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street].prop'),
294 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street'),
295 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street.prop'),
296 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street]'),
297 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street].prop'),
298 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street'),
299 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street.prop'),
300 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street]'),
301 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street].prop'),
302 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street'),
303 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street.prop'),
304 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street]'),
305 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street].prop'),
306
307 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data'),
308 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data.prop'),
309 array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data'),
310 array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street'),
311 array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street.prop'),
312 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street]'),
313 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street].prop'),
314 array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street'),
315 array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street.prop'),
316 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street]'),
317 array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street].prop'),
318 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street'),
319 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street.prop'),
320 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street]'),
321 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street].prop'),
322 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street'),
323 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street.prop'),
324 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street]'),
325 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street].prop'),
326 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street'),
327 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street.prop'),
328 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street]'),
329 array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street].prop'),
330
331 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data'),
332 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data.prop'),
333 array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data'),
334 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street'),
335 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street.prop'),
336 array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street]'),
337 array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street].prop'),
338 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street'),
339 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street.prop'),
340 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street]'),
341 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street].prop'),
342 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street'),
343 array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street.prop'),
344 array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street]'),
345 array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street].prop'),
346 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street'),
347 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street.prop'),
348 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street]'),
349 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street].prop'),
350 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street'),
351 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street.prop'),
352 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street]'),
353 array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street].prop'),
354
355 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data'),
356 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data.prop'),
357 array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data'),
358 array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street'),
359 array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street.prop'),
360 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street]'),
361 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street].prop'),
362 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street'),
363 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street.prop'),
364 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street]'),
365 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street].prop'),
366 array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street'),
367 array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street.prop'),
368 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street]'),
369 array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street].prop'),
370 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street'),
371 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street.prop'),
372 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street]'),
373 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street].prop'),
374 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street'),
375 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street.prop'),
376 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street]'),
377 array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street].prop'),
378
379 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data'),
380 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data.prop'),
381 array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data'),
382 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street'),
383 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street.prop'),
384 array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street]'),
385 array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street].prop'),
386 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street'),
387 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street.prop'),
388 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street]'),
389 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street].prop'),
390 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street'),
391 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street.prop'),
392 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street]'),
393 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street].prop'),
394 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street'),
395 array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street.prop'),
396 array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street]'),
397 array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street].prop'),
398 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street'),
399 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street.prop'),
400 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street]'),
401 array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street].prop'),
402
403 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data'),
404 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data.prop'),
405 array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data'),
406 array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street'),
407 array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street.prop'),
408 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street]'),
409 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street].prop'),
410 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street'),
411 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street.prop'),
412 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street]'),
413 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street].prop'),
414 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street'),
415 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street.prop'),
416 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street]'),
417 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street].prop'),
418 array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street'),
419 array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street.prop'),
420 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street]'),
421 array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street].prop'),
422 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street'),
423 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street.prop'),
424 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street]'),
425 array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street].prop'),
426
427 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data'),
428 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data.prop'),
429 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address]'),
430 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data'),
431 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street'),
432 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street.prop'),
433 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street]'),
434 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street].prop'),
435 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street'),
436 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street.prop'),
437 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street]'),
438 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street].prop'),
439 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street'),
440 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street.prop'),
441 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street]'),
442 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street].prop'),
443 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street'),
444 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street.prop'),
445 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street]'),
446 array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street].prop'),
447 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street'),
448 array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street.prop'),
449 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street]'),
450 array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street].prop'),
451
452 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data'),
453 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data.prop'),
454 array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data'),
455 array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street'),
456 array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street.prop'),
457 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street]'),
458 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street].prop'),
459 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street'),
460 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street.prop'),
461 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street]'),
462 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street].prop'),
463 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street'),
464 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street.prop'),
465 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street]'),
466 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street].prop'),
467 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street'),
468 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street.prop'),
469 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street]'),
470 array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street].prop'),
471 array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street'),
472 array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street.prop'),
473 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street]'),
474 array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street].prop'),
475
476 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data'),
477 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data.prop'),
478 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data'),
479 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office'),
480 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street'),
481 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street.prop'),
482 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street]'),
483 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street].prop'),
484 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office]'),
485 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street'),
486 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street.prop'),
487 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street]'),
488 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street].prop'),
489 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street'),
490 array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street.prop'),
491 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street]'),
492 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street].prop'),
493 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street'),
494 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street.prop'),
495 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street]'),
496 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street].prop'),
497 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street'),
498 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street.prop'),
499 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street]'),
500 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street].prop'),
501 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street'),
502 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street.prop'),
503 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street]'),
504 array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street].prop'),
505
506 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data'),
507 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data.prop'),
508 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data'),
509 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office'),
510 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street'),
511 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street.prop'),
512 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street]'),
513 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street].prop'),
514 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office]'),
515 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street'),
516 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street.prop'),
517 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street]'),
518 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street].prop'),
519 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street'),
520 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street.prop'),
521 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street]'),
522 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street].prop'),
523 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street'),
524 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street.prop'),
525 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street]'),
526 array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street].prop'),
527 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street'),
528 array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street.prop'),
529 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street]'),
530 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street].prop'),
531 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street'),
532 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street.prop'),
533 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street]'),
534 array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street].prop'),
535
536 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data'),
537 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data.prop'),
538 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data'),
539 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office'),
540 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street'),
541 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street.prop'),
542 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street]'),
543 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street].prop'),
544 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office]'),
545 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street'),
546 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street.prop'),
547 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street]'),
548 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street].prop'),
549 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street'),
550 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street.prop'),
551 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street]'),
552 array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street].prop'),
553 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street'),
554 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street.prop'),
555 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street]'),
556 array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street].prop'),
557 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street'),
558 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street.prop'),
559 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street]'),
560 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street].prop'),
561 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street'),
562 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street.prop'),
563 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street]'),
564 array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street].prop'),
565
566 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data'),
567 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data.prop'),
568 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street'),
569 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street.prop'),
570 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street]'),
571 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street].prop'),
572 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office]'),
573 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street'),
574 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street.prop'),
575 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street]'),
576 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street].prop'),
577 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street'),
578 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street.prop'),
579 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street]'),
580 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street].prop'),
581 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street'),
582 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street.prop'),
583 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street]'),
584 array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street].prop'),
585 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street'),
586 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street.prop'),
587 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street]'),
588 array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street].prop'),
589 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street'),
590 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street.prop'),
591 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street]'),
592 array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street].prop'),
593
594 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data'),
595 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data.prop'),
596 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data'),
597 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office'),
598 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street'),
599 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street.prop'),
600 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street]'),
601 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street].prop'),
602 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office]'),
603 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street'),
604 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street.prop'),
605 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street]'),
606 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street].prop'),
607 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street'),
608 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street.prop'),
609 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street]'),
610 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street].prop'),
611 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street'),
612 array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street.prop'),
613 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street]'),
614 array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street].prop'),
615 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street'),
616 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street.prop'),
617 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street]'),
618 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street].prop'),
619 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street'),
620 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street.prop'),
621 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street]'),
622 array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street].prop'),
623
624 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data'),
625 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data.prop'),
626 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data'),
627 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office'),
628 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street'),
629 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street.prop'),
630 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street]'),
631 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street].prop'),
632 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office]'),
633 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street'),
634 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street.prop'),
635 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street]'),
636 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street].prop'),
637 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street'),
638 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street.prop'),
639 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street]'),
640 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street].prop'),
641 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street'),
642 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street.prop'),
643 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street]'),
644 array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street].prop'),
645 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street'),
646 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street.prop'),
647 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street]'),
648 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street].prop'),
649 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street'),
650 array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street.prop'),
651 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street]'),
652 array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street].prop'),
653
654 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data'),
655 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data.prop'),
656 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data'),
657 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office'),
658 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street'),
659 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street.prop'),
660 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street]'),
661 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street].prop'),
662 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office]'),
663 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street'),
664 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street.prop'),
665 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street]'),
666 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street].prop'),
667 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street'),
668 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street.prop'),
669 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street]'),
670 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street].prop'),
671 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street'),
672 array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street.prop'),
673 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street]'),
674 array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street].prop'),
675 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street'),
676 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street.prop'),
677 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street]'),
678 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street].prop'),
679 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street'),
680 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street.prop'),
681 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street]'),
682 array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street].prop'),
683
684 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data'),
685 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data.prop'),
686 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data'),
687 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office'),
688 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street'),
689 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street.prop'),
690 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street]'),
691 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street].prop'),
692 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office]'),
693 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street'),
694 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street.prop'),
695 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street]'),
696 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street].prop'),
697 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street'),
698 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street.prop'),
699 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street]'),
700 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street].prop'),
701 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street'),
702 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street.prop'),
703 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street]'),
704 array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street].prop'),
705 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street'),
706 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street.prop'),
707 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street]'),
708 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street].prop'),
709 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street'),
710 array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street.prop'),
711 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street]'),
712 array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street].prop'),
713
714 // Edge cases which must not occur
715 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street]'),
716 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street].prop'),
717 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street]'),
718 array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street].prop'),
719 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street]'),
720 array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street].prop'),
721 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street]'),
722 array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street].prop'),
723
724 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].children[street]'),
725 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].data.street'),
726 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].data.address.street'),
727 array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.address.street'),
728
729 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].children[street]'),
730 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].data.street'),
731 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.street'),
732 array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.street'),
733 );
734 }
735
736 /**
737 * @dataProvider provideDefaultTests
738 */
739 public function testDefaultErrorMapping($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath)
740 {
741 $violation = $this->getConstraintViolation($violationPath);
742 $parent = $this->getForm('parent');
743 $child = $this->getForm($childName, $childPath);
744 $grandChild = $this->getForm($grandChildName, $grandChildPath);
745
746 $parent->add($child);
747 $child->add($grandChild);
748
749 $this->mapper->mapViolation($violation, $parent);
750
751 if (self::LEVEL_0 === $target) {
752 $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none');
753 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
754 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
755 } elseif (self::LEVEL_1 === $target) {
756 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
757 $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none');
758 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
759 } else {
760 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
761 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
762 $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none');
763 }
764 }
765
766 public function provideCustomDataErrorTests()
767 {
768 return array(
769 // mapping target, error mapping, child name, its property path, grand child name, its property path, violation path
770 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo'),
771 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'),
772 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo]'),
773 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'),
774
775 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address'),
776 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'),
777 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address]'),
778 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'),
779
780 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo'),
781 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'),
782 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'),
783 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'),
784
785 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address'),
786 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'),
787 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address]'),
788 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'),
789
790 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo'),
791 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'),
792 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo]'),
793 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'),
794
795 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address'),
796 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'),
797 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address]'),
798 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'),
799
800 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo'),
801 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'),
802 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'),
803 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'),
804
805 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address'),
806 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'),
807 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address]'),
808 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'),
809
810 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'),
811 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'),
812 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'),
813 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'),
814 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'),
815 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'),
816 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'),
817 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'),
818
819 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street'),
820 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'),
821 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'),
822 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'),
823 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street'),
824 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'),
825 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'),
826 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'),
827
828 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'),
829 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'),
830 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'),
831 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'),
832 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'),
833 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'),
834 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'),
835 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'),
836
837 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'),
838 array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'),
839 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'),
840 array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'),
841 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'),
842 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'),
843 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'),
844 array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'),
845
846 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'),
847 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'),
848 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'),
849 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'),
850 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'),
851 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'),
852 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'),
853 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'),
854
855 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'),
856 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'),
857 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'),
858 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'),
859 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'),
860 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'),
861 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'),
862 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'),
863
864 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'),
865 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'),
866 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'),
867 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'),
868 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'),
869 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'),
870 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'),
871 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'),
872
873 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'),
874 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'),
875 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'),
876 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'),
877 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'),
878 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'),
879 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'),
880 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'),
881
882 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'),
883 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'),
884 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'),
885 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'),
886 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'),
887 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'),
888 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'),
889 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'),
890
891 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street'),
892 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'),
893 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'),
894 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'),
895 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street'),
896 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'),
897 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'),
898 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'),
899
900 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'),
901 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'),
902 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'),
903 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'),
904 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'),
905 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'),
906 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'),
907 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'),
908
909 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'),
910 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'),
911 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'),
912 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'),
913 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'),
914 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'),
915 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'),
916 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'),
917
918 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'),
919 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'),
920 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'),
921 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'),
922 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'),
923 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'),
924 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'),
925 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'),
926
927 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'),
928 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'),
929 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'),
930 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'),
931 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'),
932 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'),
933 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'),
934 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'),
935
936 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'),
937 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'),
938 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'),
939 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'),
940 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'),
941 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'),
942 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'),
943 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'),
944
945 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'),
946 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'),
947 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'),
948 array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'),
949 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'),
950 array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'),
951 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'),
952 array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'),
953
954 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'),
955 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'),
956 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'),
957 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'),
958 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'),
959 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'),
960 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'),
961 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'),
962
963 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'),
964 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'),
965 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'),
966 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'),
967 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'),
968 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'),
969 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'),
970 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'),
971
972 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'),
973 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'),
974 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'),
975 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'),
976 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'),
977 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'),
978 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'),
979 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'),
980
981 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'),
982 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'),
983 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'),
984 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'),
985 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'),
986 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'),
987 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'),
988 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'),
989
990 array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'),
991 array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'),
992 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'),
993 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'),
994 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'),
995 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'),
996 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'),
997 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'),
998 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'),
999 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'),
1000 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'),
1001 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'),
1002 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'),
1003 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'),
1004 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'),
1005 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'),
1006
1007 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'),
1008 array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'),
1009 array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'),
1010 array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'),
1011 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'),
1012 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'),
1013 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'),
1014 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'),
1015 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'),
1016 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'),
1017 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'),
1018 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'),
1019 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'),
1020 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'),
1021 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'),
1022 array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'),
1023
1024 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'),
1025 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'),
1026 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'),
1027 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'),
1028 array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'),
1029 array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'),
1030 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'),
1031 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'),
1032 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'),
1033 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'),
1034 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'),
1035 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'),
1036 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'),
1037 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'),
1038 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'),
1039 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'),
1040
1041 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'),
1042 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'),
1043 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'),
1044 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'),
1045 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'),
1046 array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'),
1047 array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'),
1048 array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'),
1049 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'),
1050 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'),
1051 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'),
1052 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'),
1053 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'),
1054 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'),
1055 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'),
1056 array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'),
1057
1058 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'),
1059 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'),
1060 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'),
1061 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'),
1062 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'),
1063 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'),
1064 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'),
1065 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'),
1066 array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'),
1067 array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'),
1068 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'),
1069 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'),
1070 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'),
1071 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'),
1072 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'),
1073 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'),
1074
1075 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'),
1076 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'),
1077 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'),
1078 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'),
1079 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'),
1080 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'),
1081 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'),
1082 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'),
1083 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'),
1084 array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'),
1085 array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'),
1086 array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'),
1087 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'),
1088 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'),
1089 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'),
1090 array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'),
1091
1092 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'),
1093 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'),
1094 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'),
1095 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'),
1096 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'),
1097 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'),
1098 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'),
1099 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'),
1100 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'),
1101 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'),
1102 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'),
1103 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'),
1104 array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'),
1105 array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'),
1106 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'),
1107 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'),
1108
1109 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'),
1110 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'),
1111 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'),
1112 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'),
1113 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'),
1114 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'),
1115 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'),
1116 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'),
1117 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'),
1118 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'),
1119 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'),
1120 array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'),
1121 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'),
1122 array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'),
1123 array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'),
1124 array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'),
1125
1126 array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo'),
1127 array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.prop'),
1128 array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo]'),
1129 array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].prop'),
1130
1131 array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo'),
1132 array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.prop'),
1133 array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo]'),
1134 array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].prop'),
1135
1136 array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo'),
1137 array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.prop'),
1138 array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo]'),
1139 array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].prop'),
1140
1141 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar'),
1142 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'),
1143 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar]'),
1144 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'),
1145 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar'),
1146 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'),
1147 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar]'),
1148 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'),
1149
1150 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar'),
1151 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar.prop'),
1152 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar]'),
1153 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar].prop'),
1154 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar'),
1155 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar.prop'),
1156 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar]'),
1157 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar].prop'),
1158
1159 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar'),
1160 array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar.prop'),
1161 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar]'),
1162 array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar].prop'),
1163 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar'),
1164 array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar.prop'),
1165 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar]'),
1166 array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar].prop'),
1167
1168 // Edge cases
1169 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'),
1170 array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'),
1171 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'),
1172 array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'),
1173 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'),
1174 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'),
1175 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'),
1176 array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'),
1177
1178 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'),
1179 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'),
1180 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'),
1181 array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'),
1182 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'),
1183 array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'),
1184 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'),
1185 array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'),
1186 );
1187 }
1188
1189 /**
1190 * @dataProvider provideCustomDataErrorTests
1191 */
1192 public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath)
1193 {
1194 $violation = $this->getConstraintViolation($violationPath);
1195 $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo));
1196 $child = $this->getForm($childName, $childPath);
1197 $grandChild = $this->getForm($grandChildName, $grandChildPath);
1198
1199 $parent->add($child);
1200 $child->add($grandChild);
1201
1202 // Add a field mapped to the first element of $mapFrom
1203 // to try to distract the algorithm
1204 // Only add it if we expect the error to come up on a different
1205 // level than LEVEL_0, because in this case the error would
1206 // (correctly) be mapped to the distraction field
1207 if ($target !== self::LEVEL_0) {
1208 $mapFromPath = new PropertyPath($mapFrom);
1209 $mapFromPrefix = $mapFromPath->isIndex(0)
1210 ? '['.$mapFromPath->getElement(0).']'
1211 : $mapFromPath->getElement(0);
1212 $distraction = $this->getForm('distraction', $mapFromPrefix);
1213
1214 $parent->add($distraction);
1215 }
1216
1217 $this->mapper->mapViolation($violation, $parent);
1218
1219 if ($target !== self::LEVEL_0) {
1220 $this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one');
1221 }
1222
1223 if (self::LEVEL_0 === $target) {
1224 $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none');
1225 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1226 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1227 } elseif (self::LEVEL_1 === $target) {
1228 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1229 $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none');
1230 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1231 } else {
1232 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1233 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1234 $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none');
1235 }
1236 }
1237
1238 public function provideCustomFormErrorTests()
1239 {
1240 // This case is different than the data errors, because here the
1241 // left side of the mapping refers to the property path of the actual
1242 // children. In other words, a child error only works if
1243 // 1) the error actually maps to an existing child and
1244 // 2) the property path of that child (relative to the form providing
1245 // the mapping) matches the left side of the mapping
1246 return array(
1247 // mapping target, map from, map to, child name, its property path, grand child name, its property path, violation path
1248 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'),
1249 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'),
1250 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'),
1251 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'),
1252 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'),
1253 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'),
1254
1255 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data'),
1256 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'),
1257 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'),
1258 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street.prop'),
1259 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1260 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street].prop'),
1261
1262 // Property path of the erroneous field and mapping must match exactly
1263 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'),
1264 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'),
1265 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'),
1266 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'),
1267 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'),
1268 array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'),
1269
1270 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'),
1271 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'),
1272 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'),
1273 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'),
1274 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'),
1275 array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'),
1276
1277 array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'),
1278 array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'),
1279 array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'),
1280 array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'),
1281 array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'),
1282 array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'),
1283
1284 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data'),
1285 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data.prop'),
1286 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street'),
1287 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street.prop'),
1288 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street]'),
1289 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street].prop'),
1290
1291 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data'),
1292 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'),
1293 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'),
1294 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'),
1295 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
1296 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'),
1297
1298 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data'),
1299 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data.prop'),
1300 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street'),
1301 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street.prop'),
1302 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street]'),
1303 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street].prop'),
1304
1305 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data'),
1306 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'),
1307 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'),
1308 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'),
1309 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
1310 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'),
1311
1312 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data'),
1313 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data.prop'),
1314 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street'),
1315 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street.prop'),
1316 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street]'),
1317 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street].prop'),
1318
1319 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'),
1320 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'),
1321 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
1322 array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'),
1323 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
1324 array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'),
1325
1326 // Map to a nested child
1327 array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo]'),
1328 array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo]'),
1329 array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo]'),
1330 array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo]'),
1331
1332 // Map from a nested child
1333 array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'),
1334 array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'),
1335 array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1336 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'),
1337 array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'),
1338 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
1339 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'),
1340 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'),
1341 array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
1342 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'),
1343 array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
1344 array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
1345
1346 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'),
1347 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'),
1348 array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1349 array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'),
1350 array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'),
1351 array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
1352 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'),
1353 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'),
1354 array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
1355 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'),
1356 array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
1357 array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
1358
1359 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'),
1360 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'),
1361 array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1362 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'),
1363 array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'),
1364 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
1365 array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'),
1366 array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'),
1367 array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
1368 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'),
1369 array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
1370 array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
1371
1372 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'),
1373 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'),
1374 array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1375 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'),
1376 array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'),
1377 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'),
1378 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'),
1379 array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'),
1380 array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'),
1381 array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'),
1382 array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'),
1383 array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'),
1384 );
1385 }
1386
1387 /**
1388 * @dataProvider provideCustomFormErrorTests
1389 */
1390 public function testCustomFormErrorMapping($target, $mapFrom, $mapTo, $errorName, $errorPath, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath)
1391 {
1392 $violation = $this->getConstraintViolation($violationPath);
1393 $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo));
1394 $child = $this->getForm($childName, $childPath);
1395 $grandChild = $this->getForm($grandChildName, $grandChildPath);
1396 $errorChild = $this->getForm($errorName, $errorPath);
1397
1398 $parent->add($child);
1399 $parent->add($errorChild);
1400 $child->add($grandChild);
1401
1402 $this->mapper->mapViolation($violation, $parent);
1403
1404 if (self::LEVEL_0 === $target) {
1405 $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one');
1406 $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none');
1407 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1408 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1409 } elseif (self::LEVEL_1 === $target) {
1410 $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one');
1411 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1412 $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none');
1413 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1414 } elseif (self::LEVEL_1B === $target) {
1415 $this->assertEquals(array($this->getFormError()), $errorChild->getErrors(), $errorName.' should have an error, but has none');
1416 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1417 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1418 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1419 } else {
1420 $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one');
1421 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1422 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1423 $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none');
1424 }
1425 }
1426
1427 public function provideErrorTestsForFormInheritingParentData()
1428 {
1429 return array(
1430 // mapping target, child name, its property path, grand child name, its property path, violation path
1431 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'),
1432 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'),
1433 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'),
1434 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'),
1435 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'),
1436 array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'),
1437 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street'),
1438 array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street.prop'),
1439 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street]'),
1440 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street].prop'),
1441 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street'),
1442 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street.prop'),
1443 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street]'),
1444 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street].prop'),
1445 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'),
1446 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'),
1447 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'),
1448 array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'),
1449 );
1450 }
1451
1452 /**
1453 * @dataProvider provideErrorTestsForFormInheritingParentData
1454 */
1455 public function testErrorMappingForFormInheritingParentData($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath)
1456 {
1457 $violation = $this->getConstraintViolation($violationPath);
1458 $parent = $this->getForm('parent');
1459 $child = $this->getForm($childName, $childPath, null, array(), true);
1460 $grandChild = $this->getForm($grandChildName, $grandChildPath);
1461
1462 $parent->add($child);
1463 $child->add($grandChild);
1464
1465 $this->mapper->mapViolation($violation, $parent);
1466
1467 if (self::LEVEL_0 === $target) {
1468 $this->assertEquals(array($this->getFormError()), $parent->getErrors(), $parent->getName().' should have an error, but has none');
1469 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1470 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1471 } elseif (self::LEVEL_1 === $target) {
1472 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1473 $this->assertEquals(array($this->getFormError()), $child->getErrors(), $childName.' should have an error, but has none');
1474 $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one');
1475 } else {
1476 $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one');
1477 $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one');
1478 $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none');
1479 }
1480 }
1481}
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php
deleted file mode 100644
index 02df8f43..00000000
--- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php
+++ /dev/null
@@ -1,245 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper;
13
14use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class ViolationPathTest extends \PHPUnit_Framework_TestCase
20{
21 public function providePaths()
22 {
23 return array(
24 array('children[address]', array(
25 array('address', true, true),
26 )),
27 array('children[address].children[street]', array(
28 array('address', true, true),
29 array('street', true, true),
30 )),
31 array('children[address][street]', array(
32 array('address', true, true),
33 ), 'children[address]'),
34 array('children[address].data', array(
35 array('address', true, true),
36 ), 'children[address]'),
37 array('children[address].data.street', array(
38 array('address', true, true),
39 array('street', false, false),
40 )),
41 array('children[address].data[street]', array(
42 array('address', true, true),
43 array('street', false, true),
44 )),
45 array('children[address].children[street].data.name', array(
46 array('address', true, true),
47 array('street', true, true),
48 array('name', false, false),
49 )),
50 array('children[address].children[street].data[name]', array(
51 array('address', true, true),
52 array('street', true, true),
53 array('name', false, true),
54 )),
55 array('data.address', array(
56 array('address', false, false),
57 )),
58 array('data[address]', array(
59 array('address', false, true),
60 )),
61 array('data.address.street', array(
62 array('address', false, false),
63 array('street', false, false),
64 )),
65 array('data[address].street', array(
66 array('address', false, true),
67 array('street', false, false),
68 )),
69 array('data.address[street]', array(
70 array('address', false, false),
71 array('street', false, true),
72 )),
73 array('data[address][street]', array(
74 array('address', false, true),
75 array('street', false, true),
76 )),
77 // A few invalid examples
78 array('data', array(), ''),
79 array('children', array(), ''),
80 array('children.address', array(), ''),
81 array('children.address[street]', array(), ''),
82 );
83 }
84
85 /**
86 * @dataProvider providePaths
87 */
88 public function testCreatePath($string, $entries, $slicedPath = null)
89 {
90 if (null === $slicedPath) {
91 $slicedPath = $string;
92 }
93
94 $path = new ViolationPath($string);
95
96 $this->assertSame($slicedPath, $path->__toString());
97 $this->assertSame(count($entries), count($path->getElements()));
98 $this->assertSame(count($entries), $path->getLength());
99
100 foreach ($entries as $index => $entry) {
101 $this->assertEquals($entry[0], $path->getElement($index));
102 $this->assertSame($entry[1], $path->mapsForm($index));
103 $this->assertSame($entry[2], $path->isIndex($index));
104 $this->assertSame(!$entry[2], $path->isProperty($index));
105 }
106 }
107
108 public function provideParents()
109 {
110 return array(
111 array('children[address]', null),
112 array('children[address].children[street]', 'children[address]'),
113 array('children[address].data.street', 'children[address]'),
114 array('children[address].data[street]', 'children[address]'),
115 array('data.address', null),
116 array('data.address.street', 'data.address'),
117 array('data.address[street]', 'data.address'),
118 array('data[address].street', 'data[address]'),
119 array('data[address][street]', 'data[address]'),
120 );
121 }
122
123 /**
124 * @dataProvider provideParents
125 */
126 public function testGetParent($violationPath, $parentPath)
127 {
128 $path = new ViolationPath($violationPath);
129 $parent = $parentPath === null ? null : new ViolationPath($parentPath);
130
131 $this->assertEquals($parent, $path->getParent());
132 }
133
134 public function testGetElement()
135 {
136 $path = new ViolationPath('children[address].data[street].name');
137
138 $this->assertEquals('street', $path->getElement(1));
139 }
140
141 /**
142 * @expectedException \OutOfBoundsException
143 */
144 public function testGetElementDoesNotAcceptInvalidIndices()
145 {
146 $path = new ViolationPath('children[address].data[street].name');
147
148 $path->getElement(3);
149 }
150
151 /**
152 * @expectedException \OutOfBoundsException
153 */
154 public function testGetElementDoesNotAcceptNegativeIndices()
155 {
156 $path = new ViolationPath('children[address].data[street].name');
157
158 $path->getElement(-1);
159 }
160
161 public function testIsProperty()
162 {
163 $path = new ViolationPath('children[address].data[street].name');
164
165 $this->assertFalse($path->isProperty(1));
166 $this->assertTrue($path->isProperty(2));
167 }
168
169 /**
170 * @expectedException \OutOfBoundsException
171 */
172 public function testIsPropertyDoesNotAcceptInvalidIndices()
173 {
174 $path = new ViolationPath('children[address].data[street].name');
175
176 $path->isProperty(3);
177 }
178
179 /**
180 * @expectedException \OutOfBoundsException
181 */
182 public function testIsPropertyDoesNotAcceptNegativeIndices()
183 {
184 $path = new ViolationPath('children[address].data[street].name');
185
186 $path->isProperty(-1);
187 }
188
189 public function testIsIndex()
190 {
191 $path = new ViolationPath('children[address].data[street].name');
192
193 $this->assertTrue($path->isIndex(1));
194 $this->assertFalse($path->isIndex(2));
195 }
196
197 /**
198 * @expectedException \OutOfBoundsException
199 */
200 public function testIsIndexDoesNotAcceptInvalidIndices()
201 {
202 $path = new ViolationPath('children[address].data[street].name');
203
204 $path->isIndex(3);
205 }
206
207 /**
208 * @expectedException \OutOfBoundsException
209 */
210 public function testIsIndexDoesNotAcceptNegativeIndices()
211 {
212 $path = new ViolationPath('children[address].data[street].name');
213
214 $path->isIndex(-1);
215 }
216
217 public function testMapsForm()
218 {
219 $path = new ViolationPath('children[address].data[street].name');
220
221 $this->assertTrue($path->mapsForm(0));
222 $this->assertFalse($path->mapsForm(1));
223 $this->assertFalse($path->mapsForm(2));
224 }
225
226 /**
227 * @expectedException \OutOfBoundsException
228 */
229 public function testMapsFormDoesNotAcceptInvalidIndices()
230 {
231 $path = new ViolationPath('children[address].data[street].name');
232
233 $path->mapsForm(3);
234 }
235
236 /**
237 * @expectedException \OutOfBoundsException
238 */
239 public function testMapsFormDoesNotAcceptNegativeIndices()
240 {
241 $path = new ViolationPath('children[address].data[street].name');
242
243 $path->mapsForm(-1);
244 }
245}