如何在Mac OS X 10.5上不使用PEAR的情况下安装PHPUnit? [英] How do you install PHPUnit without using PEAR on Mac OS X 10.5?

查看:77
本文介绍了如何在Mac OS X 10.5上不使用PEAR的情况下安装PHPUnit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装PEAR时遇到问题,但是我真的只想安装PHPUnit.有人有这样做的经验吗?

I am having trouble installing PEAR, but I really only want to install PHPUnit. Does anyone have experience doing this?

推荐答案

通过GIT安装

您可以按照Git自述文件中的说明进行操作: https://github.com/sebastianbergmann/phpunit/

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

这篇关于如何在Mac OS X 10.5上不使用PEAR的情况下安装PHPUnit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆