PHPUnitをPEARからインストールしたときメモ.

PHPUnitのインストールメモ

オチから言うと,ちゃんとsebastianbergmann/phpunit - GitHubのInstallationを最初に読んでやりましょう.ということで以下まぬけな失敗ログ.

% sudo pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded

phpunitのチャンネルを追加して,installを実行.

% sudo pear install phpunit/PHPUnit
Unknown remote channel: components.ez.no
Did not download optional dependencies: channel://components.ez.no/ConsoleTools, use --alldeps to download automatically
Unknown remote channel: components.ez.no
phpunit/PHPUnit can optionally use PHP extension "dbus"
phpunit/PHP_CodeCoverage can optionally use package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
phpunit/PHPUnit_MockObject can optionally use PHP extension "soap"
phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
phpunit/PHP_CodeCoverage requires package "phpunit/PHP_TokenStream" (version >= 1.0.0)
phpunit/PHPUnit requires package "phpunit/PHP_CodeCoverage" (version >= 1.0.2)
install ok: channel://pear.phpunit.de/File_Iterator-1.2.6
install ok: channel://pear.phpunit.de/Text_Template-1.1.0
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.0
install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.0.2
install ok: channel://pear.symfony-project.com/YAML-1.0.5
install ok: channel://pear.php.net/Cache_Lite-1.7.9
install ok: channel://pear.phpunit.de/DbUnit-1.0.1
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.8
install ok: channel://pear.php.net/XML_RPC2-1.0.8

とりあえず処理が終了.

% phpunit --version
zsh: command not found: phpunit

% pear list -c phpunit
Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
DbUnit             1.0.1   stable
File_Iterator      1.2.6   stable
PHPUnit_MockObject 1.0.8   stable
PHPUnit_Selenium   1.0.2   stable
PHP_Timer          1.0.0   stable
Text_Template      1.1.0   stable

およ?肝心のPHPUnitがない.--alldepsをつけてもう一度.

% sudo pear install --alldeps phpunit/PHPUnit
Package "pear.phpunit.de/PHPUnit" dependency "pear.phpunit.de/File_Iterator" has no releases
Unknown remote channel: components.ez.no
Unknown remote channel: components.ez.no
phpunit/PHPUnit can optionally use PHP extension "dbus"
phpunit/PHP_CodeCoverage can optionally use package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6)
phpunit/PHP_CodeCoverage requires package "phpunit/PHP_TokenStream" (version >= 1.0.0)
phpunit/PHPUnit requires package "phpunit/PHP_CodeCoverage" (version >= 1.0.2)
No valid packages found
install failed

失敗してる.依存パッケージの置かれているチャンネルが無かったようです.

% sudo pear channel-discover components.ez.no
Adding Channel "components.ez.no" succeeded
Discovery of channel "components.ez.no" succeeded

チャンネルを追加してリトライ.

% sudo pear install --alldeps phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "dbus"
phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
install ok: channel://components.ez.no/Base-1.8
install ok: channel://components.ez.no/ConsoleTools-1.6.1
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.0.1
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.4
install ok: channel://pear.phpunit.de/PHPUnit-3.5.13

今度はOKっぽい.

% pear list -c phpunit
Installed packages, channel pear.phpunit.de:
============================================
Package            Version State
DbUnit             1.0.1   stable
File_Iterator      1.2.6   stable
PHPUnit            3.5.13  stable
PHPUnit_MockObject 1.0.8   stable
PHPUnit_Selenium   1.0.2   stable
PHP_CodeCoverage   1.0.4   stable
PHP_Timer          1.0.0   stable
PHP_TokenStream    1.0.1   stable
Text_Template      1.1.0   stable

% phpunit --version
PHPUnit 3.5.13 by Sebastian Bergmann.

よしよし.

ちゃんと本家見ると

sebastianbergmann/phpunit - GitHubのInstallationみたら,ちゃんと依存してるからチャンネル追加しとけよって,書いてありました.あらあら.

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

symfonyはたまたま以前symfony本体をPEARから入れたことがあったので,その名残でチャンネルが入ってた.