Testing Symfony2 Forms causes Could not load type “entity”

前端 未结 2 1958
日久生厌
日久生厌 2021-02-03 12:21

I am testing a Form Type I defined for an application. During testing the form type, using symfony\'s TypeTestCase class a message \"Could not load type \"entity\"\" appears. Wh

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 12:52

    The Ahmed Siouani's answer is well writted and allowed me to understand how to add an Extension in the TypeTestCase.

    But if you want to make an Intergration test, who is much simpler than a Unit test in this case, you can do as follow:

    protected function getExtensions()
    {
        $childType = new TestChildType();
        return array(new PreloadedExtension(array(
            $childType->getName() => $childType,
        ), array()));
    }
    

    As described in this documentation: http://symfony.com/doc/current/cookbook/form/unit_testing.html#adding-a-type-your-form-depends-on

提交回复
热议问题