Packaging PHPUnit tests as a PHAR archive?
Posted
by therefromhere
on Stack Overflow
See other posts from Stack Overflow
or by therefromhere
Published on 2010-04-23T15:31:58Z
Indexed on
2010/04/23
15:33 UTC
Read the original article
Hit count: 342
Is it possible to package PHPUnit tests as a PHAR archive, and run them using phpunit?
I've created a .phar with the follow script:
$cPhar = new Phar('mytests-archive.phar', 0);
$cPhar->addFile('mytest.php');
$stub = <<<ENDSTUB
#! /usr/bin/php
<?php
Phar::mapPhar('mytest-archive.phar');
require 'phar://mytests-archive.phar/mytest.php';
__HALT_COMPILER();
ENDSTUB;
$cPhar->setStub($stub);
$cPhar->compressFiles(Phar::GZ);
$cPhar->stopBuffering();
But when I then try running the resulting archive as follows:
phpunit mytests-archive.phar
I get the error message:
#! /usr/bin/php
PHPUnit 3.3.17 by Sebastian Bergmann.
Class MyTestClass could not be found in /path/to/mytests-archive.phar
Does PHPUnit not support PHAR files, or am I missing a step in my build script? (This is my first attempt at using PHAR)
© Stack Overflow or respective owner