Best way to create a test database and load fixtures on Symfony 2 WebTestCase?

后端 未结 7 1485
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 13:11

I have a WebTestCase that executes some basic routes in my application.

I want to, on the setUp method of PHPUnit, create a test database identical to m

7条回答
  •  不思量自难忘°
    2020-12-04 13:37

    If you want to use doctrine:fixtures:load, you can use the --append option to avoid the user confirmation. Since you are recreating the database every time, purging is unnecessary. I used to use doctrine fixtures alone for testing, but have since switched to using fixtures & LiipFunctionalTestBundle to avoid DRY. This bundle makes fixtures easier to manage.

    EDIT: David Jacquel's answer is the correct one for loading Doctrine Fixtures:

    doctrine:fixtures:load --no-interaction 
    or
    doctrine:fixtures:load -n
    

提交回复
热议问题