LoginSignup
6

More than 5 years have passed since last update.

FuelPHP で $ oil test --group=App したら「sh: phpunit: command not found」ってなる時の対処方法

Posted at

FuelPHP で $ oil test --group=App したら「sh: phpunit: command not found」ってなる時の対処方法

composer を使って、phpunit をインストールすると、パスが通ってないよ!と怒られる。

そんな時の対処方法のメモ。

composer を使って phpunit をインストールする

まずは composer.json の編集とインストール

$ vi composer.json

    "require": {
        "php": ">=5.3.3",
        "monolog/monolog": "1.5.*",
        "fuelphp/upload": "2.0.1",
        "phpunit/phpunit": "3.7.*"
    },

$ composer update

これでインストールはおしまい。

$ oil test --group=App してみる

$ oil test --group=App
Tests Running...This may take a few moments.
sh: phpunit: command not found

「sh: phpunit: command not found」は phpunit へのパスが通ってないから。

パスを通すよりも、config で解決する

$ vi fuel/app/config/oil.php
<?php
return array(
    'phpunit' => array(
        'binary_path' => 'fuel/vendor/phpunit/phpunit/composer/bin/phpunit',// 個人的には bin/phpunit にエイリアス作って置いてる
    ),
);

これで、ちゃんと動くはず。

$ oil test --group=App
Tests Running...This may take a few moments.
PHPUnit 3.7.28-12-g236f65c by Sebastian Bergmann.
Time: 815 ms, Memory: 14.50Mb

No tests executed!

とかになったら良し。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6