somemo programming etc.

プログラマ、雑記、プログラミング関係はLinkから、数式はこっちでまとめていることが多い

【PHPUnit】PHPUnitインストール(Linux)【pear】

先日、SimpleTestをインストールしましたが、 CakePhp2.0もSymfony2.0もPHPUnitに移行するそうなので、 こちらもインストールしようと思います。

インストールには、pearを使います。 pearの使い方は、以下のコマンドを実行します。

sudo pear help

 

・チャンネル設定

チャンネル登録

sudo pear channel-discover pear.phpunit.de

⇒Adding Channel "pear.phpunit.de" succeeded Discovery of channel "pear.phpunit.de" succeeded

 

・インストール

sudo pear install phpunit/PHPUnit

⇒パスワード:

Unknown remote channel: pear.symfony-project.com

Did not download optional dependencies: pear/XML_RPC2, use --alldeps to download automatically Unknown remote channel: pear.symfony-project.com

Unknown remote channel: components.ez.no

Unknown remote channel: components.ez.no

phpunit/PHPUnit requires PEAR Installer (version >= 1.9.3), installed version is 1.9.2

phpunit/PHPUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)

phpunit/PHPUnit can optionally use package "pear/XML_RPC2" phpunit/PHPUnit can optionally use PHP extension "dbus" phpunit/DbUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)

phpunit/PHP_CodeCoverage requires 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)

downloading File_Iterator-1.2.6.tgz ... Starting to download File_Iterator-1.2.6.tgz (3,439 bytes) ....done: 3,439 bytes

downloading Text_Template-1.1.0.tgz ... Starting to download Text_Template-1.1.0.tgz (2,783 bytes) ...done: 2,783 bytes

downloading PHP_Timer-1.0.0.tgz ... Starting to download PHP_Timer-1.0.0.tgz (2,536 bytes) ...done: 2,536 bytes

downloading PHPUnit_MockObject-1.0.9.tgz ... Starting to download PHPUnit_MockObject-1.0.9.tgz (18,414 bytes) ...done: 18,414 bytes

downloading PHPUnit_Selenium-1.0.3.tgz ... Starting to download PHPUnit_Selenium-1.0.3.tgz (16,587 bytes) ...done: 16,587 bytes

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.3

install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.0.9

 

・インストールの確認

sudo phpunit

phpunit: command not found

チャンネルの登録が抜けてました。

sudo pear channel-discover pear.symfony-project.com

Adding Channel "pear.symfony-project.com" succeeded Discovery of channel "pear.symfony-project.com" succeeded

 

再びインストール

sudo pear install phpunit/PHPUnit

⇒パスワード:

Did not download optional dependencies: pear/XML_RPC2, use --alldeps to download automatically

Unknown remote channel: components.ez.no

Unknown remote channel: components.ez.no phpunit/PHPUnit requires PEAR Installer (version >= 1.9.3), installed version is 1.9.2

phpunit/PHPUnit can optionally use package "pear/XML_RPC2"

phpunit/PHPUnit can optionally use PHP extension "dbus" phpunit/PHP_CodeCoverage requires 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)

downloading DbUnit-1.0.3.tgz ... Starting to download DbUnit-1.0.3.tgz (39,292 bytes) ..........done: 39,292 bytes

downloading YAML-1.0.6.tgz ... Starting to download YAML-1.0.6.tgz (10,010 bytes) ...done: 10,010 bytes

install ok: channel://pear.symfony-project.com/YAML-1.0.6

install ok: channel://pear.phpunit.de/DbUnit-1.0.3

 

まだ何か足りないので、pearのバージョン確認

sudo pear version

PEAR Version: 1.9.2

PHP Version: 5.3.6 Zend Engine Version: 2.3.0 Running on: Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686

 

インストールされているパッケージの確認

sudo pear list

パスワード:

Installed packages, channel pear.php.net: =========================================

Package Version State Archive_Tar 1.3.7 stable Console_Getopt 1.3.1 stable PEAR 1.9.2 stable Structures_Graph 1.0.4 stable XML_RPC 1.5.4 stable XML_Util 1.2.1 stable

 

pearのバージョンが1.9.2なので、1.9.3以上にアップグレード

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

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"

1.9.4にアップグレードできました。

sudo pear install phpunit/PHPUnit

Did not download optional dependencies: pear/XML_RPC2, use --alldeps to download automatically

Unknown remote channel: components.ez.no

Unknown remote channel: components.ez.no phpunit/PHPUnit can optionally use package "pear/XML_RPC2" phpunit/PHPUnit can optionally use PHP extension "dbus" phpunit/PHP_CodeCoverage requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6) phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5) phpunit/PHPUnit requires package "phpunit/PHP_CodeCoverage" (version >= 1.0.2) phpunit/PHP_TokenStream requires package "channel://components.ez.no/ConsoleTools" (version >= 1.6) No valid packages found install failed

 

まずは、components.ez.noチャンネルの追加 その後、ConsoleToolsパッケージの追加

sudo pear channel-discover components.ez.no

Adding Channel "components.ez.no" succeeded Discovery of channel "components.ez.no" succeeded

 

sudo pear install components.ez.no/ConsoleTools

downloading ConsoleTools-1.6.1.tgz ... Starting to download ConsoleTools-1.6.1.tgz (869,994 bytes) ..................................done: 869,994 bytes

downloading Base-1.8.tgz ... Starting to download Base-1.8.tgz (236,357 bytes) ...done: 236,357 bytes

install ok: channel://components.ez.no/Base-1.8

install ok: channel://components.ez.no/ConsoleTools-1.6.1

 

sudo pear install phpunit/PHPUnit

Did not download optional dependencies: pear/XML_RPC2, use --alldeps to download automatically phpunit/PHPUnit can optionally use package "pear/XML_RPC2" phpunit/PHPUnit can optionally use PHP extension "dbus" phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)

downloading PHPUnit-3.5.15.tgz ... Starting to download PHPUnit-3.5.15.tgz (118,859 bytes) ..........done: 118,859 bytes

downloading PHP_CodeCoverage-1.0.5.tgz ... Starting to download PHP_CodeCoverage-1.0.5.tgz (115,040 bytes) ...done: 115,040 bytes

downloading PHP_TokenStream-1.0.1.tgz ... Starting to download PHP_TokenStream-1.0.1.tgz (7,250 bytes) ...done: 7,250 bytes

install ok: channel://pear.phpunit.de/PHP_TokenStream-1.0.1

install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.0.5

install ok: channel://pear.phpunit.de/PHPUnit-3.5.15

 

PHPUnitをインストールできました。 sudo phpunitで確認できます。 しかし、まだ足りないものがるようです。

 

sudo pear install XML_RPC2

パスワード:

Failed to download pear/HTTP_Request2 within preferred state "stable", latest release is version 2.0.0RC1, stability "beta", use "channel://pear.php.net/HTTP_Request2-2.0.0RC1" to install pear/XML_RPC2 requires package "pear/HTTP_Request2" (version >= 0.6.0)

downloading Cache_Lite-1.7.12.tgz ... Starting to download Cache_Lite-1.7.12.tgz (30,469 bytes) .........done: 30,469 bytes

install ok: channel://pear.php.net/Cache_Lite-1.7.12

 

下記コマンドを実行するべきらしい・・・

sudo pear install channel://pear.php.net/HTTP_Request2-2.0.0RC1

Failed to download pear/Net_URL2 within preferred state "stable", latest release is version 0.3.1, stability "beta", use "channel://pear.php.net/Net_URL2-0.3.1" to install pear/HTTP_Request2 requires package "pear/Net_URL2" (version >= 0.3.0) No valid packages found install failed

 

sudo pear install channel://pear.php.net/Net_URL2-0.3.1

downloading Net_URL2-0.3.1.tgz ... Starting to download Net_URL2-0.3.1.tgz (8,488 bytes) .....done: 8,488 bytes

install ok: channel://pear.php.net/Net_URL2-0.3.1

 

無事成功したので、もう一度「sudo pear install channel://pear.php.net/HTTP_Request2-2.0.0RC1」

sudo pear install channel://pear.php.net/HTTP_Request2-2.0.0RC1 downloading HTTP_Request2-2.0.0RC1.tgz ... Starting to download HTTP_Request2-2.0.0RC1.tgz (95,353 bytes) .................done: 95,353 bytes

install ok: channel://pear.php.net/HTTP_Request2-2.0.0RC1

 

無事成功しましたので、もう一度「sudo pear install XML_RPC2」

sudo pear install XML_RPC2

downloading XML_RPC2-1.1.1.tgz ... Starting to download XML_RPC2-1.1.1.tgz (68,431 bytes) .................done: 68,431 bytes install ok: channel://pear.php.net/XML_RPC2-1.1.1

 

無事成功しました。 PHPUnitをアンインストールしてから、再度インストールしてみます。

sudo pear uninstall phpunit/PHPUnit

uninstall ok: channel://pear.phpunit.de/PHPUnit-3.5.15

 

sudo pear install phpunit/PHPUnit

phpunit/PHPUnit can optionally use PHP extension "dbus" downloading PHPUnit-3.5.15.tgz ... Starting to download PHPUnit-3.5.15.tgz (118,859 bytes) ..........................done: 118,859 bytes

install ok: channel://pear.phpunit.de/PHPUnit-3.5.15 pear list -c phpunit Installed packages, channel pear.phpunit.de: ============================================

Package Version

State DbUnit 1.0.3 stable

File_Iterator 1.2.6 stable

PHPUnit 3.5.15 stable

PHPUnit_MockObject 1.0.9 stable

PHPUnit_Selenium 1.0.3 stable

PHP_CodeCoverage 1.0.5 stable

PHP_Timer 1.0.0 stable

PHP_TokenStream 1.0.1 stable

Text_Template 1.1.0 stable

 

とりあえずここで終了。

 

まとめ

PEARをアップグレードしておくこと

チャンネルの登録

 ・pear channel-discover pear.phpunit.de

 ・pear channel-discover pear.symfony-project.com

pear channel-discover components.ez.no

 ⇒pear install components.ez.no/ConsoleTools

  ⇒pear install XML_RPC2

   ⇒pear install channel://pear.php.net/HTTP_Request2-2.0.0RC1

    ⇒pear install channel://pear.php.net/Net_URL2-0.3.1 インストール

 ・pear install phpunit/PHPUnit PHP extension

 

"dbus"というのは、以下のURLで参照してください。

http://labs.gree.jp/Top/OpenSource/DBus.html

以上。