unit testing - Symfony2 Custom form type using entity trying to test it -


i trying test form type have creating uses field class entity

here creation of form

$builder             ->add('name', 'text')             ->add('description', 'textarea')             ->add('services', 'entity', array('class' => 'mybundle:service', 'group_by' => 'category.name', 'property' => 'name', 'multiple' => true, 'required' => false)); 

this works nice when build form, trying unit test type

following this example on how test custom form types

i getting error

symfony\component\form\exception\exception: not load type "entity"

the error caused @ beginning of unit test @ command:

    $type = new mytype();     $form = $this->factory->create($type); 

any ideas on how fix error in order test custom form type using entities?

thanks in advance

i guess can't unit test form entity types, because it's defined service. have tried adding manually?

edit: imho should mock entity type, because involves doctrine, depends on existing database connection , on full kernel loaded. you're not unit testing more. functional test. maybe reason, why it's not available in unit test.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -