PHPUnitのインストール手順

記事内に広告が含まれています。

PHPUnitのインストール

環境を汚すことはできないので、ユーザホームディレクトリにPHPUnitをインストールする。

前提パッケージのインストール

composerでPHPUnitがインストールできないによるとphp-xmlがないとcomposerが使えないらしい。なので予めphp-xmlをインストールする。

$ sudo yum install php-xml
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.fairway.ne.jp
 * extras: ftp.jaist.ac.jp
 * updates: ftp.jaist.ac.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ php-xml.x86_64 0:5.4.16-43.el7_4 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================
 Package                             アーキテクチャー                   バージョン                                  リポジトリー                         容量
==============================================================================================================================================================
インストール中:
 php-xml                             x86_64                             5.4.16-43.el7_4                             updates                             125 k

トランザクションの要約
==============================================================================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 125 k
インストール容量: 325 k
Is this ok [y/d/N]: y
Downloading packages:
php-xml-5.4.16-43.el7_4.x86_64.rpm                                                                                                     | 125 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : php-xml-5.4.16-43.el7_4.x86_64                                                                                                1/1
  検証中                  : php-xml-5.4.16-43.el7_4.x86_64                                                                                                1/1

インストール:
  php-xml.x86_64 0:5.4.16-43.el7_4

完了しました!

PHPUnitのインストール

PHPUnitをインストールするために、composer.jsonを作成する。

$ mkdir myproject
$ cd myproject
$ cat <<EOF > composer.json
{
    "require": {
        "phpunit/phpunit": "4.8.36"
    }
}
EOF
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 18 installs, 0 updates, 0 removals
  - Installing symfony/yaml (v2.8.34): Loading from cache
  - Installing sebastian/version (1.0.6): Loading from cache
  - Installing sebastian/global-state (1.1.1): Loading from cache
  - Installing sebastian/recursion-context (1.0.5): Loading from cache
  - Installing sebastian/exporter (1.2.2): Loading from cache
  - Installing sebastian/environment (1.3.8): Loading from cache
  - Installing sebastian/diff (1.4.3): Loading from cache
  - Installing sebastian/comparator (1.2.4): Loading from cache
  - Installing doctrine/instantiator (1.0.5): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/phpunit-mock-objects (2.3.8): Loading from cache
  - Installing phpunit/php-timer (1.0.9): Loading from cache
  - Installing phpunit/php-file-iterator (1.4.5): Loading from cache
  - Installing phpunit/php-token-stream (1.4.12): Loading from cache
  - Installing phpunit/php-code-coverage (2.2.4): Loading from cache
  - Installing phpdocumentor/reflection-docblock (2.0.5): Loading from cache
  - Installing phpspec/prophecy (1.7.3): Loading from cache
  - Installing phpunit/phpunit (4.8.36): Loading from cache
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
phpdocumentor/reflection-docblock suggests installing dflydev/markdown (~1.0)
phpdocumentor/reflection-docblock suggests installing erusev/parsedown (~1.0)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
$ ./vendor/bin/phpunit --version
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

コメント

タイトルとURLをコピーしました