I had a problem with running test cases on multiple CI environments, where one of the two runs on PHP 5.2 and the other on PHP 5.3. This basically meant that all our pretty PHP 5.3 code caused the builds to fail on the 5.2 only machine. To solve this problem I needed a way to skip tests when the PHP version was less then 5.3.0. Besides the reason I needed this for a -less then ideal- setup. This can also be a generic way to skip certain tests, based on a PHP version.
class someTest
extends PHPUnit_Framework_TestCase
{ public function setUp
() { // Testing if we are dealing with version 5.3.0 or higher if (!
version_compare(PHP_VERSION,
'5.3.0',
'>=')) { $this->markTestSkipped
('Invalid PHP version, unable to run tests.');
} } public function test_testFoo
() { // .. some awesum test case .. \\ }} You can also use the cool @depends annotation of PHPUnit and put the version logic in a test. This has my preference, but it's not always possible. In case you have some code that simply can't be parsed by the older PHP engines.
If you know a better way to do this, please share!