diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures')
13 files changed, 540 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php new file mode 100644 index 00000000..ee7d1353 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\FormEvents; | ||
7 | use Symfony\Component\Form\FormEvent; | ||
8 | use Symfony\Component\Form\FormBuilderInterface; | ||
9 | |||
10 | class AlternatingRowType extends AbstractType | ||
11 | { | ||
12 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
13 | { | ||
14 | $formFactory = $builder->getFormFactory(); | ||
15 | |||
16 | $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { | ||
17 | $form = $event->getForm(); | ||
18 | $type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; | ||
19 | $form->add('title', $type); | ||
20 | }); | ||
21 | } | ||
22 | |||
23 | public function getName() | ||
24 | { | ||
25 | return 'alternating_row'; | ||
26 | } | ||
27 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php new file mode 100644 index 00000000..11204894 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php | |||
@@ -0,0 +1,71 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | class Author | ||
15 | { | ||
16 | public $firstName; | ||
17 | private $lastName; | ||
18 | private $australian; | ||
19 | public $child; | ||
20 | private $readPermissions; | ||
21 | |||
22 | private $privateProperty; | ||
23 | |||
24 | public function setLastName($lastName) | ||
25 | { | ||
26 | $this->lastName = $lastName; | ||
27 | } | ||
28 | |||
29 | public function getLastName() | ||
30 | { | ||
31 | return $this->lastName; | ||
32 | } | ||
33 | |||
34 | private function getPrivateGetter() | ||
35 | { | ||
36 | return 'foobar'; | ||
37 | } | ||
38 | |||
39 | public function setAustralian($australian) | ||
40 | { | ||
41 | $this->australian = $australian; | ||
42 | } | ||
43 | |||
44 | public function isAustralian() | ||
45 | { | ||
46 | return $this->australian; | ||
47 | } | ||
48 | |||
49 | public function setReadPermissions($bool) | ||
50 | { | ||
51 | $this->readPermissions = $bool; | ||
52 | } | ||
53 | |||
54 | public function hasReadPermissions() | ||
55 | { | ||
56 | return $this->readPermissions; | ||
57 | } | ||
58 | |||
59 | private function isPrivateIsser() | ||
60 | { | ||
61 | return true; | ||
62 | } | ||
63 | |||
64 | public function getPrivateSetter() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | private function setPrivateSetter($data) | ||
69 | { | ||
70 | } | ||
71 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php new file mode 100644 index 00000000..147f6e48 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php | |||
@@ -0,0 +1,30 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
4 | |||
5 | use Symfony\Component\Form\AbstractType; | ||
6 | use Symfony\Component\Form\FormBuilderInterface; | ||
7 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
8 | |||
9 | class AuthorType extends AbstractType | ||
10 | { | ||
11 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
12 | { | ||
13 | $builder | ||
14 | ->add('firstName') | ||
15 | ->add('lastName') | ||
16 | ; | ||
17 | } | ||
18 | |||
19 | public function getName() | ||
20 | { | ||
21 | return 'author'; | ||
22 | } | ||
23 | |||
24 | public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
25 | { | ||
26 | $resolver->setDefaults(array( | ||
27 | 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', | ||
28 | )); | ||
29 | } | ||
30 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php new file mode 100644 index 00000000..950f677f --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php | |||
@@ -0,0 +1,70 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | /** | ||
15 | * This class is a hand written simplified version of PHP native `ArrayObject` | ||
16 | * class, to show that it behaves differently than the PHP native implementation. | ||
17 | */ | ||
18 | class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable | ||
19 | { | ||
20 | private $array; | ||
21 | |||
22 | public function __construct(array $array = null) | ||
23 | { | ||
24 | $this->array = $array ?: array(); | ||
25 | } | ||
26 | |||
27 | public function offsetExists($offset) | ||
28 | { | ||
29 | return array_key_exists($offset, $this->array); | ||
30 | } | ||
31 | |||
32 | public function offsetGet($offset) | ||
33 | { | ||
34 | return $this->array[$offset]; | ||
35 | } | ||
36 | |||
37 | public function offsetSet($offset, $value) | ||
38 | { | ||
39 | if (null === $offset) { | ||
40 | $this->array[] = $value; | ||
41 | } else { | ||
42 | $this->array[$offset] = $value; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public function offsetUnset($offset) | ||
47 | { | ||
48 | unset($this->array[$offset]); | ||
49 | } | ||
50 | |||
51 | public function getIterator() | ||
52 | { | ||
53 | return new \ArrayIterator($this->array); | ||
54 | } | ||
55 | |||
56 | public function count() | ||
57 | { | ||
58 | return count($this->array); | ||
59 | } | ||
60 | |||
61 | public function serialize() | ||
62 | { | ||
63 | return serialize($this->array); | ||
64 | } | ||
65 | |||
66 | public function unserialize($serialized) | ||
67 | { | ||
68 | $this->array = (array) unserialize((string) $serialized); | ||
69 | } | ||
70 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php new file mode 100644 index 00000000..a5a31248 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\DataTransformerInterface; | ||
15 | use Symfony\Component\Form\Exception\RuntimeException; | ||
16 | |||
17 | class FixedDataTransformer implements DataTransformerInterface | ||
18 | { | ||
19 | private $mapping; | ||
20 | |||
21 | public function __construct(array $mapping) | ||
22 | { | ||
23 | $this->mapping = $mapping; | ||
24 | } | ||
25 | |||
26 | public function transform($value) | ||
27 | { | ||
28 | if (!array_key_exists($value, $this->mapping)) { | ||
29 | throw new RuntimeException(sprintf('No mapping for value "%s"', $value)); | ||
30 | } | ||
31 | |||
32 | return $this->mapping[$value]; | ||
33 | } | ||
34 | |||
35 | public function reverseTransform($value) | ||
36 | { | ||
37 | $result = array_search($value, $this->mapping, true); | ||
38 | |||
39 | if ($result === false) { | ||
40 | throw new RuntimeException(sprintf('No reverse mapping for value "%s"', $value)); | ||
41 | } | ||
42 | |||
43 | return $result; | ||
44 | } | ||
45 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php new file mode 100644 index 00000000..762a10b8 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php | |||
@@ -0,0 +1,66 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvents; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
17 | |||
18 | class FixedFilterListener implements EventSubscriberInterface | ||
19 | { | ||
20 | private $mapping; | ||
21 | |||
22 | public function __construct(array $mapping) | ||
23 | { | ||
24 | $this->mapping = array_merge(array( | ||
25 | 'preSubmit' => array(), | ||
26 | 'onSubmit' => array(), | ||
27 | 'preSetData' => array(), | ||
28 | ), $mapping); | ||
29 | } | ||
30 | |||
31 | public function preSubmit(FormEvent $event) | ||
32 | { | ||
33 | $data = $event->getData(); | ||
34 | |||
35 | if (isset($this->mapping['preSubmit'][$data])) { | ||
36 | $event->setData($this->mapping['preSubmit'][$data]); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | public function onSubmit(FormEvent $event) | ||
41 | { | ||
42 | $data = $event->getData(); | ||
43 | |||
44 | if (isset($this->mapping['onSubmit'][$data])) { | ||
45 | $event->setData($this->mapping['onSubmit'][$data]); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | public function preSetData(FormEvent $event) | ||
50 | { | ||
51 | $data = $event->getData(); | ||
52 | |||
53 | if (isset($this->mapping['preSetData'][$data])) { | ||
54 | $event->setData($this->mapping['preSetData'][$data]); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | public static function getSubscribedEvents() | ||
59 | { | ||
60 | return array( | ||
61 | FormEvents::PRE_SUBMIT => 'preSubmit', | ||
62 | FormEvents::SUBMIT => 'onSubmit', | ||
63 | FormEvents::PRE_SET_DATA => 'preSetData', | ||
64 | ); | ||
65 | } | ||
66 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php new file mode 100644 index 00000000..4f7ba6d4 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooSubType extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo_sub_type'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return 'foo'; | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php new file mode 100644 index 00000000..468b5a32 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooSubTypeWithParentInstance extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo_sub_type_parent_instance'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return new FooType(); | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php new file mode 100644 index 00000000..d26d3f76 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractType; | ||
15 | use Symfony\Component\Form\FormBuilder; | ||
16 | use Symfony\Component\Form\FormBuilderInterface; | ||
17 | use Symfony\Component\Form\FormFactoryInterface; | ||
18 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
19 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
20 | |||
21 | class FooType extends AbstractType | ||
22 | { | ||
23 | public function getName() | ||
24 | { | ||
25 | return 'foo'; | ||
26 | } | ||
27 | |||
28 | public function getParent() | ||
29 | { | ||
30 | return null; | ||
31 | } | ||
32 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php new file mode 100644 index 00000000..c5f92e11 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php | |||
@@ -0,0 +1,35 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractTypeExtension; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | |||
17 | class FooTypeBarExtension extends AbstractTypeExtension | ||
18 | { | ||
19 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | { | ||
21 | $builder->setAttribute('bar', 'x'); | ||
22 | } | ||
23 | |||
24 | public function getAllowedOptionValues() | ||
25 | { | ||
26 | return array( | ||
27 | 'a_or_b' => array('c'), | ||
28 | ); | ||
29 | } | ||
30 | |||
31 | public function getExtendedType() | ||
32 | { | ||
33 | return 'foo'; | ||
34 | } | ||
35 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php new file mode 100644 index 00000000..2e364754 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php | |||
@@ -0,0 +1,28 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\AbstractTypeExtension; | ||
15 | use Symfony\Component\Form\FormBuilderInterface; | ||
16 | |||
17 | class FooTypeBazExtension extends AbstractTypeExtension | ||
18 | { | ||
19 | public function buildForm(FormBuilderInterface $builder, array $options) | ||
20 | { | ||
21 | $builder->setAttribute('baz', 'x'); | ||
22 | } | ||
23 | |||
24 | public function getExtendedType() | ||
25 | { | ||
26 | return 'foo'; | ||
27 | } | ||
28 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php new file mode 100644 index 00000000..f9de560f --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php | |||
@@ -0,0 +1,72 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Fixtures; | ||
13 | |||
14 | use Symfony\Component\Form\FormTypeInterface; | ||
15 | use Symfony\Component\Form\FormTypeExtensionInterface; | ||
16 | use Symfony\Component\Form\FormTypeGuesserInterface; | ||
17 | use Symfony\Component\Form\FormExtensionInterface; | ||
18 | |||
19 | class TestExtension implements FormExtensionInterface | ||
20 | { | ||
21 | private $types = array(); | ||
22 | |||
23 | private $extensions = array(); | ||
24 | |||
25 | private $guesser; | ||
26 | |||
27 | public function __construct(FormTypeGuesserInterface $guesser) | ||
28 | { | ||
29 | $this->guesser = $guesser; | ||
30 | } | ||
31 | |||
32 | public function addType(FormTypeInterface $type) | ||
33 | { | ||
34 | $this->types[$type->getName()] = $type; | ||
35 | } | ||
36 | |||
37 | public function getType($name) | ||
38 | { | ||
39 | return isset($this->types[$name]) ? $this->types[$name] : null; | ||
40 | } | ||
41 | |||
42 | public function hasType($name) | ||
43 | { | ||
44 | return isset($this->types[$name]); | ||
45 | } | ||
46 | |||
47 | public function addTypeExtension(FormTypeExtensionInterface $extension) | ||
48 | { | ||
49 | $type = $extension->getExtendedType(); | ||
50 | |||
51 | if (!isset($this->extensions[$type])) { | ||
52 | $this->extensions[$type] = array(); | ||
53 | } | ||
54 | |||
55 | $this->extensions[$type][] = $extension; | ||
56 | } | ||
57 | |||
58 | public function getTypeExtensions($name) | ||
59 | { | ||
60 | return isset($this->extensions[$name]) ? $this->extensions[$name] : array(); | ||
61 | } | ||
62 | |||
63 | public function hasTypeExtensions($name) | ||
64 | { | ||
65 | return isset($this->extensions[$name]); | ||
66 | } | ||
67 | |||
68 | public function getTypeGuesser() | ||
69 | { | ||
70 | return $this->guesser; | ||
71 | } | ||
72 | } | ||
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo | |||