読者です 読者をやめる 読者になる 読者になる

せかいや

いまいるここを、おもしろく http://sekai-in-the-box.appspot.com/

PHPUnit インストール編

PHPUnitインストール時の作業記録です。
どうせ学習するならPHPUnitを使いたいと思い。

PEARが古い

C:\xampp\php>pear install --alldeps phpunit/PHPUnit
phpunit/PHPUnit requires PEAR Installer (version >= 1.9.4), installed version is 1.7.2
phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.0.0, version <= 2.99.99)
phpunit/File_Iterator requires PEAR Installer (version >= 1.9.4), installed version is 1.7.2
phpunit/Text_Template requires PEAR Installer (version >= 1.9.4), installed version is 1.7.2
phpunit/PHP_CodeCoverage requires PEAR Installer (version >= 1.9.4), installed version is 1.7.2
phpunit/PHP_CodeCoverage requires package "phpunit/File_Iterator" (version >= 1.3.0)

アップデート

C:\xampp\php>pear upgrade PEAR
WARNING: channel "pear.php.net" has updated its protocols, use "channel-update
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPl
pear/Console_Getopt requires PEAR Installer (version >= 1.8.0), installed versi
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.11.tgz ...
Starting to download Archive_Tar-1.3.11.tgz (18,537 bytes)
...done: 18,537 bytes
downloading Structures_Graph-1.0.4.tgz ...
Starting to download Structures_Graph-1.0.4.tgz (30,318 bytes)
...done: 30,318 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.11
upgrade ok: channel://pear.php.net/Structures_Graph-1.0.4
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"

install OKといわれるが実はインストールできてない

C:\xampp\php>pear install --alldeps phpunit/PHPUnit
Unknown remote channel: pear.symfony.com
phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.0.0, version <= 2.99.99)
phpunit/PHP_Invoker requires PHP extension "pcntl"
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.12.tgz ...
Starting to download PHP_CodeCoverage-1.2.12.tgz (158,796 bytes)
...done: 158,796 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.12
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.2.3

インストールを確認するとエラー

C:\xampp\php>phpunit

Fatal error: Call to undefined method PHP_CodeCoverage_Filter::getInstance() in C:\xampp\php\phpunit on line 39

Call Stack:
0.0006 329984 1. {main}() C:\xampp\php\phpunit:0

チャネルを解決できていないため

Unknown remote channel: pear.symfony.com

チャネルを追加

C:\xampp\php>pear channel-discover pear.symfony.com
Adding Channel "pear.symfony.com" succeeded
Discovery of channel "pear.symfony.com" succeeded

そもそもインストールできてなかったみたい

C:\xampp\php>pear uninstall phpunit/PHPUnit
phpunit/PHPUnit not installed

再度インストール

C:\xampp\php>pear install --alldeps phpunit/PHPUnit
phpunit/PHP_Invoker requires PHP extension "pcntl"
downloading PHPUnit-3.7.22.tgz ...
Starting to download PHPUnit-3.7.22.tgz (116,042 bytes)
.........................done: 116,042 bytes
downloading Yaml-2.3.2.tgz ...
Starting to download Yaml-2.3.2.tgz (40,003 bytes)
...done: 40,003 bytes
install ok: channel://pear.symfony.com/Yaml-2.3.2
install ok: channel://pear.phpunit.de/PHPUnit-3.7.22

インストール成功

C:\xampp\php>phpunit
PHPUnit 3.7.22 by Sebastian Bergmann.

Usage: phpunit [switches] UnitTest [UnitTest.php]
phpunit [switches]

--log-junit Log test execution in JUnit XML format