[英]How to run a PHPunit test suite in multiple different php environments?
I should run a PHPUnit 3.7 test suite in different php environments: with different php.ini settings and even in different OS environment.我应该在不同的 php 环境中运行PHPUnit 3.7测试套件:使用不同的 php.ini 设置,甚至在不同的操作系统环境中。 I want to make sure that my test suite and the underlying classes work constantly when我想确保我的测试套件和基础类在以下情况下持续工作
How to properly do set-up the test environment in PHPUnit and in CLI (Linux)?如何在 PHPUnit 和 CLI (Linux) 中正确设置测试环境?
If you all you want to is to change php.ini settings and maybe OS/env vars I'd suggest writing little bash script wrappers (or using your build tool of choice) to do the equivalent.如果您只想更改 php.ini 设置和操作系统/环境变量,我建议您编写一些 bash 脚本包装器(或使用您选择的构建工具)来执行等效操作。
/path/to/php-5.3 -d date.timezone=America/New_york /usr/bin/phpunit
export TZ=Europa/Berlin
/path/to/php-5.4 -d date.timezone=Aemerica/San_Franciso /usr/bin/phpunit
This approach will also work with process_isolation
if you use that feature as PHPUnit will be able to figure out what PHP binary was used but you might have issues with the "-d" parameters.如果您使用该功能,这种方法也适用于process_isolation
,因为 PHPUnit 将能够找出使用的 PHP 二进制文件,但您可能会遇到“-d”参数的问题。 In that case don't pass them to the php binary but to phpunit.在这种情况下,不要将它们传递给 php 二进制文件,而是传递给 phpunit。 ( phpunit -d date.timezone=foo
). ( phpunit -d date.timezone=foo
)。 PHPUnit will then take care of setting it before your tests run. PHPUnit 将在您的测试运行之前负责设置它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.