Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit83641f8

Browse files
Ulrichweaverryan
Ulrich
authored andcommitted
Update how to add custom Type
New in sf2.3, update the way we have to use to add custom Type.
1 parentba4a5a8 commit83641f8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎cookbook/form/unit_testing.rst‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,28 @@ might look like this::
117117

118118
To create your form correctly, you need to make the type available to the
119119
form factory in your test. The easiest way is to register it manually
120-
before creating the parent form::
120+
before creating the parent form using PreloadedExtension class::
121121

122122
// src/Acme/TestBundle/Tests/Form/Type/TestedTypeTests.php
123123
namespace Acme\TestBundle\Tests\Form\Type;
124124

125125
use Acme\TestBundle\Form\Type\TestedType;
126126
use Acme\TestBundle\Model\TestObject;
127-
use Symfony\Component\Form\Tests\Extension\Core\Type\TypeTestCase;
127+
use Symfony\Component\Form\Test\TypeTestCase;
128+
use Symfony\Component\Form\PreloadedExtension;
128129

129130
class TestedTypeTest extends TypeTestCase
130131
{
131-
public functiontestBindValidData()
132+
protected functiongetExtensions()
132133
{
133-
$this->factory->addType(new TestChildType());
134+
$childType = new TestChildType();
135+
return array(new PreloadedExtension(array(
136+
$childType->getName() => $childType
137+
), array()));
138+
}
134139

140+
public function testBindValidData()
141+
{
135142
$type = new TestedType();
136143
$form = $this->factory->create($type);
137144

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp