News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mark van der Velden's Blog:
PHPUnit conditional test based on a PHP version
April 20, 2010 @ 09:57:33

In a new post Mark van der Velden has posted a quick (handy) example of how you can write your PHPUnit tests to be PHP version aware and only test what's needed.

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.

His technique is based on skipping tests that aren't meant for the latest version - like a test that'd only work if the server's running PHP 5.3 or greater. The key is in the PHP_VERSION constant that makes it simple to check what you're running. He also points out that you can use the @depends to achieve a similar functionality.

0 comments voice your opinion now!
phpunit conditional version snippet


blog comments powered by Disqus

Similar Posts

Till Klampaeckel's Blog: Cooking PHPUnit (and a chef-solo example on top)

International PHP Magazine: Poll Question: What are the Features you want to see in PHPUnit Projects

Greg Beaver\'s Blog: PEAR 1.4.7 Released

Phil Sturgeon: The Neverending Muppet Debate of PHP 6 v PHP 7

Volker Dusch's Blog: Textual code coverage information for PHPUnit


Community Events

Don't see your event here?
Let us know!


laravel5 api framework language interview security extension series symfony threedevsandamaybe opinion podcast laravel release community voicesoftheelephpant library version unittest introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework