Search code examples
phpmacososx-snow-leopardphpunit

How to install phpunit with MAMP on snow leopard 10.6.7


I've been trying to install phpunit on Mac OS X 10.6.7 with MAMP 1.9.5 with no luck. It's correctly installed, but when I execute it, it doesn't do anything, no output, nothing.

bash-3.2# php -i | grep include_path
include_path => .:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/bin/php5.3/lib/php/PEAR/PHPUnit => .:/Applications/MAMP/bin/php5.3/lib/php:/Applications/MAMP/bin/php5.3/lib/php/PEAR/PHPUnit
bash-3.2# which php
/Applications/MAMP/bin/php5.3/bin/php
bash-3.2# which phpunit
/Applications/MAMP/bin/php5.3/bin/phpunit
bash-3.2# which pear
/Applications/MAMP/bin/php5.3/bin/pear
bash-3.2# phpunit
bash-3.2# phpunit --version
bash-3.2# phpunit --help

I've tried every proposition from this post How to Install phpunit 3.5 on mac with MAMP , but nothings seems to work for me.

Here is my phpunit content :

#!/Applications/MAMP/bin/php5.3/bin/php
<?php
/* PHPUnit
 * 
 */

require_once 'PHP/CodeCoverage/Filter.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');

if (extension_loaded('xdebug')) {
    xdebug_disable();
}

if (strpos('/Applications/MAMP/bin/php5.3/bin/php', '@php_bin') === 0) {
    set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
}

require_once 'PHPUnit/Autoload.php';

define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');

PHPUnit_TextUI_Command::main();

Does anyone has an idea of what's going on ?

Thanks you very much.


Solution

  • Following edorian suggestion, I've been to the other thread and found the solution : restore the system settings for pear, as I probably messed with user settings. Here is the complete solution if anyone needs it :

    I did have a similar issue, thanks to this thread I managed to fix it. Here is how I did it : Followed edorian suggestion :

    Reinstalling pear

    The only way i found arround that is To reinstall save http://pear.php.net/go-pear.phar to disk via 'Save as...' and run php go-pear.phar

    Then called pear config-show to see this :

    Configuration (channel pear.php.net):
    =====================================
    Auto-discover new Channels     auto_discover    <not set>
    Default Channel                default_channel  pear.php.net
    HTTP Proxy Server Address      http_proxy       <not set>
    PEAR server [DEPRECATED]       master_server    pear.php.net
    Default Channel Mirror         preferred_mirror pear.php.net
    Remote Configuration File      remote_config    <not set>
    PEAR executables directory     bin_dir          /Users/mbritto/pear/bin
    PEAR documentation directory   doc_dir          /Users/mbritto/pear/docs
    PHP extension directory        ext_dir          /Applications/MAMP/bin/php5.3/lib/php/extensions
    PEAR directory                 php_dir          /Users/mbritto/pear/share/pear
    PEAR Installer cache directory cache_dir        /tmp/pear/cache
    PEAR configuration file        cfg_dir          /Users/mbritto/pear/cfg
    directory
    PEAR data directory            data_dir         /Users/mbritto/pear/data
    PEAR Installer download        download_dir     /tmp/pear/install
    directory
    PHP CLI/CGI binary             php_bin          /Applications/MAMP/bin/php5.3/bin/php
    php.ini location               php_ini          /Applications/MAMP/conf/php5.3/php.ini
    --program-prefix passed to     php_prefix       <not set>
    PHP's ./configure
    --program-suffix passed to     php_suffix       <not set>
    PHP's ./configure
    PEAR Installer temp directory  temp_dir         /tmp/pear/install
    PEAR test directory            test_dir         /Users/mbritto/pear/tests
    PEAR www files directory       www_dir          /Users/mbritto/pear/www
    Cache TimeToLive               cache_ttl        3600
    Preferred Package State        preferred_state  stable
    Unix file mask                 umask            22
    Debug Log Level                verbose          1
    PEAR password (for             password         <not set>
    maintainers)
    Signature Handling Program     sig_bin          /usr/local/bin/gpg
    Signature Key Directory        sig_keydir       /Applications/MAMP/conf/php5.3/pearkeys
    Signature Key Id               sig_keyid        <not set>
    Package Signature Type         sig_type         gpg
    PEAR username (for             username         <not set>
    maintainers)
    User Configuration File        Filename         /Users/mbritto/.pearrc
    System Configuration File      Filename         /Applications/MAMP/conf/php5.3/pear.conf
    

    I could see there was two config files one for the system and one for the user (see a the bottom of the config-show.

    I backed up my user conf file and replaced it by the system one. Then I needed to set the php_ini setting to /Applications/MAMP/conf/php5.3/php.ini (seemed to be absent from the system config file).

    After that my phpunit worked again! Thanks to everyone :)