title: Testing forms (form types) in Symfony 3.3 projects
body: <p>In a Symfony 3.3 project I try to test this simple form:</p>
  
  <pre><code>class FooFormType extends AbstractType
  {
      private $fooService;
  
      public function __construct(FooService $fooService)
      {
          $this-&gt;fooService = $fooService;
      }
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add(
                  'bar',
                  EntityType::class,
                  [
                      'class' =&gt; Bar::class,
                      'choice_label' =&gt; 'title',
                      'placeholder' =&gt; 'Please select a bar',
                  ]
              )
              -&gt;add(
                  'baz',
                  ChoiceType::class,
                  [
                      'choices' =&gt; $this-&gt;fooService-&gt;lorem(),
                  ]
              )
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(
              [
                  'data_class' =&gt; Foo::class,
              ]
          );
      }
  }
  </code></pre>
  
  <p>I followed the instruction I found at <a href="http://symfony.com/doc/current/form/unit_testing.html#testings-types-from-the-service-container" rel="nofollow noreferrer">http://symfony.com/doc/current/form/unit_testing.html#testings-types-from-the-service-container</a> to write this (simplified) test:</p>
  
  <pre><code>class FooFormTypeTest extends TypeTestCase
  {
      protected function getExtensions()
      {
          $fooServiceDummy = $this-&gt;createMock(FooService::class);
          $fooFormType = new FooFormType($fooServiceDummy);
  
          $managerRegistryDummy = $this-&gt;createMock(ManagerRegistry::class);
          $entityFormType = new EntityType($managerRegistryDummy);
  
          return [
              new PreloadedExtension([$fooFormType, $entityFormType], []),
          ];
      }
  
      /**
       * @test
       */
      public function submitValidData()
      {
          $form = $this-&gt;factory-&gt;create(FooFormType::class);
      }
  }
  </code></pre>
  
  <p>Unfortunatelly this exception is thrown:</p>
  
  <blockquote>
    <p>Symfony\Component\Form\Exception\RuntimeException: Class "AppBundle\Entity\Bar" seems not to be a managed Doctrine entity. Did you forget to map it?</p>
  </blockquote>
  
  <p>What is the problem here?</p>