我正在开发一个使用PHP类的命令行工具。 我对覆盖范围内的课程进行了测试。PHPUnit测试覆盖范围的命令行脚本
现在我想测试我在命令行中使用的PHP脚本。
我发现如何触发与以下螺纹的命令行: How do I test a command-line program with PHPUnit?
我想知道我怎么可以覆盖在命令行脚本执行的行。
我试图使测试像:
class CommandTest extends \PHPUnit_Framework_TestCase
{
protected static $command = './src/Command.php ';
protected static $testWorkingDir = 'tests/Command';
public function testCLIInstall()
{
$command = self::$command . ' --help';
$output = `$command`;
}
}
执行成功完成,但没有什么是文件“Command.php”盖。
首先,这可能吗? 那么,如果是这样,我该如何做掩护命令行脚本?
非常感谢。
最好的问候,
Neoblaster。
更新:我在GitHub上打开一个问题:https://github.com/sebastianbergmann/phpunit/issues/2817
嗨Marv255, 我的命令行脚本不是PHP类,但它使用一个。 请在这里找到相应的脚本:[Command.php](https://github.com/neooblaster/SYSLang/blob/master/src/Command.php?ts=3) 它没有完成,但也许是错误的方式来使命令行界面? (新命令($ argv)) - >运行()' – Neoblaster
此外,为php创建命令行脚本的最佳方式是我见过的[symfony console](https:// symfony。COM/DOC /电流/组件/ console.html)。请按照链接阅读更多关于它。 – marv255