diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php new file mode 100644 index 00000000..66194105 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php | |||
@@ -0,0 +1,85 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Validator\Type; | ||
13 | |||
14 | use Symfony\Component\Form\FormInterface; | ||
15 | |||
16 | class FormTypeValidatorExtensionTest extends TypeTestCase | ||
17 | { | ||
18 | public function testValidationGroupNullByDefault() | ||
19 | { | ||
20 | $form = $this->factory->create('form'); | ||
21 | |||
22 | $this->assertNull($form->getConfig()->getOption('validation_groups')); | ||
23 | } | ||
24 | |||
25 | public function testValidationGroupsTransformedToArray() | ||
26 | { | ||
27 | $form = $this->factory->create('form', null, array( | ||
28 | 'validation_groups' => 'group', | ||
29 | )); | ||
30 | |||
31 | $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); | ||
32 | } | ||
33 | |||
34 | public function testValidationGroupsCanBeSetToArray() | ||
35 | { | ||
36 | $form = $this->factory->create('form', null, array( | ||
37 | 'validation_groups' => array('group1', 'group2'), | ||
38 | )); | ||
39 | |||
40 | $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); | ||
41 | } | ||
42 | |||
43 | public function testValidationGroupsCanBeSetToFalse() | ||
44 | { | ||
45 | $form = $this->factory->create('form', null, array( | ||
46 | 'validation_groups' => false, | ||
47 | )); | ||
48 | |||
49 | $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); | ||
50 | } | ||
51 | |||
52 | public function testValidationGroupsCanBeSetToCallback() | ||
53 | { | ||
54 | $form = $this->factory->create('form', null, array( | ||
55 | 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), | ||
56 | )); | ||
57 | |||
58 | $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
59 | } | ||
60 | |||
61 | public function testValidationGroupsCanBeSetToClosure() | ||
62 | { | ||
63 | $form = $this->factory->create('form', null, array( | ||
64 | 'validation_groups' => function(FormInterface $form){ return null; }, | ||
65 | )); | ||
66 | |||
67 | $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); | ||
68 | } | ||
69 | |||
70 | public function testSubmitValidatesData() | ||
71 | { | ||
72 | $builder = $this->factory->createBuilder('form', null, array( | ||
73 | 'validation_groups' => 'group', | ||
74 | )); | ||
75 | $builder->add('firstName', 'form'); | ||
76 | $form = $builder->getForm(); | ||
77 | |||
78 | $this->validator->expects($this->once()) | ||
79 | ->method('validate') | ||
80 | ->with($this->equalTo($form)); | ||
81 | |||
82 | // specific data is irrelevant | ||
83 | $form->submit(array()); | ||
84 | } | ||
85 | } | ||