PC Web メモ

メモ Setup PHPUnit on OSX 10.8

ユニットテストのための環境作り。

  1. pearをインストール
  2. pear経由でPHPUnitを同時に必要なモジュールと併せてインストール

まずはpearをインストール
phpは入ってるけど、pearは手動でインストールする必要があるみたいね。

MC723JA:~ user$ sudo php /usr/lib/php/install-pear-nozlib.phar 
[PEAR] Archive_Tar    - installed: 1.3.7
warning: pear/pear dependency package "pear/Console_Getopt" downloaded version 1.3.0 is not the recommended version 1.2.3
[PEAR] Console_Getopt - installed: 1.3.0
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.4
Wrote PEAR system config file at: /private/etc/pear.conf
You may want to add: /usr/lib/php/pear to your php.ini include_path

何も変化してないから、次の処理は要らないのかもしれない。

MC723JA:~ user$ pear config-set php_ini /private/etc/php.ini
config-set succeeded
MC723JA:~ user$ pecl config-set php_ini /private/etc/php.ini
config-set succeeded

php.iniにinclude_pathをセットしてからの方が良いのかもしれないが、、、更新できるモジュールをUpdate

MC723JA:~ user$ sudo pear upgrade-all
Will upgrade channel://pear.php.net/archive_tar
Will upgrade channel://pear.php.net/console_getopt
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPlus"
downloading Archive_Tar-1.3.11.tgz ...
Starting to download Archive_Tar-1.3.11.tgz (18,537 bytes)
......done: 18,537 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-all ok: channel://pear.php.net/Archive_Tar-1.3.11
upgrade-all ok: channel://pear.php.net/Console_Getopt-1.3.1

php.iniを開いて、最初の指示通りinclude_pathをセットする。

MC723JA:~ user$ vim /private/etc/php.ini
include_path=".:/usr/lib/php/pear"

pearと他のインストールされているモジュールを更新。モジュールは最新だったけど、chanelの更新があった。

MC723JA:= user$ sudo pear list-upgrades
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
Channel pear.php.net: No upgrades available
MC723JA:~ user$ sudo pear channel-update pear.php.net
Updating channel "pear.php.net"
Update of Channel "pear.php.net" succeeded

次は本題、pear経由でPHPUnitを同時に必要なモジュールと併せてインストール

MC723JA:~ user$ sudo pear channel-discover pear.phpunit.de
Adding Channel "pear.phpunit.de" succeeded
Discovery of channel "pear.phpunit.de" succeeded
 
MC723JA:~ user$ sudo pear install phpunit/PHPUnit
Unknown remote channel: pear.symfony.com
Did not download optional dependencies: phpunit/PHP_Invoker, use --alldeps to download automatically
phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.1.0, version < = 2.1.99) phpunit/PHPUnit can optionally use package "phpunit/PHP_Invoker" (version >= 1.1.0, version < = 1.1.99) phpunit/PHP_CodeCoverage can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading File_Iterator-1.3.3.tgz ...
Starting to download File_Iterator-1.3.3.tgz (5,152 bytes)
.....done: 5,152 bytes
downloading Text_Template-1.1.4.tgz ...
Starting to download Text_Template-1.1.4.tgz (3,701 bytes)
...done: 3,701 bytes
downloading PHP_CodeCoverage-1.2.9.tgz ...
Starting to download PHP_CodeCoverage-1.2.9.tgz (159,582 bytes)
...done: 159,582 bytes
downloading PHP_Timer-1.0.4.tgz ...
Starting to download PHP_Timer-1.0.4.tgz (3,694 bytes)
...done: 3,694 bytes
downloading PHPUnit_MockObject-1.2.3.tgz ...
Starting to download PHPUnit_MockObject-1.2.3.tgz (20,390 bytes)
...done: 20,390 bytes
downloading PHP_TokenStream-1.1.5.tgz ...
Starting to download PHP_TokenStream-1.1.5.tgz (9,859 bytes)
...done: 9,859 bytes
install ok: channel://pear.phpunit.de/File_Iterator-1.3.3
install ok: channel://pear.phpunit.de/Text_Template-1.1.4
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.4
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.5
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.2.9
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.2.3

でき、た?と思ったらPHPUnit自体はインストールされていないみたいだし、なにやら、

phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml"

と言われたので、Yamlを追加でinstall。

MC723JA:~ user$ sudo pear channel-discover pear.symfony-project.com
Adding Channel "pear.symfony-project.com" succeeded
Discovery of channel "pear.symfony-project.com" succeeded
MC723JA:~ user$ sudo pear channel-discover pear.symfony.com
Adding Channel "pear.symfony.com" succeeded
Discovery of channel "pear.symfony.com" succeeded
MC723JA:~ user$ sudo pear install pear.symfony.com/Yaml
downloading Yaml-2.1.8.tgz ...
Starting to download Yaml-2.1.8.tgz (39,746 bytes)
..........done: 39,746 bytes
install ok: channel://pear.symfony.com/Yaml-2.1.8

気を取り直してOPHPUnitをインストール

MC723JA:~ user$ 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, version < = 1.1.99)
downloading PHPUnit-3.7.14.tgz ...
Starting to download PHPUnit-3.7.14.tgz (117,687 bytes)
.........................done: 117,687 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.7.14
 
MC723JA:~ user$ phpunit --version
PHPUnit 3.7.14 by Sebastian Bergmann.

やれやれ。
事後だけど、PHPUnitのインストールの個所は、ここが参考になる。

返信を残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください