是否可以将PHPUnit测试打包为
PHAR
存档,并使用phpunit运行它们?
我创造了一个。phar使用以下脚本:
<?php
$cPhar = new Phar('mytests-archive.phar', 0);
$cPhar->addFile('mytest.php');
$sStub = <<<ENDSTUB
#! /usr/bin/php
<?php
Phar::mapPhar('mytest-archive.phar');
require 'phar://mytests-archive.phar/mytest.php';
__HALT_COMPILER();
ENDSTUB;
$cPhar->setStub($sStub);
$cPhar->compressFiles(Phar::GZ);
$cPhar->stopBuffering();
?>
但当我尝试运行生成的归档文件时,如下所示:
phpunit mytests-archive.phar
我收到了错误信息:
#! /usr/bin/php
PHPUnit 3.3.17 by Sebastian Bergmann.
Class MyTestClass could not be found in /path/to/mytests-archive.phar
PHPUnit是否不支持PHAR文件,或者我的构建脚本中是否遗漏了一个步骤?(这是我第一次尝试使用PHAR)