diff options
Diffstat (limited to 'vendor/symfony/options-resolver/Symfony')
14 files changed, 2553 insertions, 0 deletions
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/.gitignore b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/.gitignore new file mode 100644 index 00000000..44de97a3 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | vendor/ | ||
2 | composer.lock | ||
3 | phpunit.xml | ||
4 | |||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php new file mode 100644 index 00000000..4224f4e3 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/ExceptionInterface.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Exception; | ||
13 | |||
14 | /** | ||
15 | * Marker interface for the Options component. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | interface ExceptionInterface | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php new file mode 100644 index 00000000..2e7ea1bc --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Exception; | ||
13 | |||
14 | /** | ||
15 | * Exception thrown when an invalid option is passed. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class InvalidOptionsException extends \InvalidArgumentException implements ExceptionInterface | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php new file mode 100644 index 00000000..8544dfb2 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/MissingOptionsException.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Exception; | ||
13 | |||
14 | /** | ||
15 | * Exception thrown when a required option is missing. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class MissingOptionsException extends \InvalidArgumentException implements ExceptionInterface | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php new file mode 100644 index 00000000..11617fe1 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Exception/OptionDefinitionException.php | |||
@@ -0,0 +1,21 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Exception; | ||
13 | |||
14 | /** | ||
15 | * Thrown when an option definition is invalid. | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class OptionDefinitionException extends \RuntimeException implements ExceptionInterface | ||
20 | { | ||
21 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/LICENSE b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/LICENSE new file mode 100644 index 00000000..88a57f8d --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/LICENSE | |||
@@ -0,0 +1,19 @@ | |||
1 | Copyright (c) 2004-2013 Fabien Potencier | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
4 | of this software and associated documentation files (the "Software"), to deal | ||
5 | in the Software without restriction, including without limitation the rights | ||
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
7 | copies of the Software, and to permit persons to whom the Software is furnished | ||
8 | to do so, subject to the following conditions: | ||
9 | |||
10 | The above copyright notice and this permission notice shall be included in all | ||
11 | copies or substantial portions of the Software. | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
19 | THE SOFTWARE. | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Options.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Options.php new file mode 100644 index 00000000..5b958af4 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Options.php | |||
@@ -0,0 +1,513 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver; | ||
13 | |||
14 | use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; | ||
15 | |||
16 | /** | ||
17 | * Container for resolving inter-dependent options. | ||
18 | * | ||
19 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
20 | */ | ||
21 | class Options implements \ArrayAccess, \Iterator, \Countable | ||
22 | { | ||
23 | /** | ||
24 | * A list of option values. | ||
25 | * @var array | ||
26 | */ | ||
27 | private $options = array(); | ||
28 | |||
29 | /** | ||
30 | * A list of normalizer closures. | ||
31 | * @var array | ||
32 | */ | ||
33 | private $normalizers = array(); | ||
34 | |||
35 | /** | ||
36 | * A list of closures for evaluating lazy options. | ||
37 | * @var array | ||
38 | */ | ||
39 | private $lazy = array(); | ||
40 | |||
41 | /** | ||
42 | * A list containing the currently locked options. | ||
43 | * @var array | ||
44 | */ | ||
45 | private $lock = array(); | ||
46 | |||
47 | /** | ||
48 | * Whether at least one option has already been read. | ||
49 | * | ||
50 | * Once read, the options cannot be changed anymore. This is | ||
51 | * necessary in order to avoid inconsistencies during the resolving | ||
52 | * process. If any option is changed after being read, all evaluated | ||
53 | * lazy options that depend on this option would become invalid. | ||
54 | * | ||
55 | * @var Boolean | ||
56 | */ | ||
57 | private $reading = false; | ||
58 | |||
59 | /** | ||
60 | * Sets the value of a given option. | ||
61 | * | ||
62 | * You can set lazy options by passing a closure with the following | ||
63 | * signature: | ||
64 | * | ||
65 | * <code> | ||
66 | * function (Options $options) | ||
67 | * </code> | ||
68 | * | ||
69 | * This closure will be evaluated once the option is read using | ||
70 | * {@link get()}. The closure has access to the resolved values of | ||
71 | * other options through the passed {@link Options} instance. | ||
72 | * | ||
73 | * @param string $option The name of the option. | ||
74 | * @param mixed $value The value of the option. | ||
75 | * | ||
76 | * @throws OptionDefinitionException If options have already been read. | ||
77 | * Once options are read, the container | ||
78 | * becomes immutable. | ||
79 | */ | ||
80 | public function set($option, $value) | ||
81 | { | ||
82 | // Setting is not possible once an option is read, because then lazy | ||
83 | // options could manipulate the state of the object, leading to | ||
84 | // inconsistent results. | ||
85 | if ($this->reading) { | ||
86 | throw new OptionDefinitionException('Options cannot be set anymore once options have been read.'); | ||
87 | } | ||
88 | |||
89 | // Setting is equivalent to overloading while discarding the previous | ||
90 | // option value | ||
91 | unset($this->options[$option]); | ||
92 | unset($this->lazy[$option]); | ||
93 | |||
94 | $this->overload($option, $value); | ||
95 | } | ||
96 | |||
97 | /** | ||
98 | * Sets the normalizer for a given option. | ||
99 | * | ||
100 | * Normalizers should be closures with the following signature: | ||
101 | * | ||
102 | * <code> | ||
103 | * function (Options $options, $value) | ||
104 | * </code> | ||
105 | * | ||
106 | * This closure will be evaluated once the option is read using | ||
107 | * {@link get()}. The closure has access to the resolved values of | ||
108 | * other options through the passed {@link Options} instance. | ||
109 | * | ||
110 | * @param string $option The name of the option. | ||
111 | * @param \Closure $normalizer The normalizer. | ||
112 | * | ||
113 | * @throws OptionDefinitionException If options have already been read. | ||
114 | * Once options are read, the container | ||
115 | * becomes immutable. | ||
116 | */ | ||
117 | public function setNormalizer($option, \Closure $normalizer) | ||
118 | { | ||
119 | if ($this->reading) { | ||
120 | throw new OptionDefinitionException('Normalizers cannot be added anymore once options have been read.'); | ||
121 | } | ||
122 | |||
123 | $this->normalizers[$option] = $normalizer; | ||
124 | } | ||
125 | |||
126 | /** | ||
127 | * Replaces the contents of the container with the given options. | ||
128 | * | ||
129 | * This method is a shortcut for {@link clear()} with subsequent | ||
130 | * calls to {@link set()}. | ||
131 | * | ||
132 | * @param array $options The options to set. | ||
133 | * | ||
134 | * @throws OptionDefinitionException If options have already been read. | ||
135 | * Once options are read, the container | ||
136 | * becomes immutable. | ||
137 | */ | ||
138 | public function replace(array $options) | ||
139 | { | ||
140 | if ($this->reading) { | ||
141 | throw new OptionDefinitionException('Options cannot be replaced anymore once options have been read.'); | ||
142 | } | ||
143 | |||
144 | $this->options = array(); | ||
145 | $this->lazy = array(); | ||
146 | $this->normalizers = array(); | ||
147 | |||
148 | foreach ($options as $option => $value) { | ||
149 | $this->overload($option, $value); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * Overloads the value of a given option. | ||
155 | * | ||
156 | * Contrary to {@link set()}, this method keeps the previous default | ||
157 | * value of the option so that you can access it if you pass a closure. | ||
158 | * Passed closures should have the following signature: | ||
159 | * | ||
160 | * <code> | ||
161 | * function (Options $options, $value) | ||
162 | * </code> | ||
163 | * | ||
164 | * The second parameter passed to the closure is the current default | ||
165 | * value of the option. | ||
166 | * | ||
167 | * @param string $option The option name. | ||
168 | * @param mixed $value The option value. | ||
169 | * | ||
170 | * @throws OptionDefinitionException If options have already been read. | ||
171 | * Once options are read, the container | ||
172 | * becomes immutable. | ||
173 | */ | ||
174 | public function overload($option, $value) | ||
175 | { | ||
176 | if ($this->reading) { | ||
177 | throw new OptionDefinitionException('Options cannot be overloaded anymore once options have been read.'); | ||
178 | } | ||
179 | |||
180 | // If an option is a closure that should be evaluated lazily, store it | ||
181 | // in the "lazy" property. | ||
182 | if ($value instanceof \Closure) { | ||
183 | $reflClosure = new \ReflectionFunction($value); | ||
184 | $params = $reflClosure->getParameters(); | ||
185 | |||
186 | if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && __CLASS__ === $class->name) { | ||
187 | // Initialize the option if no previous value exists | ||
188 | if (!isset($this->options[$option])) { | ||
189 | $this->options[$option] = null; | ||
190 | } | ||
191 | |||
192 | // Ignore previous lazy options if the closure has no second parameter | ||
193 | if (!isset($this->lazy[$option]) || !isset($params[1])) { | ||
194 | $this->lazy[$option] = array(); | ||
195 | } | ||
196 | |||
197 | // Store closure for later evaluation | ||
198 | $this->lazy[$option][] = $value; | ||
199 | |||
200 | return; | ||
201 | } | ||
202 | } | ||
203 | |||
204 | // Remove lazy options by default | ||
205 | unset($this->lazy[$option]); | ||
206 | |||
207 | $this->options[$option] = $value; | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Returns the value of the given option. | ||
212 | * | ||
213 | * If the option was a lazy option, it is evaluated now. | ||
214 | * | ||
215 | * @param string $option The option name. | ||
216 | * | ||
217 | * @return mixed The option value. | ||
218 | * | ||
219 | * @throws \OutOfBoundsException If the option does not exist. | ||
220 | * @throws OptionDefinitionException If a cyclic dependency is detected | ||
221 | * between two lazy options. | ||
222 | */ | ||
223 | public function get($option) | ||
224 | { | ||
225 | $this->reading = true; | ||
226 | |||
227 | if (!array_key_exists($option, $this->options)) { | ||
228 | throw new \OutOfBoundsException(sprintf('The option "%s" does not exist.', $option)); | ||
229 | } | ||
230 | |||
231 | if (isset($this->lazy[$option])) { | ||
232 | $this->resolve($option); | ||
233 | } | ||
234 | |||
235 | if (isset($this->normalizers[$option])) { | ||
236 | $this->normalize($option); | ||
237 | } | ||
238 | |||
239 | return $this->options[$option]; | ||
240 | } | ||
241 | |||
242 | /** | ||
243 | * Returns whether the given option exists. | ||
244 | * | ||
245 | * @param string $option The option name. | ||
246 | * | ||
247 | * @return Boolean Whether the option exists. | ||
248 | */ | ||
249 | public function has($option) | ||
250 | { | ||
251 | return array_key_exists($option, $this->options); | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * Removes the option with the given name. | ||
256 | * | ||
257 | * @param string $option The option name. | ||
258 | * | ||
259 | * @throws OptionDefinitionException If options have already been read. | ||
260 | * Once options are read, the container | ||
261 | * becomes immutable. | ||
262 | */ | ||
263 | public function remove($option) | ||
264 | { | ||
265 | if ($this->reading) { | ||
266 | throw new OptionDefinitionException('Options cannot be removed anymore once options have been read.'); | ||
267 | } | ||
268 | |||
269 | unset($this->options[$option]); | ||
270 | unset($this->lazy[$option]); | ||
271 | unset($this->normalizers[$option]); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * Removes all options. | ||
276 | * | ||
277 | * @throws OptionDefinitionException If options have already been read. | ||
278 | * Once options are read, the container | ||
279 | * becomes immutable. | ||
280 | */ | ||
281 | public function clear() | ||
282 | { | ||
283 | if ($this->reading) { | ||
284 | throw new OptionDefinitionException('Options cannot be cleared anymore once options have been read.'); | ||
285 | } | ||
286 | |||
287 | $this->options = array(); | ||
288 | $this->lazy = array(); | ||
289 | $this->normalizers = array(); | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * Returns the values of all options. | ||
294 | * | ||
295 | * Lazy options are evaluated at this point. | ||
296 | * | ||
297 | * @return array The option values. | ||
298 | */ | ||
299 | public function all() | ||
300 | { | ||
301 | $this->reading = true; | ||
302 | |||
303 | // Performance-wise this is slightly better than | ||
304 | // while (null !== $option = key($this->lazy)) | ||
305 | foreach ($this->lazy as $option => $closures) { | ||
306 | // Double check, in case the option has already been resolved | ||
307 | // by cascade in the previous cycles | ||
308 | if (isset($this->lazy[$option])) { | ||
309 | $this->resolve($option); | ||
310 | } | ||
311 | } | ||
312 | |||
313 | foreach ($this->normalizers as $option => $normalizer) { | ||
314 | if (isset($this->normalizers[$option])) { | ||
315 | $this->normalize($option); | ||
316 | } | ||
317 | } | ||
318 | |||
319 | return $this->options; | ||
320 | } | ||
321 | |||
322 | /** | ||
323 | * Equivalent to {@link has()}. | ||
324 | * | ||
325 | * @param string $option The option name. | ||
326 | * | ||
327 | * @return Boolean Whether the option exists. | ||
328 | * | ||
329 | * @see \ArrayAccess::offsetExists() | ||
330 | */ | ||
331 | public function offsetExists($option) | ||
332 | { | ||
333 | return $this->has($option); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * Equivalent to {@link get()}. | ||
338 | * | ||
339 | * @param string $option The option name. | ||
340 | * | ||
341 | * @return mixed The option value. | ||
342 | * | ||
343 | * @throws \OutOfBoundsException If the option does not exist. | ||
344 | * @throws OptionDefinitionException If a cyclic dependency is detected | ||
345 | * between two lazy options. | ||
346 | * | ||
347 | * @see \ArrayAccess::offsetGet() | ||
348 | */ | ||
349 | public function offsetGet($option) | ||
350 | { | ||
351 | return $this->get($option); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Equivalent to {@link set()}. | ||
356 | * | ||
357 | * @param string $option The name of the option. | ||
358 | * @param mixed $value The value of the option. May be a closure with a | ||
359 | * signature as defined in DefaultOptions::add(). | ||
360 | * | ||
361 | * @throws OptionDefinitionException If options have already been read. | ||
362 | * Once options are read, the container | ||
363 | * becomes immutable. | ||
364 | * | ||
365 | * @see \ArrayAccess::offsetSet() | ||
366 | */ | ||
367 | public function offsetSet($option, $value) | ||
368 | { | ||
369 | $this->set($option, $value); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Equivalent to {@link remove()}. | ||
374 | * | ||
375 | * @param string $option The option name. | ||
376 | * | ||
377 | * @throws OptionDefinitionException If options have already been read. | ||
378 | * Once options are read, the container | ||
379 | * becomes immutable. | ||
380 | * | ||
381 | * @see \ArrayAccess::offsetUnset() | ||
382 | */ | ||
383 | public function offsetUnset($option) | ||
384 | { | ||
385 | $this->remove($option); | ||
386 | } | ||
387 | |||
388 | /** | ||
389 | * {@inheritdoc} | ||
390 | */ | ||
391 | public function current() | ||
392 | { | ||
393 | return $this->get($this->key()); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * {@inheritdoc} | ||
398 | */ | ||
399 | public function next() | ||
400 | { | ||
401 | next($this->options); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * {@inheritdoc} | ||
406 | */ | ||
407 | public function key() | ||
408 | { | ||
409 | return key($this->options); | ||
410 | } | ||
411 | |||
412 | /** | ||
413 | * {@inheritdoc} | ||
414 | */ | ||
415 | public function valid() | ||
416 | { | ||
417 | return null !== $this->key(); | ||
418 | } | ||
419 | |||
420 | /** | ||
421 | * {@inheritdoc} | ||
422 | */ | ||
423 | public function rewind() | ||
424 | { | ||
425 | reset($this->options); | ||
426 | } | ||
427 | |||
428 | /** | ||
429 | * {@inheritdoc} | ||
430 | */ | ||
431 | public function count() | ||
432 | { | ||
433 | return count($this->options); | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * Evaluates the given lazy option. | ||
438 | * | ||
439 | * The evaluated value is written into the options array. The closure for | ||
440 | * evaluating the option is discarded afterwards. | ||
441 | * | ||
442 | * @param string $option The option to evaluate. | ||
443 | * | ||
444 | * @throws OptionDefinitionException If the option has a cyclic dependency | ||
445 | * on another option. | ||
446 | */ | ||
447 | private function resolve($option) | ||
448 | { | ||
449 | // The code duplication with normalize() exists for performance | ||
450 | // reasons, in order to save a method call. | ||
451 | // Remember that this method is potentially called a couple of thousand | ||
452 | // times and needs to be as efficient as possible. | ||
453 | if (isset($this->lock[$option])) { | ||
454 | $conflicts = array(); | ||
455 | |||
456 | foreach ($this->lock as $option => $locked) { | ||
457 | if ($locked) { | ||
458 | $conflicts[] = $option; | ||
459 | } | ||
460 | } | ||
461 | |||
462 | throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', $conflicts))); | ||
463 | } | ||
464 | |||
465 | $this->lock[$option] = true; | ||
466 | foreach ($this->lazy[$option] as $closure) { | ||
467 | $this->options[$option] = $closure($this, $this->options[$option]); | ||
468 | } | ||
469 | unset($this->lock[$option]); | ||
470 | |||
471 | // The option now isn't lazy anymore | ||
472 | unset($this->lazy[$option]); | ||
473 | } | ||
474 | |||
475 | /** | ||
476 | * Normalizes the given option. | ||
477 | * | ||
478 | * The evaluated value is written into the options array. | ||
479 | * | ||
480 | * @param string $option The option to normalizer. | ||
481 | * | ||
482 | * @throws OptionDefinitionException If the option has a cyclic dependency | ||
483 | * on another option. | ||
484 | */ | ||
485 | private function normalize($option) | ||
486 | { | ||
487 | // The code duplication with resolve() exists for performance | ||
488 | // reasons, in order to save a method call. | ||
489 | // Remember that this method is potentially called a couple of thousand | ||
490 | // times and needs to be as efficient as possible. | ||
491 | if (isset($this->lock[$option])) { | ||
492 | $conflicts = array(); | ||
493 | |||
494 | foreach ($this->lock as $option => $locked) { | ||
495 | if ($locked) { | ||
496 | $conflicts[] = $option; | ||
497 | } | ||
498 | } | ||
499 | |||
500 | throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', $conflicts))); | ||
501 | } | ||
502 | |||
503 | /** @var \Closure $normalizer */ | ||
504 | $normalizer = $this->normalizers[$option]; | ||
505 | |||
506 | $this->lock[$option] = true; | ||
507 | $this->options[$option] = $normalizer($this, array_key_exists($option, $this->options) ? $this->options[$option] : null); | ||
508 | unset($this->lock[$option]); | ||
509 | |||
510 | // The option is now normalized | ||
511 | unset($this->normalizers[$option]); | ||
512 | } | ||
513 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolver.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolver.php new file mode 100644 index 00000000..d6554baa --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolver.php | |||
@@ -0,0 +1,346 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver; | ||
13 | |||
14 | use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; | ||
15 | use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; | ||
16 | use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; | ||
17 | |||
18 | /** | ||
19 | * Helper for merging default and concrete option values. | ||
20 | * | ||
21 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
22 | * @author Tobias Schultze <http://tobion.de> | ||
23 | */ | ||
24 | class OptionsResolver implements OptionsResolverInterface | ||
25 | { | ||
26 | /** | ||
27 | * The default option values. | ||
28 | * @var Options | ||
29 | */ | ||
30 | private $defaultOptions; | ||
31 | |||
32 | /** | ||
33 | * The options known by the resolver. | ||
34 | * @var array | ||
35 | */ | ||
36 | private $knownOptions = array(); | ||
37 | |||
38 | /** | ||
39 | * The options without defaults that are required to be passed to resolve(). | ||
40 | * @var array | ||
41 | */ | ||
42 | private $requiredOptions = array(); | ||
43 | |||
44 | /** | ||
45 | * A list of accepted values for each option. | ||
46 | * @var array | ||
47 | */ | ||
48 | private $allowedValues = array(); | ||
49 | |||
50 | /** | ||
51 | * A list of accepted types for each option. | ||
52 | * @var array | ||
53 | */ | ||
54 | private $allowedTypes = array(); | ||
55 | |||
56 | /** | ||
57 | * Creates a new instance. | ||
58 | */ | ||
59 | public function __construct() | ||
60 | { | ||
61 | $this->defaultOptions = new Options(); | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * Clones the resolver. | ||
66 | */ | ||
67 | public function __clone() | ||
68 | { | ||
69 | $this->defaultOptions = clone $this->defaultOptions; | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * {@inheritdoc} | ||
74 | */ | ||
75 | public function setDefaults(array $defaultValues) | ||
76 | { | ||
77 | foreach ($defaultValues as $option => $value) { | ||
78 | $this->defaultOptions->overload($option, $value); | ||
79 | $this->knownOptions[$option] = true; | ||
80 | unset($this->requiredOptions[$option]); | ||
81 | } | ||
82 | |||
83 | return $this; | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * {@inheritdoc} | ||
88 | */ | ||
89 | public function replaceDefaults(array $defaultValues) | ||
90 | { | ||
91 | foreach ($defaultValues as $option => $value) { | ||
92 | $this->defaultOptions->set($option, $value); | ||
93 | $this->knownOptions[$option] = true; | ||
94 | unset($this->requiredOptions[$option]); | ||
95 | } | ||
96 | |||
97 | return $this; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * {@inheritdoc} | ||
102 | */ | ||
103 | public function setOptional(array $optionNames) | ||
104 | { | ||
105 | foreach ($optionNames as $key => $option) { | ||
106 | if (!is_int($key)) { | ||
107 | throw new OptionDefinitionException('You should not pass default values to setOptional()'); | ||
108 | } | ||
109 | |||
110 | $this->knownOptions[$option] = true; | ||
111 | } | ||
112 | |||
113 | return $this; | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * {@inheritdoc} | ||
118 | */ | ||
119 | public function setRequired(array $optionNames) | ||
120 | { | ||
121 | foreach ($optionNames as $key => $option) { | ||
122 | if (!is_int($key)) { | ||
123 | throw new OptionDefinitionException('You should not pass default values to setRequired()'); | ||
124 | } | ||
125 | |||
126 | $this->knownOptions[$option] = true; | ||
127 | // set as required if no default has been set already | ||
128 | if (!isset($this->defaultOptions[$option])) { | ||
129 | $this->requiredOptions[$option] = true; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | return $this; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * {@inheritdoc} | ||
138 | */ | ||
139 | public function setAllowedValues(array $allowedValues) | ||
140 | { | ||
141 | $this->validateOptionsExistence($allowedValues); | ||
142 | |||
143 | $this->allowedValues = array_replace($this->allowedValues, $allowedValues); | ||
144 | |||
145 | return $this; | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * {@inheritdoc} | ||
150 | */ | ||
151 | public function addAllowedValues(array $allowedValues) | ||
152 | { | ||
153 | $this->validateOptionsExistence($allowedValues); | ||
154 | |||
155 | $this->allowedValues = array_merge_recursive($this->allowedValues, $allowedValues); | ||
156 | |||
157 | return $this; | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * {@inheritdoc} | ||
162 | */ | ||
163 | public function setAllowedTypes(array $allowedTypes) | ||
164 | { | ||
165 | $this->validateOptionsExistence($allowedTypes); | ||
166 | |||
167 | $this->allowedTypes = array_replace($this->allowedTypes, $allowedTypes); | ||
168 | |||
169 | return $this; | ||
170 | } | ||
171 | |||
172 | /** | ||
173 | * {@inheritdoc} | ||
174 | */ | ||
175 | public function addAllowedTypes(array $allowedTypes) | ||
176 | { | ||
177 | $this->validateOptionsExistence($allowedTypes); | ||
178 | |||
179 | $this->allowedTypes = array_merge_recursive($this->allowedTypes, $allowedTypes); | ||
180 | |||
181 | return $this; | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * {@inheritdoc} | ||
186 | */ | ||
187 | public function setNormalizers(array $normalizers) | ||
188 | { | ||
189 | $this->validateOptionsExistence($normalizers); | ||
190 | |||
191 | foreach ($normalizers as $option => $normalizer) { | ||
192 | $this->defaultOptions->setNormalizer($option, $normalizer); | ||
193 | } | ||
194 | |||
195 | return $this; | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * {@inheritdoc} | ||
200 | */ | ||
201 | public function isKnown($option) | ||
202 | { | ||
203 | return isset($this->knownOptions[$option]); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * {@inheritdoc} | ||
208 | */ | ||
209 | public function isRequired($option) | ||
210 | { | ||
211 | return isset($this->requiredOptions[$option]); | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * {@inheritdoc} | ||
216 | */ | ||
217 | public function resolve(array $options = array()) | ||
218 | { | ||
219 | $this->validateOptionsExistence($options); | ||
220 | $this->validateOptionsCompleteness($options); | ||
221 | |||
222 | // Make sure this method can be called multiple times | ||
223 | $combinedOptions = clone $this->defaultOptions; | ||
224 | |||
225 | // Override options set by the user | ||
226 | foreach ($options as $option => $value) { | ||
227 | $combinedOptions->set($option, $value); | ||
228 | } | ||
229 | |||
230 | // Resolve options | ||
231 | $resolvedOptions = $combinedOptions->all(); | ||
232 | |||
233 | $this->validateOptionValues($resolvedOptions); | ||
234 | $this->validateOptionTypes($resolvedOptions); | ||
235 | |||
236 | return $resolvedOptions; | ||
237 | } | ||
238 | |||
239 | /** | ||
240 | * Validates that the given option names exist and throws an exception | ||
241 | * otherwise. | ||
242 | * | ||
243 | * @param array $options An list of option names as keys. | ||
244 | * | ||
245 | * @throws InvalidOptionsException If any of the options has not been defined. | ||
246 | */ | ||
247 | private function validateOptionsExistence(array $options) | ||
248 | { | ||
249 | $diff = array_diff_key($options, $this->knownOptions); | ||
250 | |||
251 | if (count($diff) > 0) { | ||
252 | ksort($this->knownOptions); | ||
253 | ksort($diff); | ||
254 | |||
255 | throw new InvalidOptionsException(sprintf( | ||
256 | (count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Known options are: "%s"', | ||
257 | implode('", "', array_keys($diff)), | ||
258 | implode('", "', array_keys($this->knownOptions)) | ||
259 | )); | ||
260 | } | ||
261 | } | ||
262 | |||
263 | /** | ||
264 | * Validates that all required options are given and throws an exception | ||
265 | * otherwise. | ||
266 | * | ||
267 | * @param array $options An list of option names as keys. | ||
268 | * | ||
269 | * @throws MissingOptionsException If a required option is missing. | ||
270 | */ | ||
271 | private function validateOptionsCompleteness(array $options) | ||
272 | { | ||
273 | $diff = array_diff_key($this->requiredOptions, $options); | ||
274 | |||
275 | if (count($diff) > 0) { | ||
276 | ksort($diff); | ||
277 | |||
278 | throw new MissingOptionsException(sprintf( | ||
279 | count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', | ||
280 | implode('", "', array_keys($diff)) | ||
281 | )); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * Validates that the given option values match the allowed values and | ||
287 | * throws an exception otherwise. | ||
288 | * | ||
289 | * @param array $options A list of option values. | ||
290 | * | ||
291 | * @throws InvalidOptionsException If any of the values does not match the | ||
292 | * allowed values of the option. | ||
293 | */ | ||
294 | private function validateOptionValues(array $options) | ||
295 | { | ||
296 | foreach ($this->allowedValues as $option => $allowedValues) { | ||
297 | if (isset($options[$option]) && !in_array($options[$option], $allowedValues, true)) { | ||
298 | throw new InvalidOptionsException(sprintf('The option "%s" has the value "%s", but is expected to be one of "%s"', $option, $options[$option], implode('", "', $allowedValues))); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Validates that the given options match the allowed types and | ||
305 | * throws an exception otherwise. | ||
306 | * | ||
307 | * @param array $options A list of options. | ||
308 | * | ||
309 | * @throws InvalidOptionsException If any of the types does not match the | ||
310 | * allowed types of the option. | ||
311 | */ | ||
312 | private function validateOptionTypes(array $options) | ||
313 | { | ||
314 | foreach ($this->allowedTypes as $option => $allowedTypes) { | ||
315 | if (!array_key_exists($option, $options)) { | ||
316 | continue; | ||
317 | } | ||
318 | |||
319 | $value = $options[$option]; | ||
320 | $allowedTypes = (array) $allowedTypes; | ||
321 | |||
322 | foreach ($allowedTypes as $type) { | ||
323 | $isFunction = 'is_'.$type; | ||
324 | |||
325 | if (function_exists($isFunction) && $isFunction($value)) { | ||
326 | continue 2; | ||
327 | } elseif ($value instanceof $type) { | ||
328 | continue 2; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | $printableValue = is_object($value) | ||
333 | ? get_class($value) | ||
334 | : (is_array($value) | ||
335 | ? 'Array' | ||
336 | : (string) $value); | ||
337 | |||
338 | throw new InvalidOptionsException(sprintf( | ||
339 | 'The option "%s" with value "%s" is expected to be of type "%s"', | ||
340 | $option, | ||
341 | $printableValue, | ||
342 | implode('", "', $allowedTypes) | ||
343 | )); | ||
344 | } | ||
345 | } | ||
346 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolverInterface.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolverInterface.php new file mode 100644 index 00000000..8474c4bc --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/OptionsResolverInterface.php | |||
@@ -0,0 +1,210 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | interface OptionsResolverInterface | ||
18 | { | ||
19 | /** | ||
20 | * Sets default option values. | ||
21 | * | ||
22 | * The options can either be values of any types or closures that | ||
23 | * evaluate the option value lazily. These closures must have one | ||
24 | * of the following signatures: | ||
25 | * | ||
26 | * <code> | ||
27 | * function (Options $options) | ||
28 | * function (Options $options, $value) | ||
29 | * </code> | ||
30 | * | ||
31 | * The second parameter passed to the closure is the previously | ||
32 | * set default value, in case you are overwriting an existing | ||
33 | * default value. | ||
34 | * | ||
35 | * The closures should return the lazily created option value. | ||
36 | * | ||
37 | * @param array $defaultValues A list of option names as keys and default | ||
38 | * values or closures as values. | ||
39 | * | ||
40 | * @return OptionsResolverInterface The resolver instance. | ||
41 | */ | ||
42 | public function setDefaults(array $defaultValues); | ||
43 | |||
44 | /** | ||
45 | * Replaces default option values. | ||
46 | * | ||
47 | * Old defaults are erased, which means that closures passed here cannot | ||
48 | * access the previous default value. This may be useful to improve | ||
49 | * performance if the previous default value is calculated by an expensive | ||
50 | * closure. | ||
51 | * | ||
52 | * @param array $defaultValues A list of option names as keys and default | ||
53 | * values or closures as values. | ||
54 | * | ||
55 | * @return OptionsResolverInterface The resolver instance. | ||
56 | */ | ||
57 | public function replaceDefaults(array $defaultValues); | ||
58 | |||
59 | /** | ||
60 | * Sets optional options. | ||
61 | * | ||
62 | * This method declares valid option names without setting default values for them. | ||
63 | * If these options are not passed to {@link resolve()} and no default has been set | ||
64 | * for them, they will be missing in the final options array. This can be helpful | ||
65 | * if you want to determine whether an option has been set or not because otherwise | ||
66 | * {@link resolve()} would trigger an exception for unknown options. | ||
67 | * | ||
68 | * @param array $optionNames A list of option names. | ||
69 | * | ||
70 | * @return OptionsResolverInterface The resolver instance. | ||
71 | * | ||
72 | * @throws Exception\OptionDefinitionException When trying to pass default values. | ||
73 | */ | ||
74 | public function setOptional(array $optionNames); | ||
75 | |||
76 | /** | ||
77 | * Sets required options. | ||
78 | * | ||
79 | * If these options are not passed to {@link resolve()} and no default has been set for | ||
80 | * them, an exception will be thrown. | ||
81 | * | ||
82 | * @param array $optionNames A list of option names. | ||
83 | * | ||
84 | * @return OptionsResolverInterface The resolver instance. | ||
85 | * | ||
86 | * @throws Exception\OptionDefinitionException When trying to pass default values. | ||
87 | */ | ||
88 | public function setRequired(array $optionNames); | ||
89 | |||
90 | /** | ||
91 | * Sets allowed values for a list of options. | ||
92 | * | ||
93 | * @param array $allowedValues A list of option names as keys and arrays | ||
94 | * with values acceptable for that option as | ||
95 | * values. | ||
96 | * | ||
97 | * @return OptionsResolverInterface The resolver instance. | ||
98 | * | ||
99 | * @throws Exception\InvalidOptionsException If an option has not been defined | ||
100 | * (see {@link isKnown()}) for which | ||
101 | * an allowed value is set. | ||
102 | */ | ||
103 | public function setAllowedValues(array $allowedValues); | ||
104 | |||
105 | /** | ||
106 | * Adds allowed values for a list of options. | ||
107 | * | ||
108 | * The values are merged with the allowed values defined previously. | ||
109 | * | ||
110 | * @param array $allowedValues A list of option names as keys and arrays | ||
111 | * with values acceptable for that option as | ||
112 | * values. | ||
113 | * | ||
114 | * @return OptionsResolverInterface The resolver instance. | ||
115 | * | ||
116 | * @throws Exception\InvalidOptionsException If an option has not been defined | ||
117 | * (see {@link isKnown()}) for which | ||
118 | * an allowed value is set. | ||
119 | */ | ||
120 | public function addAllowedValues(array $allowedValues); | ||
121 | |||
122 | /** | ||
123 | * Sets allowed types for a list of options. | ||
124 | * | ||
125 | * @param array $allowedTypes A list of option names as keys and type | ||
126 | * names passed as string or array as values. | ||
127 | * | ||
128 | * @return OptionsResolverInterface The resolver instance. | ||
129 | * | ||
130 | * @throws Exception\InvalidOptionsException If an option has not been defined for | ||
131 | * which an allowed type is set. | ||
132 | */ | ||
133 | public function setAllowedTypes(array $allowedTypes); | ||
134 | |||
135 | /** | ||
136 | * Adds allowed types for a list of options. | ||
137 | * | ||
138 | * The types are merged with the allowed types defined previously. | ||
139 | * | ||
140 | * @param array $allowedTypes A list of option names as keys and type | ||
141 | * names passed as string or array as values. | ||
142 | * | ||
143 | * @return OptionsResolverInterface The resolver instance. | ||
144 | * | ||
145 | * @throws Exception\InvalidOptionsException If an option has not been defined for | ||
146 | * which an allowed type is set. | ||
147 | */ | ||
148 | public function addAllowedTypes(array $allowedTypes); | ||
149 | |||
150 | /** | ||
151 | * Sets normalizers that are applied on resolved options. | ||
152 | * | ||
153 | * The normalizers should be closures with the following signature: | ||
154 | * | ||
155 | * <code> | ||
156 | * function (Options $options, $value) | ||
157 | * </code> | ||
158 | * | ||
159 | * The second parameter passed to the closure is the value of | ||
160 | * the option. | ||
161 | * | ||
162 | * The closure should return the normalized value. | ||
163 | * | ||
164 | * @param array $normalizers An array of closures. | ||
165 | * | ||
166 | * @return OptionsResolverInterface The resolver instance. | ||
167 | */ | ||
168 | public function setNormalizers(array $normalizers); | ||
169 | |||
170 | /** | ||
171 | * Returns whether an option is known. | ||
172 | * | ||
173 | * An option is known if it has been passed to either {@link setDefaults()}, | ||
174 | * {@link setRequired()} or {@link setOptional()} before. | ||
175 | * | ||
176 | * @param string $option The name of the option. | ||
177 | * | ||
178 | * @return Boolean Whether the option is known. | ||
179 | */ | ||
180 | public function isKnown($option); | ||
181 | |||
182 | /** | ||
183 | * Returns whether an option is required. | ||
184 | * | ||
185 | * An option is required if it has been passed to {@link setRequired()}, | ||
186 | * but not to {@link setDefaults()}. That is, the option has been declared | ||
187 | * as required and no default value has been set. | ||
188 | * | ||
189 | * @param string $option The name of the option. | ||
190 | * | ||
191 | * @return Boolean Whether the option is required. | ||
192 | */ | ||
193 | public function isRequired($option); | ||
194 | |||
195 | /** | ||
196 | * Returns the combination of the default and the passed options. | ||
197 | * | ||
198 | * @param array $options The custom option values. | ||
199 | * | ||
200 | * @return array A list of options and their values. | ||
201 | * | ||
202 | * @throws Exception\InvalidOptionsException If any of the passed options has not | ||
203 | * been defined or does not contain an | ||
204 | * allowed value. | ||
205 | * @throws Exception\MissingOptionsException If a required option is missing. | ||
206 | * @throws Exception\OptionDefinitionException If a cyclic dependency is detected | ||
207 | * between two lazy options. | ||
208 | */ | ||
209 | public function resolve(array $options = array()); | ||
210 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/README.md b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/README.md new file mode 100644 index 00000000..29cea102 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/README.md | |||
@@ -0,0 +1,107 @@ | |||
1 | OptionsResolver Component | ||
2 | ========================= | ||
3 | |||
4 | OptionsResolver helps at configuring objects with option arrays. | ||
5 | |||
6 | It supports default values on different levels of your class hierarchy, | ||
7 | option constraints (required vs. optional, allowed values) and lazy options | ||
8 | whose default value depends on the value of another option. | ||
9 | |||
10 | The following example demonstrates a Person class with two required options | ||
11 | "firstName" and "lastName" and two optional options "age" and "gender", where | ||
12 | the default value of "gender" is derived from the passed first name, if | ||
13 | possible, and may only be one of "male" and "female". | ||
14 | |||
15 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
16 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
17 | use Symfony\Component\OptionsResolver\Options; | ||
18 | |||
19 | class Person | ||
20 | { | ||
21 | protected $options; | ||
22 | |||
23 | public function __construct(array $options = array()) | ||
24 | { | ||
25 | $resolver = new OptionsResolver(); | ||
26 | $this->setDefaultOptions($resolver); | ||
27 | |||
28 | $this->options = $resolver->resolve($options); | ||
29 | } | ||
30 | |||
31 | protected function setDefaultOptions(OptionsResolverInterface $resolver) | ||
32 | { | ||
33 | $resolver->setRequired(array( | ||
34 | 'firstName', | ||
35 | 'lastName', | ||
36 | )); | ||
37 | |||
38 | $resolver->setDefaults(array( | ||
39 | 'age' => null, | ||
40 | 'gender' => function (Options $options) { | ||
41 | if (self::isKnownMaleName($options['firstName'])) { | ||
42 | return 'male'; | ||
43 | } | ||
44 | |||
45 | return 'female'; | ||
46 | }, | ||
47 | )); | ||
48 | |||
49 | $resolver->setAllowedValues(array( | ||
50 | 'gender' => array('male', 'female'), | ||
51 | )); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | We can now easily instantiate a Person object: | ||
56 | |||
57 | // 'gender' is implicitly set to 'female' | ||
58 | $person = new Person(array( | ||
59 | 'firstName' => 'Jane', | ||
60 | 'lastName' => 'Doe', | ||
61 | )); | ||
62 | |||
63 | We can also override the default values of the optional options: | ||
64 | |||
65 | $person = new Person(array( | ||
66 | 'firstName' => 'Abdullah', | ||
67 | 'lastName' => 'Mogashi', | ||
68 | 'gender' => 'male', | ||
69 | 'age' => 30, | ||
70 | )); | ||
71 | |||
72 | Options can be added or changed in subclasses by overriding the `setDefaultOptions` | ||
73 | method: | ||
74 | |||
75 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
76 | use Symfony\Component\OptionsResolver\Options; | ||
77 | |||
78 | class Employee extends Person | ||
79 | { | ||
80 | protected function setDefaultOptions(OptionsResolverInterface $resolver) | ||
81 | { | ||
82 | parent::setDefaultOptions($resolver); | ||
83 | |||
84 | $resolver->setRequired(array( | ||
85 | 'birthDate', | ||
86 | )); | ||
87 | |||
88 | $resolver->setDefaults(array( | ||
89 | // $previousValue contains the default value configured in the | ||
90 | // parent class | ||
91 | 'age' => function (Options $options, $previousValue) { | ||
92 | return self::calculateAge($options['birthDate']); | ||
93 | } | ||
94 | )); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | |||
99 | |||
100 | Resources | ||
101 | --------- | ||
102 | |||
103 | You can run the unit tests with the following command: | ||
104 | |||
105 | $ cd path/to/Symfony/Component/OptionsResolver/ | ||
106 | $ composer.phar install --dev | ||
107 | $ phpunit | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php new file mode 100644 index 00000000..d50cd3fc --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php | |||
@@ -0,0 +1,681 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Tests; | ||
13 | |||
14 | use Symfony\Component\OptionsResolver\OptionsResolver; | ||
15 | use Symfony\Component\OptionsResolver\Options; | ||
16 | |||
17 | class OptionsResolverTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | /** | ||
20 | * @var OptionsResolver | ||
21 | */ | ||
22 | private $resolver; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | $this->resolver = new OptionsResolver(); | ||
27 | } | ||
28 | |||
29 | public function testResolve() | ||
30 | { | ||
31 | $this->resolver->setDefaults(array( | ||
32 | 'one' => '1', | ||
33 | 'two' => '2', | ||
34 | )); | ||
35 | |||
36 | $options = array( | ||
37 | 'two' => '20', | ||
38 | ); | ||
39 | |||
40 | $this->assertEquals(array( | ||
41 | 'one' => '1', | ||
42 | 'two' => '20', | ||
43 | ), $this->resolver->resolve($options)); | ||
44 | } | ||
45 | |||
46 | public function testResolveLazy() | ||
47 | { | ||
48 | $this->resolver->setDefaults(array( | ||
49 | 'one' => '1', | ||
50 | 'two' => function (Options $options) { | ||
51 | return '20'; | ||
52 | }, | ||
53 | )); | ||
54 | |||
55 | $this->assertEquals(array( | ||
56 | 'one' => '1', | ||
57 | 'two' => '20', | ||
58 | ), $this->resolver->resolve(array())); | ||
59 | } | ||
60 | |||
61 | public function testResolveLazyDependencyOnOptional() | ||
62 | { | ||
63 | $this->resolver->setDefaults(array( | ||
64 | 'one' => '1', | ||
65 | 'two' => function (Options $options) { | ||
66 | return $options['one'].'2'; | ||
67 | }, | ||
68 | )); | ||
69 | |||
70 | $options = array( | ||
71 | 'one' => '10', | ||
72 | ); | ||
73 | |||
74 | $this->assertEquals(array( | ||
75 | 'one' => '10', | ||
76 | 'two' => '102', | ||
77 | ), $this->resolver->resolve($options)); | ||
78 | } | ||
79 | |||
80 | public function testResolveLazyDependencyOnMissingOptionalWithoutDefault() | ||
81 | { | ||
82 | $test = $this; | ||
83 | |||
84 | $this->resolver->setOptional(array( | ||
85 | 'one', | ||
86 | )); | ||
87 | |||
88 | $this->resolver->setDefaults(array( | ||
89 | 'two' => function (Options $options) use ($test) { | ||
90 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
91 | $test->assertFalse(isset($options['one'])); | ||
92 | |||
93 | return '2'; | ||
94 | }, | ||
95 | )); | ||
96 | |||
97 | $options = array( | ||
98 | ); | ||
99 | |||
100 | $this->assertEquals(array( | ||
101 | 'two' => '2', | ||
102 | ), $this->resolver->resolve($options)); | ||
103 | } | ||
104 | |||
105 | public function testResolveLazyDependencyOnOptionalWithoutDefault() | ||
106 | { | ||
107 | $test = $this; | ||
108 | |||
109 | $this->resolver->setOptional(array( | ||
110 | 'one', | ||
111 | )); | ||
112 | |||
113 | $this->resolver->setDefaults(array( | ||
114 | 'two' => function (Options $options) use ($test) { | ||
115 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
116 | $test->assertTrue(isset($options['one'])); | ||
117 | |||
118 | return $options['one'].'2'; | ||
119 | }, | ||
120 | )); | ||
121 | |||
122 | $options = array( | ||
123 | 'one' => '10', | ||
124 | ); | ||
125 | |||
126 | $this->assertEquals(array( | ||
127 | 'one' => '10', | ||
128 | 'two' => '102', | ||
129 | ), $this->resolver->resolve($options)); | ||
130 | } | ||
131 | |||
132 | public function testResolveLazyDependencyOnRequired() | ||
133 | { | ||
134 | $this->resolver->setRequired(array( | ||
135 | 'one', | ||
136 | )); | ||
137 | $this->resolver->setDefaults(array( | ||
138 | 'two' => function (Options $options) { | ||
139 | return $options['one'].'2'; | ||
140 | }, | ||
141 | )); | ||
142 | |||
143 | $options = array( | ||
144 | 'one' => '10', | ||
145 | ); | ||
146 | |||
147 | $this->assertEquals(array( | ||
148 | 'one' => '10', | ||
149 | 'two' => '102', | ||
150 | ), $this->resolver->resolve($options)); | ||
151 | } | ||
152 | |||
153 | public function testResolveLazyReplaceDefaults() | ||
154 | { | ||
155 | $test = $this; | ||
156 | |||
157 | $this->resolver->setDefaults(array( | ||
158 | 'one' => function (Options $options) use ($test) { | ||
159 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
160 | $test->fail('Previous closure should not be executed'); | ||
161 | }, | ||
162 | )); | ||
163 | |||
164 | $this->resolver->replaceDefaults(array( | ||
165 | 'one' => function (Options $options, $previousValue) { | ||
166 | return '1'; | ||
167 | }, | ||
168 | )); | ||
169 | |||
170 | $this->assertEquals(array( | ||
171 | 'one' => '1', | ||
172 | ), $this->resolver->resolve(array())); | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
177 | */ | ||
178 | public function testResolveFailsIfNonExistingOption() | ||
179 | { | ||
180 | $this->resolver->setDefaults(array( | ||
181 | 'one' => '1', | ||
182 | )); | ||
183 | |||
184 | $this->resolver->setRequired(array( | ||
185 | 'two', | ||
186 | )); | ||
187 | |||
188 | $this->resolver->setOptional(array( | ||
189 | 'three', | ||
190 | )); | ||
191 | |||
192 | $this->resolver->resolve(array( | ||
193 | 'foo' => 'bar', | ||
194 | )); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException | ||
199 | */ | ||
200 | public function testResolveFailsIfMissingRequiredOption() | ||
201 | { | ||
202 | $this->resolver->setRequired(array( | ||
203 | 'one', | ||
204 | )); | ||
205 | |||
206 | $this->resolver->setDefaults(array( | ||
207 | 'two' => '2', | ||
208 | )); | ||
209 | |||
210 | $this->resolver->resolve(array( | ||
211 | 'two' => '20', | ||
212 | )); | ||
213 | } | ||
214 | |||
215 | public function testResolveSucceedsIfOptionValueAllowed() | ||
216 | { | ||
217 | $this->resolver->setDefaults(array( | ||
218 | 'one' => '1', | ||
219 | )); | ||
220 | |||
221 | $this->resolver->setAllowedValues(array( | ||
222 | 'one' => array('1', 'one'), | ||
223 | )); | ||
224 | |||
225 | $options = array( | ||
226 | 'one' => 'one', | ||
227 | ); | ||
228 | |||
229 | $this->assertEquals(array( | ||
230 | 'one' => 'one', | ||
231 | ), $this->resolver->resolve($options)); | ||
232 | } | ||
233 | |||
234 | public function testResolveSucceedsIfOptionValueAllowed2() | ||
235 | { | ||
236 | $this->resolver->setDefaults(array( | ||
237 | 'one' => '1', | ||
238 | 'two' => '2', | ||
239 | )); | ||
240 | |||
241 | $this->resolver->setAllowedValues(array( | ||
242 | 'one' => '1', | ||
243 | 'two' => '2', | ||
244 | )); | ||
245 | $this->resolver->addAllowedValues(array( | ||
246 | 'one' => 'one', | ||
247 | 'two' => 'two', | ||
248 | )); | ||
249 | |||
250 | $options = array( | ||
251 | 'one' => '1', | ||
252 | 'two' => 'two', | ||
253 | ); | ||
254 | |||
255 | $this->assertEquals(array( | ||
256 | 'one' => '1', | ||
257 | 'two' => 'two', | ||
258 | ), $this->resolver->resolve($options)); | ||
259 | } | ||
260 | |||
261 | public function testResolveSucceedsIfOptionalWithAllowedValuesNotSet() | ||
262 | { | ||
263 | $this->resolver->setRequired(array( | ||
264 | 'one', | ||
265 | )); | ||
266 | |||
267 | $this->resolver->setOptional(array( | ||
268 | 'two', | ||
269 | )); | ||
270 | |||
271 | $this->resolver->setAllowedValues(array( | ||
272 | 'one' => array('1', 'one'), | ||
273 | 'two' => array('2', 'two'), | ||
274 | )); | ||
275 | |||
276 | $options = array( | ||
277 | 'one' => '1', | ||
278 | ); | ||
279 | |||
280 | $this->assertEquals(array( | ||
281 | 'one' => '1', | ||
282 | ), $this->resolver->resolve($options)); | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
287 | */ | ||
288 | public function testResolveFailsIfOptionValueNotAllowed() | ||
289 | { | ||
290 | $this->resolver->setDefaults(array( | ||
291 | 'one' => '1', | ||
292 | )); | ||
293 | |||
294 | $this->resolver->setAllowedValues(array( | ||
295 | 'one' => array('1', 'one'), | ||
296 | )); | ||
297 | |||
298 | $this->resolver->resolve(array( | ||
299 | 'one' => '2', | ||
300 | )); | ||
301 | } | ||
302 | |||
303 | public function testResolveSucceedsIfOptionTypeAllowed() | ||
304 | { | ||
305 | $this->resolver->setDefaults(array( | ||
306 | 'one' => '1', | ||
307 | )); | ||
308 | |||
309 | $this->resolver->setAllowedTypes(array( | ||
310 | 'one' => 'string', | ||
311 | )); | ||
312 | |||
313 | $options = array( | ||
314 | 'one' => 'one', | ||
315 | ); | ||
316 | |||
317 | $this->assertEquals(array( | ||
318 | 'one' => 'one', | ||
319 | ), $this->resolver->resolve($options)); | ||
320 | } | ||
321 | |||
322 | public function testResolveSucceedsIfOptionTypeAllowedPassArray() | ||
323 | { | ||
324 | $this->resolver->setDefaults(array( | ||
325 | 'one' => '1', | ||
326 | )); | ||
327 | |||
328 | $this->resolver->setAllowedTypes(array( | ||
329 | 'one' => array('string', 'bool'), | ||
330 | )); | ||
331 | |||
332 | $options = array( | ||
333 | 'one' => true, | ||
334 | ); | ||
335 | |||
336 | $this->assertEquals(array( | ||
337 | 'one' => true, | ||
338 | ), $this->resolver->resolve($options)); | ||
339 | } | ||
340 | |||
341 | public function testResolveSucceedsIfOptionTypeAllowedPassObject() | ||
342 | { | ||
343 | $this->resolver->setDefaults(array( | ||
344 | 'one' => '1', | ||
345 | )); | ||
346 | |||
347 | $this->resolver->setAllowedTypes(array( | ||
348 | 'one' => 'object', | ||
349 | )); | ||
350 | |||
351 | $object = new \stdClass(); | ||
352 | $options = array( | ||
353 | 'one' => $object, | ||
354 | ); | ||
355 | |||
356 | $this->assertEquals(array( | ||
357 | 'one' => $object, | ||
358 | ), $this->resolver->resolve($options)); | ||
359 | } | ||
360 | |||
361 | public function testResolveSucceedsIfOptionTypeAllowedPassClass() | ||
362 | { | ||
363 | $this->resolver->setDefaults(array( | ||
364 | 'one' => '1', | ||
365 | )); | ||
366 | |||
367 | $this->resolver->setAllowedTypes(array( | ||
368 | 'one' => '\stdClass', | ||
369 | )); | ||
370 | |||
371 | $object = new \stdClass(); | ||
372 | $options = array( | ||
373 | 'one' => $object, | ||
374 | ); | ||
375 | |||
376 | $this->assertEquals(array( | ||
377 | 'one' => $object, | ||
378 | ), $this->resolver->resolve($options)); | ||
379 | } | ||
380 | |||
381 | public function testResolveSucceedsIfOptionTypeAllowedAddTypes() | ||
382 | { | ||
383 | $this->resolver->setDefaults(array( | ||
384 | 'one' => '1', | ||
385 | 'two' => '2', | ||
386 | )); | ||
387 | |||
388 | $this->resolver->setAllowedTypes(array( | ||
389 | 'one' => 'string', | ||
390 | 'two' => 'bool', | ||
391 | )); | ||
392 | $this->resolver->addAllowedTypes(array( | ||
393 | 'one' => 'float', | ||
394 | 'two' => 'integer', | ||
395 | )); | ||
396 | |||
397 | $options = array( | ||
398 | 'one' => 1.23, | ||
399 | 'two' => false, | ||
400 | ); | ||
401 | |||
402 | $this->assertEquals(array( | ||
403 | 'one' => 1.23, | ||
404 | 'two' => false, | ||
405 | ), $this->resolver->resolve($options)); | ||
406 | } | ||
407 | |||
408 | public function testResolveSucceedsIfOptionalWithTypeAndWithoutValue() | ||
409 | { | ||
410 | $this->resolver->setOptional(array( | ||
411 | 'one', | ||
412 | 'two', | ||
413 | )); | ||
414 | |||
415 | $this->resolver->setAllowedTypes(array( | ||
416 | 'one' => 'string', | ||
417 | 'two' => 'int', | ||
418 | )); | ||
419 | |||
420 | $options = array( | ||
421 | 'two' => 1, | ||
422 | ); | ||
423 | |||
424 | $this->assertEquals(array( | ||
425 | 'two' => 1, | ||
426 | ), $this->resolver->resolve($options)); | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
431 | */ | ||
432 | public function testResolveFailsIfOptionTypeNotAllowed() | ||
433 | { | ||
434 | $this->resolver->setDefaults(array( | ||
435 | 'one' => '1', | ||
436 | )); | ||
437 | |||
438 | $this->resolver->setAllowedTypes(array( | ||
439 | 'one' => array('string', 'bool'), | ||
440 | )); | ||
441 | |||
442 | $this->resolver->resolve(array( | ||
443 | 'one' => 1.23, | ||
444 | )); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
449 | */ | ||
450 | public function testResolveFailsIfOptionTypeNotAllowedMultipleOptions() | ||
451 | { | ||
452 | $this->resolver->setDefaults(array( | ||
453 | 'one' => '1', | ||
454 | 'two' => '2', | ||
455 | )); | ||
456 | |||
457 | $this->resolver->setAllowedTypes(array( | ||
458 | 'one' => 'string', | ||
459 | 'two' => 'bool', | ||
460 | )); | ||
461 | |||
462 | $this->resolver->resolve(array( | ||
463 | 'one' => 'foo', | ||
464 | 'two' => 1.23, | ||
465 | )); | ||
466 | } | ||
467 | |||
468 | /** | ||
469 | * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException | ||
470 | */ | ||
471 | public function testResolveFailsIfOptionTypeNotAllowedAddTypes() | ||
472 | { | ||
473 | $this->resolver->setDefaults(array( | ||
474 | 'one' => '1', | ||
475 | )); | ||
476 | |||
477 | $this->resolver->setAllowedTypes(array( | ||
478 | 'one' => 'string', | ||
479 | )); | ||
480 | $this->resolver->addAllowedTypes(array( | ||
481 | 'one' => 'bool', | ||
482 | )); | ||
483 | |||
484 | $this->resolver->resolve(array( | ||
485 | 'one' => 1.23, | ||
486 | )); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
491 | */ | ||
492 | public function testSetRequiredFailsIfDefaultIsPassed() | ||
493 | { | ||
494 | $this->resolver->setRequired(array( | ||
495 | 'one' => '1', | ||
496 | )); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
501 | */ | ||
502 | public function testSetOptionalFailsIfDefaultIsPassed() | ||
503 | { | ||
504 | $this->resolver->setOptional(array( | ||
505 | 'one' => '1', | ||
506 | )); | ||
507 | } | ||
508 | |||
509 | public function testFluidInterface() | ||
510 | { | ||
511 | $this->resolver->setDefaults(array('one' => '1')) | ||
512 | ->replaceDefaults(array('one' => '2')) | ||
513 | ->setAllowedValues(array('one' => array('1', '2'))) | ||
514 | ->addAllowedValues(array('one' => array('3'))) | ||
515 | ->setRequired(array('two')) | ||
516 | ->setOptional(array('three')); | ||
517 | |||
518 | $options = array( | ||
519 | 'two' => '2', | ||
520 | ); | ||
521 | |||
522 | $this->assertEquals(array( | ||
523 | 'one' => '2', | ||
524 | 'two' => '2', | ||
525 | ), $this->resolver->resolve($options)); | ||
526 | } | ||
527 | |||
528 | public function testKnownIfDefaultWasSet() | ||
529 | { | ||
530 | $this->assertFalse($this->resolver->isKnown('foo')); | ||
531 | |||
532 | $this->resolver->setDefaults(array( | ||
533 | 'foo' => 'bar', | ||
534 | )); | ||
535 | |||
536 | $this->assertTrue($this->resolver->isKnown('foo')); | ||
537 | } | ||
538 | |||
539 | public function testKnownIfRequired() | ||
540 | { | ||
541 | $this->assertFalse($this->resolver->isKnown('foo')); | ||
542 | |||
543 | $this->resolver->setRequired(array( | ||
544 | 'foo', | ||
545 | )); | ||
546 | |||
547 | $this->assertTrue($this->resolver->isKnown('foo')); | ||
548 | } | ||
549 | |||
550 | public function testKnownIfOptional() | ||
551 | { | ||
552 | $this->assertFalse($this->resolver->isKnown('foo')); | ||
553 | |||
554 | $this->resolver->setOptional(array( | ||
555 | 'foo', | ||
556 | )); | ||
557 | |||
558 | $this->assertTrue($this->resolver->isKnown('foo')); | ||
559 | } | ||
560 | |||
561 | public function testRequiredIfRequired() | ||
562 | { | ||
563 | $this->assertFalse($this->resolver->isRequired('foo')); | ||
564 | |||
565 | $this->resolver->setRequired(array( | ||
566 | 'foo', | ||
567 | )); | ||
568 | |||
569 | $this->assertTrue($this->resolver->isRequired('foo')); | ||
570 | } | ||
571 | |||
572 | public function testNotRequiredIfRequiredAndDefaultValue() | ||
573 | { | ||
574 | $this->assertFalse($this->resolver->isRequired('foo')); | ||
575 | |||
576 | $this->resolver->setRequired(array( | ||
577 | 'foo', | ||
578 | )); | ||
579 | $this->resolver->setDefaults(array( | ||
580 | 'foo' => 'bar', | ||
581 | )); | ||
582 | |||
583 | $this->assertFalse($this->resolver->isRequired('foo')); | ||
584 | } | ||
585 | |||
586 | public function testNormalizersTransformFinalOptions() | ||
587 | { | ||
588 | $this->resolver->setDefaults(array( | ||
589 | 'foo' => 'bar', | ||
590 | 'bam' => 'baz', | ||
591 | )); | ||
592 | $this->resolver->setNormalizers(array( | ||
593 | 'foo' => function (Options $options, $value) { | ||
594 | return $options['bam'].'['.$value.']'; | ||
595 | }, | ||
596 | )); | ||
597 | |||
598 | $expected = array( | ||
599 | 'foo' => 'baz[bar]', | ||
600 | 'bam' => 'baz', | ||
601 | ); | ||
602 | |||
603 | $this->assertEquals($expected, $this->resolver->resolve(array())); | ||
604 | |||
605 | $expected = array( | ||
606 | 'foo' => 'boo[custom]', | ||
607 | 'bam' => 'boo', | ||
608 | ); | ||
609 | |||
610 | $this->assertEquals($expected, $this->resolver->resolve(array( | ||
611 | 'foo' => 'custom', | ||
612 | 'bam' => 'boo', | ||
613 | ))); | ||
614 | } | ||
615 | |||
616 | public function testResolveWithoutOptionSucceedsIfRequiredAndDefaultValue() | ||
617 | { | ||
618 | $this->resolver->setRequired(array( | ||
619 | 'foo', | ||
620 | )); | ||
621 | $this->resolver->setDefaults(array( | ||
622 | 'foo' => 'bar', | ||
623 | )); | ||
624 | |||
625 | $this->assertEquals(array( | ||
626 | 'foo' => 'bar' | ||
627 | ), $this->resolver->resolve(array())); | ||
628 | } | ||
629 | |||
630 | public function testResolveWithoutOptionSucceedsIfDefaultValueAndRequired() | ||
631 | { | ||
632 | $this->resolver->setDefaults(array( | ||
633 | 'foo' => 'bar', | ||
634 | )); | ||
635 | $this->resolver->setRequired(array( | ||
636 | 'foo', | ||
637 | )); | ||
638 | |||
639 | $this->assertEquals(array( | ||
640 | 'foo' => 'bar' | ||
641 | ), $this->resolver->resolve(array())); | ||
642 | } | ||
643 | |||
644 | public function testResolveSucceedsIfOptionRequiredAndValueAllowed() | ||
645 | { | ||
646 | $this->resolver->setRequired(array( | ||
647 | 'one', 'two', | ||
648 | )); | ||
649 | $this->resolver->setAllowedValues(array( | ||
650 | 'two' => array('2'), | ||
651 | )); | ||
652 | |||
653 | $options = array( | ||
654 | 'one' => '1', | ||
655 | 'two' => '2' | ||
656 | ); | ||
657 | |||
658 | $this->assertEquals($options, $this->resolver->resolve($options)); | ||
659 | } | ||
660 | |||
661 | public function testClone() | ||
662 | { | ||
663 | $this->resolver->setDefaults(array('one' => '1')); | ||
664 | |||
665 | $clone = clone $this->resolver; | ||
666 | |||
667 | // Changes after cloning don't affect each other | ||
668 | $this->resolver->setDefaults(array('two' => '2')); | ||
669 | $clone->setDefaults(array('three' => '3')); | ||
670 | |||
671 | $this->assertEquals(array( | ||
672 | 'one' => '1', | ||
673 | 'two' => '2', | ||
674 | ), $this->resolver->resolve()); | ||
675 | |||
676 | $this->assertEquals(array( | ||
677 | 'one' => '1', | ||
678 | 'three' => '3', | ||
679 | ), $clone->resolve()); | ||
680 | } | ||
681 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsTest.php b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsTest.php new file mode 100644 index 00000000..e24a7647 --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/Tests/OptionsTest.php | |||
@@ -0,0 +1,529 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\OptionsResolver\Tests; | ||
13 | |||
14 | use Symfony\Component\OptionsResolver\Options; | ||
15 | |||
16 | class OptionsTest extends \PHPUnit_Framework_TestCase | ||
17 | { | ||
18 | /** | ||
19 | * @var Options | ||
20 | */ | ||
21 | private $options; | ||
22 | |||
23 | protected function setUp() | ||
24 | { | ||
25 | $this->options = new Options(); | ||
26 | } | ||
27 | |||
28 | public function testArrayAccess() | ||
29 | { | ||
30 | $this->assertFalse(isset($this->options['foo'])); | ||
31 | $this->assertFalse(isset($this->options['bar'])); | ||
32 | |||
33 | $this->options['foo'] = 0; | ||
34 | $this->options['bar'] = 1; | ||
35 | |||
36 | $this->assertTrue(isset($this->options['foo'])); | ||
37 | $this->assertTrue(isset($this->options['bar'])); | ||
38 | |||
39 | unset($this->options['bar']); | ||
40 | |||
41 | $this->assertTrue(isset($this->options['foo'])); | ||
42 | $this->assertFalse(isset($this->options['bar'])); | ||
43 | $this->assertEquals(0, $this->options['foo']); | ||
44 | } | ||
45 | |||
46 | public function testCountable() | ||
47 | { | ||
48 | $this->options->set('foo', 0); | ||
49 | $this->options->set('bar', 1); | ||
50 | |||
51 | $this->assertCount(2, $this->options); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @expectedException \OutOfBoundsException | ||
56 | */ | ||
57 | public function testGetNonExisting() | ||
58 | { | ||
59 | $this->options->get('foo'); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
64 | */ | ||
65 | public function testSetNotSupportedAfterGet() | ||
66 | { | ||
67 | $this->options->set('foo', 'bar'); | ||
68 | $this->options->get('foo'); | ||
69 | $this->options->set('foo', 'baz'); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
74 | */ | ||
75 | public function testRemoveNotSupportedAfterGet() | ||
76 | { | ||
77 | $this->options->set('foo', 'bar'); | ||
78 | $this->options->get('foo'); | ||
79 | $this->options->remove('foo'); | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
84 | */ | ||
85 | public function testSetNormalizerNotSupportedAfterGet() | ||
86 | { | ||
87 | $this->options->set('foo', 'bar'); | ||
88 | $this->options->get('foo'); | ||
89 | $this->options->setNormalizer('foo', function () {}); | ||
90 | } | ||
91 | |||
92 | public function testSetLazyOption() | ||
93 | { | ||
94 | $test = $this; | ||
95 | |||
96 | $this->options->set('foo', function (Options $options) use ($test) { | ||
97 | return 'dynamic'; | ||
98 | }); | ||
99 | |||
100 | $this->assertEquals('dynamic', $this->options->get('foo')); | ||
101 | } | ||
102 | |||
103 | public function testSetDiscardsPreviousValue() | ||
104 | { | ||
105 | $test = $this; | ||
106 | |||
107 | // defined by superclass | ||
108 | $this->options->set('foo', 'bar'); | ||
109 | |||
110 | // defined by subclass | ||
111 | $this->options->set('foo', function (Options $options, $previousValue) use ($test) { | ||
112 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
113 | $test->assertNull($previousValue); | ||
114 | |||
115 | return 'dynamic'; | ||
116 | }); | ||
117 | |||
118 | $this->assertEquals('dynamic', $this->options->get('foo')); | ||
119 | } | ||
120 | |||
121 | public function testOverloadKeepsPreviousValue() | ||
122 | { | ||
123 | $test = $this; | ||
124 | |||
125 | // defined by superclass | ||
126 | $this->options->set('foo', 'bar'); | ||
127 | |||
128 | // defined by subclass | ||
129 | $this->options->overload('foo', function (Options $options, $previousValue) use ($test) { | ||
130 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
131 | $test->assertEquals('bar', $previousValue); | ||
132 | |||
133 | return 'dynamic'; | ||
134 | }); | ||
135 | |||
136 | $this->assertEquals('dynamic', $this->options->get('foo')); | ||
137 | } | ||
138 | |||
139 | public function testPreviousValueIsEvaluatedIfLazy() | ||
140 | { | ||
141 | $test = $this; | ||
142 | |||
143 | // defined by superclass | ||
144 | $this->options->set('foo', function (Options $options) { | ||
145 | return 'bar'; | ||
146 | }); | ||
147 | |||
148 | // defined by subclass | ||
149 | $this->options->overload('foo', function (Options $options, $previousValue) use ($test) { | ||
150 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
151 | $test->assertEquals('bar', $previousValue); | ||
152 | |||
153 | return 'dynamic'; | ||
154 | }); | ||
155 | |||
156 | $this->assertEquals('dynamic', $this->options->get('foo')); | ||
157 | } | ||
158 | |||
159 | public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() | ||
160 | { | ||
161 | $test = $this; | ||
162 | |||
163 | // defined by superclass | ||
164 | $this->options->set('foo', function (Options $options) use ($test) { | ||
165 | $test->fail('Should not be called'); | ||
166 | }); | ||
167 | |||
168 | // defined by subclass, no $previousValue argument defined! | ||
169 | $this->options->overload('foo', function (Options $options) use ($test) { | ||
170 | return 'dynamic'; | ||
171 | }); | ||
172 | |||
173 | $this->assertEquals('dynamic', $this->options->get('foo')); | ||
174 | } | ||
175 | |||
176 | public function testLazyOptionCanAccessOtherOptions() | ||
177 | { | ||
178 | $test = $this; | ||
179 | |||
180 | $this->options->set('foo', 'bar'); | ||
181 | |||
182 | $this->options->set('bam', function (Options $options) use ($test) { | ||
183 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
184 | $test->assertEquals('bar', $options->get('foo')); | ||
185 | |||
186 | return 'dynamic'; | ||
187 | }); | ||
188 | |||
189 | $this->assertEquals('bar', $this->options->get('foo')); | ||
190 | $this->assertEquals('dynamic', $this->options->get('bam')); | ||
191 | } | ||
192 | |||
193 | public function testLazyOptionCanAccessOtherLazyOptions() | ||
194 | { | ||
195 | $test = $this; | ||
196 | |||
197 | $this->options->set('foo', function (Options $options) { | ||
198 | return 'bar'; | ||
199 | }); | ||
200 | |||
201 | $this->options->set('bam', function (Options $options) use ($test) { | ||
202 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
203 | $test->assertEquals('bar', $options->get('foo')); | ||
204 | |||
205 | return 'dynamic'; | ||
206 | }); | ||
207 | |||
208 | $this->assertEquals('bar', $this->options->get('foo')); | ||
209 | $this->assertEquals('dynamic', $this->options->get('bam')); | ||
210 | } | ||
211 | |||
212 | public function testNormalizer() | ||
213 | { | ||
214 | $this->options->set('foo', 'bar'); | ||
215 | |||
216 | $this->options->setNormalizer('foo', function () { | ||
217 | return 'normalized'; | ||
218 | }); | ||
219 | |||
220 | $this->assertEquals('normalized', $this->options->get('foo')); | ||
221 | } | ||
222 | |||
223 | public function testNormalizerReceivesUnnormalizedValue() | ||
224 | { | ||
225 | $this->options->set('foo', 'bar'); | ||
226 | |||
227 | $this->options->setNormalizer('foo', function (Options $options, $value) { | ||
228 | return 'normalized['.$value.']'; | ||
229 | }); | ||
230 | |||
231 | $this->assertEquals('normalized[bar]', $this->options->get('foo')); | ||
232 | } | ||
233 | |||
234 | public function testNormalizerCanAccessOtherOptions() | ||
235 | { | ||
236 | $test = $this; | ||
237 | |||
238 | $this->options->set('foo', 'bar'); | ||
239 | $this->options->set('bam', 'baz'); | ||
240 | |||
241 | $this->options->setNormalizer('bam', function (Options $options) use ($test) { | ||
242 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
243 | $test->assertEquals('bar', $options->get('foo')); | ||
244 | |||
245 | return 'normalized'; | ||
246 | }); | ||
247 | |||
248 | $this->assertEquals('bar', $this->options->get('foo')); | ||
249 | $this->assertEquals('normalized', $this->options->get('bam')); | ||
250 | } | ||
251 | |||
252 | public function testNormalizerCanAccessOtherLazyOptions() | ||
253 | { | ||
254 | $test = $this; | ||
255 | |||
256 | $this->options->set('foo', function (Options $options) { | ||
257 | return 'bar'; | ||
258 | }); | ||
259 | $this->options->set('bam', 'baz'); | ||
260 | |||
261 | $this->options->setNormalizer('bam', function (Options $options) use ($test) { | ||
262 | /* @var \PHPUnit_Framework_TestCase $test */ | ||
263 | $test->assertEquals('bar', $options->get('foo')); | ||
264 | |||
265 | return 'normalized'; | ||
266 | }); | ||
267 | |||
268 | $this->assertEquals('bar', $this->options->get('foo')); | ||
269 | $this->assertEquals('normalized', $this->options->get('bam')); | ||
270 | } | ||
271 | |||
272 | /** | ||
273 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
274 | */ | ||
275 | public function testFailForCyclicDependencies() | ||
276 | { | ||
277 | $this->options->set('foo', function (Options $options) { | ||
278 | $options->get('bam'); | ||
279 | }); | ||
280 | |||
281 | $this->options->set('bam', function (Options $options) { | ||
282 | $options->get('foo'); | ||
283 | }); | ||
284 | |||
285 | $this->options->get('foo'); | ||
286 | } | ||
287 | |||
288 | /** | ||
289 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
290 | */ | ||
291 | public function testFailForCyclicDependenciesBetweenNormalizers() | ||
292 | { | ||
293 | $this->options->set('foo', 'bar'); | ||
294 | $this->options->set('bam', 'baz'); | ||
295 | |||
296 | $this->options->setNormalizer('foo', function (Options $options) { | ||
297 | $options->get('bam'); | ||
298 | }); | ||
299 | |||
300 | $this->options->setNormalizer('bam', function (Options $options) { | ||
301 | $options->get('foo'); | ||
302 | }); | ||
303 | |||
304 | $this->options->get('foo'); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
309 | */ | ||
310 | public function testFailForCyclicDependenciesBetweenNormalizerAndLazyOption() | ||
311 | { | ||
312 | $this->options->set('foo', function (Options $options) { | ||
313 | $options->get('bam'); | ||
314 | }); | ||
315 | $this->options->set('bam', 'baz'); | ||
316 | |||
317 | $this->options->setNormalizer('bam', function (Options $options) { | ||
318 | $options->get('foo'); | ||
319 | }); | ||
320 | |||
321 | $this->options->get('foo'); | ||
322 | } | ||
323 | |||
324 | public function testAllInvokesEachLazyOptionOnlyOnce() | ||
325 | { | ||
326 | $test = $this; | ||
327 | $i = 1; | ||
328 | |||
329 | $this->options->set('foo', function (Options $options) use ($test, &$i) { | ||
330 | $test->assertSame(1, $i); | ||
331 | ++$i; | ||
332 | |||
333 | // Implicitly invoke lazy option for "bam" | ||
334 | $options->get('bam'); | ||
335 | }); | ||
336 | $this->options->set('bam', function (Options $options) use ($test, &$i) { | ||
337 | $test->assertSame(2, $i); | ||
338 | ++$i; | ||
339 | }); | ||
340 | |||
341 | $this->options->all(); | ||
342 | } | ||
343 | |||
344 | public function testAllInvokesEachNormalizerOnlyOnce() | ||
345 | { | ||
346 | $test = $this; | ||
347 | $i = 1; | ||
348 | |||
349 | $this->options->set('foo', 'bar'); | ||
350 | $this->options->set('bam', 'baz'); | ||
351 | |||
352 | $this->options->setNormalizer('foo', function (Options $options) use ($test, &$i) { | ||
353 | $test->assertSame(1, $i); | ||
354 | ++$i; | ||
355 | |||
356 | // Implicitly invoke normalizer for "bam" | ||
357 | $options->get('bam'); | ||
358 | }); | ||
359 | $this->options->setNormalizer('bam', function (Options $options) use ($test, &$i) { | ||
360 | $test->assertSame(2, $i); | ||
361 | ++$i; | ||
362 | }); | ||
363 | |||
364 | $this->options->all(); | ||
365 | } | ||
366 | |||
367 | public function testReplaceClearsAndSets() | ||
368 | { | ||
369 | $this->options->set('one', '1'); | ||
370 | |||
371 | $this->options->replace(array( | ||
372 | 'two' => '2', | ||
373 | 'three' => function (Options $options) { | ||
374 | return '2' === $options['two'] ? '3' : 'foo'; | ||
375 | } | ||
376 | )); | ||
377 | |||
378 | $this->assertEquals(array( | ||
379 | 'two' => '2', | ||
380 | 'three' => '3', | ||
381 | ), $this->options->all()); | ||
382 | } | ||
383 | |||
384 | public function testClearRemovesAllOptions() | ||
385 | { | ||
386 | $this->options->set('one', 1); | ||
387 | $this->options->set('two', 2); | ||
388 | |||
389 | $this->options->clear(); | ||
390 | |||
391 | $this->assertEmpty($this->options->all()); | ||
392 | |||
393 | } | ||
394 | |||
395 | /** | ||
396 | * @covers Symfony\Component\OptionsResolver\Options::replace | ||
397 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
398 | */ | ||
399 | public function testCannotReplaceAfterOptionWasRead() | ||
400 | { | ||
401 | $this->options->set('one', 1); | ||
402 | $this->options->all(); | ||
403 | |||
404 | $this->options->replace(array( | ||
405 | 'two' => '2', | ||
406 | )); | ||
407 | } | ||
408 | |||
409 | /** | ||
410 | * @covers Symfony\Component\OptionsResolver\Options::overload | ||
411 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
412 | */ | ||
413 | public function testCannotOverloadAfterOptionWasRead() | ||
414 | { | ||
415 | $this->options->set('one', 1); | ||
416 | $this->options->all(); | ||
417 | |||
418 | $this->options->overload('one', 2); | ||
419 | } | ||
420 | |||
421 | /** | ||
422 | * @covers Symfony\Component\OptionsResolver\Options::clear | ||
423 | * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException | ||
424 | */ | ||
425 | public function testCannotClearAfterOptionWasRead() | ||
426 | { | ||
427 | $this->options->set('one', 1); | ||
428 | $this->options->all(); | ||
429 | |||
430 | $this->options->clear(); | ||
431 | } | ||
432 | |||
433 | public function testOverloadCannotBeEvaluatedLazilyWithoutExpectedClosureParams() | ||
434 | { | ||
435 | $this->options->set('foo', 'bar'); | ||
436 | |||
437 | $this->options->overload('foo', function () { | ||
438 | return 'test'; | ||
439 | }); | ||
440 | |||
441 | $this->assertNotEquals('test', $this->options->get('foo')); | ||
442 | $this->assertTrue(is_callable($this->options->get('foo'))); | ||
443 | } | ||
444 | |||
445 | public function testOverloadCannotBeEvaluatedLazilyWithoutFirstParamTypeHint() | ||
446 | { | ||
447 | $this->options->set('foo', 'bar'); | ||
448 | |||
449 | $this->options->overload('foo', function ($object) { | ||
450 | return 'test'; | ||
451 | }); | ||
452 | |||
453 | $this->assertNotEquals('test', $this->options->get('foo')); | ||
454 | $this->assertTrue(is_callable($this->options->get('foo'))); | ||
455 | } | ||
456 | |||
457 | public function testOptionsIteration() | ||
458 | { | ||
459 | $this->options->set('foo', 'bar'); | ||
460 | $this->options->set('foo1', 'bar1'); | ||
461 | $expectedResult = array('foo' => 'bar', 'foo1' => 'bar1'); | ||
462 | |||
463 | $this->assertEquals($expectedResult, iterator_to_array($this->options, true)); | ||
464 | } | ||
465 | |||
466 | public function testHasWithNullValue() | ||
467 | { | ||
468 | $this->options->set('foo', null); | ||
469 | |||
470 | $this->assertTrue($this->options->has('foo')); | ||
471 | } | ||
472 | |||
473 | public function testRemoveOptionAndNormalizer() | ||
474 | { | ||
475 | $this->options->set('foo1', 'bar'); | ||
476 | $this->options->setNormalizer('foo1', function (Options $options) { | ||
477 | return ''; | ||
478 | }); | ||
479 | $this->options->set('foo2', 'bar'); | ||
480 | $this->options->setNormalizer('foo2', function (Options $options) { | ||
481 | return ''; | ||
482 | }); | ||
483 | |||
484 | $this->options->remove('foo2'); | ||
485 | $this->assertEquals(array('foo1' => ''), $this->options->all()); | ||
486 | } | ||
487 | |||
488 | public function testReplaceOptionAndNormalizer() | ||
489 | { | ||
490 | $this->options->set('foo1', 'bar'); | ||
491 | $this->options->setNormalizer('foo1', function (Options $options) { | ||
492 | return ''; | ||
493 | }); | ||
494 | $this->options->set('foo2', 'bar'); | ||
495 | $this->options->setNormalizer('foo2', function (Options $options) { | ||
496 | return ''; | ||
497 | }); | ||
498 | |||
499 | $this->options->replace(array('foo1' => 'new')); | ||
500 | $this->assertEquals(array('foo1' => 'new'), $this->options->all()); | ||
501 | } | ||
502 | |||
503 | public function testClearOptionAndNormalizer() | ||
504 | { | ||
505 | $this->options->set('foo1', 'bar'); | ||
506 | $this->options->setNormalizer('foo1', function (Options $options) { | ||
507 | return ''; | ||
508 | }); | ||
509 | $this->options->set('foo2', 'bar'); | ||
510 | $this->options->setNormalizer('foo2', function (Options $options) { | ||
511 | return ''; | ||
512 | }); | ||
513 | |||
514 | $this->options->clear(); | ||
515 | $this->assertEmpty($this->options->all()); | ||
516 | } | ||
517 | |||
518 | public function testNormalizerWithoutCorrespondingOption() | ||
519 | { | ||
520 | $test = $this; | ||
521 | |||
522 | $this->options->setNormalizer('foo', function (Options $options, $previousValue) use ($test) { | ||
523 | $test->assertNull($previousValue); | ||
524 | |||
525 | return ''; | ||
526 | }); | ||
527 | $this->assertEquals(array('foo' => ''), $this->options->all()); | ||
528 | } | ||
529 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/composer.json b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/composer.json new file mode 100644 index 00000000..f13d246e --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/composer.json | |||
@@ -0,0 +1,31 @@ | |||
1 | { | ||
2 | "name": "symfony/options-resolver", | ||
3 | "type": "library", | ||
4 | "description": "Symfony OptionsResolver Component", | ||
5 | "keywords": ["options", "config", "configuration"], | ||
6 | "homepage": "http://symfony.com", | ||
7 | "license": "MIT", | ||
8 | "authors": [ | ||
9 | { | ||
10 | "name": "Fabien Potencier", | ||
11 | "email": "fabien@symfony.com" | ||
12 | }, | ||
13 | { | ||
14 | "name": "Symfony Community", | ||
15 | "homepage": "http://symfony.com/contributors" | ||
16 | } | ||
17 | ], | ||
18 | "require": { | ||
19 | "php": ">=5.3.3" | ||
20 | }, | ||
21 | "autoload": { | ||
22 | "psr-0": { "Symfony\\Component\\OptionsResolver\\": "" } | ||
23 | }, | ||
24 | "target-dir": "Symfony/Component/OptionsResolver", | ||
25 | "minimum-stability": "dev", | ||
26 | "extra": { | ||
27 | "branch-alias": { | ||
28 | "dev-master": "2.3-dev" | ||
29 | } | ||
30 | } | ||
31 | } | ||
diff --git a/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/phpunit.xml.dist b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/phpunit.xml.dist new file mode 100644 index 00000000..ad24d17b --- /dev/null +++ b/vendor/symfony/options-resolver/Symfony/Component/OptionsResolver/phpunit.xml.dist | |||
@@ -0,0 +1,29 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | |||
3 | <phpunit backupGlobals="false" | ||
4 | backupStaticAttributes="false" | ||
5 | colors="true" | ||
6 | convertErrorsToExceptions="true" | ||
7 | convertNoticesToExceptions="true" | ||
8 | convertWarningsToExceptions="true" | ||
9 | processIsolation="false" | ||
10 | stopOnFailure="false" | ||
11 | syntaxCheck="false" | ||
12 | bootstrap="vendor/autoload.php" | ||
13 | > | ||
14 | <testsuites> | ||
15 | <testsuite name="Symfony OptionsResolver Component Test Suite"> | ||
16 | <directory>./Tests/</directory> | ||
17 | </testsuite> | ||
18 | </testsuites> | ||
19 | |||
20 | <filter> | ||
21 | <whitelist> | ||
22 | <directory>./</directory> | ||
23 | <exclude> | ||
24 | <directory>./Resources</directory> | ||
25 | <directory>./Tests</directory> | ||
26 | </exclude> | ||
27 | </whitelist> | ||
28 | </filter> | ||
29 | </phpunit> | ||