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/Core/Type/BaseTypeTest.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/Core/Type/BaseTypeTest.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php new file mode 100644 index 00000000..bfa1e218 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php | |||
@@ -0,0 +1,135 @@ | |||
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\Core\Type; | ||
13 | |||
14 | /** | ||
15 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
16 | */ | ||
17 | abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase | ||
18 | { | ||
19 | public function testPassDisabledAsOption() | ||
20 | { | ||
21 | $form = $this->factory->create($this->getTestedType(), null, array('disabled' => true)); | ||
22 | |||
23 | $this->assertTrue($form->isDisabled()); | ||
24 | } | ||
25 | |||
26 | public function testPassIdAndNameToView() | ||
27 | { | ||
28 | $view = $this->factory->createNamed('name', $this->getTestedType()) | ||
29 | ->createView(); | ||
30 | |||
31 | $this->assertEquals('name', $view->vars['id']); | ||
32 | $this->assertEquals('name', $view->vars['name']); | ||
33 | $this->assertEquals('name', $view->vars['full_name']); | ||
34 | } | ||
35 | |||
36 | public function testStripLeadingUnderscoresAndDigitsFromId() | ||
37 | { | ||
38 | $view = $this->factory->createNamed('_09name', $this->getTestedType()) | ||
39 | ->createView(); | ||
40 | |||
41 | $this->assertEquals('name', $view->vars['id']); | ||
42 | $this->assertEquals('_09name', $view->vars['name']); | ||
43 | $this->assertEquals('_09name', $view->vars['full_name']); | ||
44 | } | ||
45 | |||
46 | public function testPassIdAndNameToViewWithParent() | ||
47 | { | ||
48 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
49 | ->add('child', $this->getTestedType()) | ||
50 | ->getForm() | ||
51 | ->createView(); | ||
52 | |||
53 | $this->assertEquals('parent_child', $view['child']->vars['id']); | ||
54 | $this->assertEquals('child', $view['child']->vars['name']); | ||
55 | $this->assertEquals('parent[child]', $view['child']->vars['full_name']); | ||
56 | } | ||
57 | |||
58 | public function testPassIdAndNameToViewWithGrandParent() | ||
59 | { | ||
60 | $builder = $this->factory->createNamedBuilder('parent', 'form') | ||
61 | ->add('child', 'form'); | ||
62 | $builder->get('child')->add('grand_child', $this->getTestedType()); | ||
63 | $view = $builder->getForm()->createView(); | ||
64 | |||
65 | $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); | ||
66 | $this->assertEquals('grand_child', $view['child']['grand_child']->vars['name']); | ||
67 | $this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->vars['full_name']); | ||
68 | } | ||
69 | |||
70 | public function testPassTranslationDomainToView() | ||
71 | { | ||
72 | $form = $this->factory->create($this->getTestedType(), null, array( | ||
73 | 'translation_domain' => 'domain', | ||
74 | )); | ||
75 | $view = $form->createView(); | ||
76 | |||
77 | $this->assertSame('domain', $view->vars['translation_domain']); | ||
78 | } | ||
79 | |||
80 | public function testInheritTranslationDomainFromParent() | ||
81 | { | ||
82 | $view = $this->factory | ||
83 | ->createNamedBuilder('parent', 'form', null, array( | ||
84 | 'translation_domain' => 'domain', | ||
85 | )) | ||
86 | ->add('child', $this->getTestedType()) | ||
87 | ->getForm() | ||
88 | ->createView(); | ||
89 | |||
90 | $this->assertEquals('domain', $view['child']->vars['translation_domain']); | ||
91 | } | ||
92 | |||
93 | public function testPreferOwnTranslationDomain() | ||
94 | { | ||
95 | $view = $this->factory | ||
96 | ->createNamedBuilder('parent', 'form', null, array( | ||
97 | 'translation_domain' => 'parent_domain', | ||
98 | )) | ||
99 | ->add('child', $this->getTestedType(), array( | ||
100 | 'translation_domain' => 'domain', | ||
101 | )) | ||
102 | ->getForm() | ||
103 | ->createView(); | ||
104 | |||
105 | $this->assertEquals('domain', $view['child']->vars['translation_domain']); | ||
106 | } | ||
107 | |||
108 | public function testDefaultTranslationDomain() | ||
109 | { | ||
110 | $view = $this->factory->createNamedBuilder('parent', 'form') | ||
111 | ->add('child', $this->getTestedType()) | ||
112 | ->getForm() | ||
113 | ->createView(); | ||
114 | |||
115 | $this->assertEquals('messages', $view['child']->vars['translation_domain']); | ||
116 | } | ||
117 | |||
118 | public function testPassLabelToView() | ||
119 | { | ||
120 | $form = $this->factory->createNamed('__test___field', $this->getTestedType(), null, array('label' => 'My label')); | ||
121 | $view = $form->createView(); | ||
122 | |||
123 | $this->assertSame('My label', $view->vars['label']); | ||
124 | } | ||
125 | |||
126 | public function testPassMultipartFalseToView() | ||
127 | { | ||
128 | $form = $this->factory->create($this->getTestedType()); | ||
129 | $view = $form->createView(); | ||
130 | |||
131 | $this->assertFalse($view->vars['multipart']); | ||
132 | } | ||
133 | |||
134 | abstract protected function getTestedType(); | ||
135 | } | ||