Running PHPUnit under multiple PHP Versions in Git Bash on Windows (+PHPStorm)

Just a quick note as I wiggled through that:

To run your unit-tests with different PHP Versions in Git Bash on Windows, there is not much use in changing the PHPBIN windows environment variable to make PHPUnit pick the right PHP binary.

Under Git Bash the phpunit file with the PHP shebang is used. So the quick and dirty fix is to duplicate the file and change the PHP interpreter, as in it’s first line:

#!c:\Programme\PHP\.\php.exe
<?php
/* PHPUnit
 *
 * Copyright (c) 2001-2012, Sebastian Bergmann <sebastian@phpunit.de>.
 * All rights reserved.
 * ...

It’s not really a very fine solution but it did it for the moment for me. I named the other file phpunit5.4 to tag the phpversion with it.

For PHPStorm compatiblity not much is needed to do. The only thing that I needed to do was to kill the PHPRC environment variable, otherwise PHPStorm would have picked the configuration from the default commandline PHP installation (still PHP 5.3 on that box).

For standard windows shell it’s just working by setting the PHPBIN variable:

> set PHPBIN=c:\Programme\PHP-5.4\php.exe
> set PHPRC=

The second set is only necessary in case this has not been unset yet. Similar operations in git bash:

$ unset $PHPRC
$ export -n PHPRC

As written changing the PHPBIN variable makes not much sense under bash. Maybe there is an easy way to even better streamline this, I was looking into that the first time. PHP 5.4 will become my default PHP version on the system anyway the next month, that version is just too good to give it secondary treatment.

This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s