Passing parameters to PHPUnit

后端 未结 9 633
我寻月下人不归
我寻月下人不归 2020-12-24 11:03

I\'m starting to write PHPUnit tests and I\'d like the tests to be run from developers machines as well as from our servers. Developers machines are set up differently than

9条回答
  •  滥情空心
    2020-12-24 11:35

    An elegant way to pass variables to both bootstrap files as well as to test files is by using environment variables:

    export MY_ENV_VAR="some value"
    
    phpunit all
    

    Then, in your PHP files, you can access it like this:

    getenv('MY_ENV_VAR')
    

    Source: http://blog.lysender.com/2010/10/phpunit-passing-environment-variable-to-your-application/

提交回复
热议问题