Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b94747

Browse filesBrowse files
author
Stuart Grimshaw
committed
| Q | A
| ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.1+ | Fixed tickets | 2485 Fixes the documented example of how to test forms with custom types, as there was no better suggestions than the one put forward by @chrisburgess7 I implemented that in my test case & it worked so I've updated the documentation to match.
1 parent 9aad603 commit 2b94747
Copy full SHA for 2b94747

File tree

Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-3
lines changed

‎cookbook/form/unit_testing.rst

Copy file name to clipboardExpand all lines: cookbook/form/unit_testing.rst
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,20 @@ before creating the parent form::
123123
namespace Acme\TestBundle\Tests\Form\Type;
124124

125125
use Acme\TestBundle\Form\Type\TestedType;
126+
use Acme\TestBundle\Form\Forms;
126127
use Acme\TestBundle\Model\TestObject;
127128
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
128129

129130
class TestedTypeTest extends TypeTestCase
130131
{
131132
public function testBindValidData()
132133
{
133-
$this->factory->addType(new TestChildType());
134-
135134
$type = new TestedType();
136-
$form = $this->factory->create($type);
135+
136+
$form = Forms::createFormFactoryBuilder()
137+
->addType(new TestChildType())
138+
->getFormFactory()
139+
->create($type);
137140

138141
// ... your test
139142
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.