aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
commit4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch)
tree6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php
parent2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff)
downloadwallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip
twig implementation
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php')
-rw-r--r--vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php147
1 files changed, 147 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php
new file mode 100644
index 00000000..29118187
--- /dev/null
+++ b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php
@@ -0,0 +1,147 @@
1<?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Form\Tests;
13
14use Symfony\Component\Form\FormBuilder;
15use Symfony\Component\EventDispatcher\EventDispatcher;
16use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
18abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase
19{
20 /**
21 * @var EventDispatcherInterface
22 */
23 protected $dispatcher;
24
25 /**
26 * @var \Symfony\Component\Form\FormFactoryInterface
27 */
28 protected $factory;
29
30 /**
31 * @var \Symfony\Component\Form\FormInterface
32 */
33 protected $form;
34
35 protected function setUp()
36 {
37 if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) {
38 $this->markTestSkipped('The "EventDispatcher" component is not available');
39 }
40
41 // We need an actual dispatcher to use the deprecated
42 // bindRequest() method
43 $this->dispatcher = new EventDispatcher();
44 $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
45 $this->form = $this->createForm();
46 }
47
48 protected function tearDown()
49 {
50 $this->dispatcher = null;
51 $this->factory = null;
52 $this->form = null;
53 }
54
55 /**
56 * @return \Symfony\Component\Form\FormInterface
57 */
58 abstract protected function createForm();
59
60 /**
61 * @param string $name
62 * @param EventDispatcherInterface $dispatcher
63 * @param string $dataClass
64 *
65 * @return FormBuilder
66 */
67 protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null, $dataClass = null)
68 {
69 return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory);
70 }
71
72 /**
73 * @param string $name
74 *
75 * @return \PHPUnit_Framework_MockObject_MockObject
76 */
77 protected function getMockForm($name = 'name')
78 {
79 $form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
80 $config = $this->getMock('Symfony\Component\Form\FormConfigInterface');
81
82 $form->expects($this->any())
83 ->method('getName')
84 ->will($this->returnValue($name));
85 $form->expects($this->any())
86 ->method('getConfig')
87 ->will($this->returnValue($config));
88
89 return $form;
90 }
91
92 /**
93 * @param string $name
94 *
95 * @return \PHPUnit_Framework_MockObject_MockObject
96 */
97 protected function getValidForm($name)
98 {
99 $form = $this->getMockForm($name);
100
101 $form->expects($this->any())
102 ->method('isValid')
103 ->will($this->returnValue(true));
104
105 return $form;
106 }
107
108 /**
109 * @param string $name
110 *
111 * @return \PHPUnit_Framework_MockObject_MockObject
112 */
113 protected function getInvalidForm($name)
114 {
115 $form = $this->getMockForm($name);
116
117 $form->expects($this->any())
118 ->method('isValid')
119 ->will($this->returnValue(false));
120
121 return $form;
122 }
123
124 /**
125 * @return \PHPUnit_Framework_MockObject_MockObject
126 */
127 protected function getDataMapper()
128 {
129 return $this->getMock('Symfony\Component\Form\DataMapperInterface');
130 }
131
132 /**
133 * @return \PHPUnit_Framework_MockObject_MockObject
134 */
135 protected function getDataTransformer()
136 {
137 return $this->getMock('Symfony\Component\Form\DataTransformerInterface');
138 }
139
140 /**
141 * @return \PHPUnit_Framework_MockObject_MockObject
142 */
143 protected function getFormValidator()
144 {
145 return $this->getMock('Symfony\Component\Form\FormValidatorInterface');
146 }
147}