How to rollback transactions when doing functional testing with Symfony2

前端 未结 3 711
深忆病人
深忆病人 2021-02-09 23:08

I\'m trying to write a functional test for my project in Symfony2. I\'d like to test if a user can access a page, fill up a form and submit it. I\'m trying to find a way to roll

3条回答
  •  梦毁少年i
    2021-02-09 23:52

    You could use a dedication test database for testing

    Another option is using Codeception. This is a unit testing bundle that works with Symfony. If you use this, you can configure it to use a test database and then "clean it up" after each testing cycle.
    An example yaml configuartion to do that would be something like, it is the cleanup: true that does what you want;

    class_name: UnitTester
    modules:
        enabled:
            - Asserts
            - Symfony2:
                app_path: '../../app'
                var_path: '../../app'
                environment: 'test'
            - Doctrine2:
                depends: Symfony2
                cleanup: true
            - \AppBundle\Helper\Unit
    

提交回复
热议问题