Laravel 5 : Use different database for testing and local

后端 未结 6 1474
栀梦
栀梦 2020-12-24 12:21

How does one change database for development and testing on local system without editing the .env file each time?

I have found it quite inconvenient to

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 12:44

    You can use a different .env file for each type of test. You can modify your tests/functional.suite.yml and tests/unit.suite.yml something like this:

    class_name: FunctionalTester
    modules:
        enabled: [Laravel5, FunctionalHelper, Asserts]
        config:
            Laravel5:
                environment_file: .env.testing
    

    And this:

    class_name: UnitTester
    modules:
        enabled: [Asserts, UnitHelper, Laravel5]
        config:
            Laravel5:
                environment_file: .env.unittesting
    

    Or you can simply modify your phpunit.xml and add environment vars like @Tijmen did above.

提交回复
热议问题