MAMP2.0.5にPHPUnitを導入する

NO IMAGE

MAMPで何かやるたびハマってる気がしてきましたがPHPUnitの導入も例外なくはまったわけで

PEARをupgradeする

$ cd /Applications/MAMP/bin/php/php5.3.6/bin
$ sudo ./pear upgrade pear

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

上記のようなエラーが出た場合は
/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf を削除する

参考:pearコマンド起動しなくて困った – サイと旅する

confファイルを削除して再度実行

$ sudo ./pear upgrade pear
downloading PEAR-1.9.4.tgz ...
Starting to download PEAR-1.9.4.tgz (296,332 bytes)
.............................................................done: 296,332 bytes
downloading Archive_Tar-1.3.9.tgz ...
Starting to download Archive_Tar-1.3.9.tgz (18,123 bytes)
...done: 18,123 bytes
downloading Console_Getopt-1.3.1.tgz ...
Starting to download Console_Getopt-1.3.1.tgz (4,471 bytes)
...done: 4,471 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.9
upgrade ok: channel://pear.php.net/Console_Getopt-1.3.1
upgrade ok: channel://pear.php.net/PEAR-1.9.4
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

PHPUnitのインストール

$ ./pear channel-discover pear.phpunit.de
$ ./pear channel-discover components.ez.no
$ ./pear channel-discover pear.symfony-project.com
$ sudo ./pear install phpunit/PHPUnit

Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.6.10.tgz ...
Starting to download PHPUnit-3.6.10.tgz (118,595 bytes)
..........................done: 118,595 bytes
downloading File_Iterator-1.3.1.tgz ...
Starting to download File_Iterator-1.3.1.tgz (5,157 bytes)
...done: 5,157 bytes
downloading Text_Template-1.1.1.tgz ...
Starting to download Text_Template-1.1.1.tgz (3,622 bytes)
...done: 3,622 bytes
downloading PHP_CodeCoverage-1.1.2.tgz ...
Starting to download PHP_CodeCoverage-1.1.2.tgz (132,552 bytes)
...done: 132,552 bytes
downloading PHP_Timer-1.0.2.tgz ...
Starting to download PHP_Timer-1.0.2.tgz (3,686 bytes)
...done: 3,686 bytes
downloading PHPUnit_MockObject-1.1.1.tgz ...
Starting to download PHPUnit_MockObject-1.1.1.tgz (19,897 bytes)
...done: 19,897 bytes
downloading YAML-1.0.6.tgz ...
Starting to download YAML-1.0.6.tgz (10,010 bytes)
...done: 10,010 bytes
downloading PHP_TokenStream-1.1.3.tgz ...
Starting to download PHP_TokenStream-1.1.3.tgz (9,860 bytes)
...done: 9,860 bytes
install ok: channel://pear.phpunit.de/File_Iterator-1.3.1
install ok: channel://pear.phpunit.de/Text_Template-1.1.1
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.2
install ok: channel://pear.symfony-project.com/YAML-1.0.6
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.3
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.1.2
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.1.1
install ok: channel://pear.phpunit.de/PHPUnit-3.6.10

インストール出来たのか確認

$ phpunit --version

PHPUnit 3.6.10 by Sebastian Bergmann.