Repository navigation
PHPUnit via composer not running in PHP 5.2 #12
Description
Activity
Hello;
This is not really a dunit issue. In order to use PHPUnit with PHP 5.2 you need a very old (unsupported, outdated, hard to find) version of PHPUnit. I believe 3.6 is the last version you can use with PHP5.2. By default dunit will simply use the phpunit script located in your project's vendor folder.
That said, I thought it would be an interesting challenge to tackle (and may prove useful for future versions of dunit). Here's what I did to get a "working" version of PHPUnit within the PHP 5.2 docker image.
My
composer.json:... "require": { "php": ">=5.2.0" }, "require-dev": { "xrstf/composer-php52": "1.*", "phpunit/phpunit-php52": "dev-3.6.12-php52", "phpunit/phpunit-mock-objects-php52": "dev-1.1.0-php52", "vectorface/dunit": "~2.0" }, "repositories": [ { "type": "git", "url": "https://github.com/garex/phpunit" }, { "type": "git", "url": "https://github.com/garex/phpunit-mock-objects" } ], "scripts": { "post-install-cmd": [ "xrstf\\Composer52\\Generator::onPostInstallCmd" ], "post-update-cmd": [ "xrstf\\Composer52\\Generator::onPostInstallCmd" ], "post-autoload-dump": [ "xrstf\\Composer52\\Generator::onPostInstallCmd" ] } ...then:
$> composer update ... $> docker run -i -t -v `pwd`:/opt/source vectorface/php5.2 root@c18b8af431e8:/# cd /opt/source root@c18b8af431e8:/opt/source# php -d error_reporting=-1 ./vendor/bin/phpunit-php52 ./PHP52Test.php PHPUnit @package_version@ by Sebastian Bergmann. . Time: 0 seconds, Memory: 3.75Mb OK (1 test, 1 assertion)Note that I had to actually write a new test because none of my own are PHP 5.2 compatible, but that test does run. Please note that PHPUnit 5.2 is provided but not officially support for running modern unit test suites. Primarily the PHP 5.2 image is for running linting (php -l). Anyway, hope this was helpful for you. Best of luck.
Reacted by Samir AguiarHi, @danbruce, thanks so much for getting in touch.
I've been thinking to suggest you include a phpunit52.phar (I was working on it) or something like that inside your docker image, but you made clear that ...
Primarily the PHP 5.2 image is for running linting (php -l)
... so it would be pointless.
Again, thanks and congrats for releasing this awesome project!
The reason I tagged this as an "enhancement" is due to exactly what you mentioned. I am now considering (in a future version) of packaging a version of PHPUnit within each docker image that is compatible with the PHP version. This is especially relevant as PHPUnit plans to drop support for all PHP < 5.6.
Tweets:
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>@s_bergmann hello, sorry for bother! Is available any phpunit3.6.phar around? The intention is provide it in https://t.co/3F4KxFOYtM php52
— Rogerio Prado J (@rogeriopradoj) June 9, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>@rogeriopradoj No because PHAR support was added in PHPUnit 3.7.
— Sebastian Bergmann (@s_bergmann) June 9, 2015
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>@rogeriopradoj You can use the zip files, can't you? https://t.co/PIdfwGLm1L
— Augusto Pascutti (@augustohp) June 9, 2015
Hello, first of all, thanks for this awesome project!
Unfortunately, I'm having a problem with a project:
I trying to find a way to install phpunit in PHP 5.2, found some clues (I hope this can help):
Anyway, thanks again!