我在安装 PEAR 时遇到了问题,但我真的只想安装 PHPUnit。有没有人有这方面的经验?
最佳答案
通过 GIT 安装
您可以按照 Git 自述文件中的说明进行操作:https://github.com/sebastianbergmann/phpunit/
“git”文件并将它们放到您的主目录中
cd ~ && mkdir phpunit && cd phpunit
git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git
设置个人二进制路径
cd ~ && mkdir bin
vi ~/.profile
>> export PATH=$HOME/bin:$PATH
>> :wq
source ~/.profile
创建可执行文件
touch ~/bin/phpunit
chmod 755 ~/bin/phpunit
编写可执行文件
#!/usr/bin/env php
<?php
// set main method
define('PHPUnit_MAIN_METHOD','PHPUnit_TextUI_Command::main');
// add phpunit to the include path
$paths = scandir($_ENV['HOME'].'/phpunit');
$includes = array();
foreach($paths as $path){
if (!preg_match('/^\./', $path)){
$includes[] = $_ENV['HOME'].'/phpunit/' . $path;
}
}
set_include_path(implode(PATH_SEPARATOR,$includes).PATH_SEPARATOR.get_include_path());
// set the auto loader
require 'PHPUnit/Autoload.php';
// execute
PHPUnit_TextUI_Command::main();
测试可执行文件
which phpunit
phpunit --version
关于php - 如何在 Mac OS X 10.5 上不使用 PEAR 安装 PHPUnit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/628986/