Pass variable to PhpUnit

前端 未结 3 1973
旧巷少年郎
旧巷少年郎 2020-12-17 22:16

I developed a set of test cases using phpunit used for testing both development site and the production site. The only difference is the domain name. How can I pass the doma

3条回答
  •  时光取名叫无心
    2020-12-17 22:58

    I ran into this too. One way you can do this with bash is to export the ENV variables you want to pass in and chain the phpunit call using ; like so:

    #: HOST_NAME="my.host.com"; phpunit MyTestFile.php
    

    That will create a HOST_NAME environment variable and then immediately call your unit test.

    Then within your test script you can access the HOST_NAME variable using something like:

    $host = getenv('HOST_NAME');
    

提交回复
热议问题