php - 如何在 Mac OS X 10.5 上不使用 PEAR 安装 PHPUnit?

标签 php phpunit pear

我在安装 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/

相关文章:

当前用户不可写 channel "pear.php.net"的 php_dir

java - Android sdk-manager 与 php 冲突?

php - SELECT GROUP BY 用户发送的 INBOX 消息中的最新条目

php - 基于唯一字段的 Doctrine 保存方法更新/插入

Symfony/PHPUnit 在测试中启用分析器

php - 如何将 PHP error_log() 语句回显到输出缓冲区

php - 在 phpunit 中按完全匹配过滤

php mysql 问题

php - 将两个查询合并在一起

php - 如何根据一组特定的编码约定检查 PHP 代码?