Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you install PHPUnit without using PEAR on Mac OS X 10.5?

Tags:

php

phpunit

pear

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

like image 891
Andrew Avatar asked Mar 10 '09 05:03

Andrew


1 Answers

Install via GIT

You can follow the instructions from the Git README: https://github.com/sebastianbergmann/phpunit/

"git" the files and drop them in your home directory

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

setup a personal binary path

cd ~ && mkdir bin
vi ~/.profile
>> export PATH=$HOME/bin:$PATH
>> :wq
source ~/.profile

create the executable

touch ~/bin/phpunit
chmod 755 ~/bin/phpunit

write the executable

#!/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();

test the executable

which phpunit
phpunit --version
like image 192
tobius Avatar answered Nov 11 '22 18:11

tobius