From a82e41cc9e782876f945579f440e079175ffead4 Mon Sep 17 00:00:00 2001 From: Ulrich Date: Thu, 13 Jun 2013 17:36:11 +0300 Subject: [PATCH 1/2] Update how to add custom Type New in sf2.3, update the way we have to use to add custom Type. --- cookbook/form/unit_testing.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cookbook/form/unit_testing.rst b/cookbook/form/unit_testing.rst index 8522f39efa9..fdbdd25a43d 100644 --- a/cookbook/form/unit_testing.rst +++ b/cookbook/form/unit_testing.rst @@ -117,7 +117,7 @@ might look like this:: To create your form correctly, you need to make the type available to the form factory in your test. The easiest way is to register it manually -before creating the parent form:: +before creating the parent form using PreloadedExtension class:: // src/Acme/TestBundle/Tests/Form/Type/TestedTypeTests.php namespace Acme\TestBundle\Tests\Form\Type; @@ -125,13 +125,20 @@ before creating the parent form:: use Acme\TestBundle\Form\Type\TestedType; use Acme\TestBundle\Model\TestObject; use Symfony\Component\Form\Test\TypeTestCase; + use Symfony\Component\Form\PreloadedExtension; class TestedTypeTest extends TypeTestCase { - public function testSubmitValidData() + protected function getExtensions() { - $this->factory->addType(new TestChildType()); + $childType = new TestChildType(); + return array(new PreloadedExtension(array( + $childType->getName() => $childType + ), array())); + } + public function testSubmitValidData() + { $type = new TestedType(); $form = $this->factory->create($type); From 20a00a4f70e7fd0716f284b491f818976d07db8e Mon Sep 17 00:00:00 2001 From: Ulrich Date: Thu, 13 Jun 2013 17:54:32 +0300 Subject: [PATCH 2/2] fix indent & coma --- cookbook/form/unit_testing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/form/unit_testing.rst b/cookbook/form/unit_testing.rst index fdbdd25a43d..9e0d84b2b63 100644 --- a/cookbook/form/unit_testing.rst +++ b/cookbook/form/unit_testing.rst @@ -133,8 +133,8 @@ before creating the parent form using PreloadedExtension class:: { $childType = new TestChildType(); return array(new PreloadedExtension(array( - $childType->getName() => $childType - ), array())); + $childType->getName() => $childType, + ), array())); } public function testSubmitValidData() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy