PHPUnit
laravel
0

laradock + PhpStormでPHPUnitを動かす

はじめに

laradock での開発環境構築はこちら

PHPStormでPHPUnitを動かす設定

1. CLI Interpreterの設定

  • Preference > Languages & Frameworks > PHPを選択。
  • CLI InterPreterの右端の...をクリック。

スクリーンショット 2018-12-17 15.21.00.png

  • 左上の+をクリック。
  • From Docker, ...を選択してOKをクリック。

スクリーンショット 2018-12-17 15.38.32.png

  • Docker Composeのラジオボタンを選択。
  • Server : Newボタンをクリック。

スクリーンショット 2018-12-17 15.47.21.png

  • Nameに適当な名前を入力。
  • Connect to Docker...のラジオボックスからDocker for Macを選択してOKをクリック。

スクリーンショット 2018-12-17 15.21.45.png

  • Configuration File(s):横のフォルダマークをクリック
  • Docker Configuration Filesを追加。下部+をクリックし、laradock内のdocker-compose.ymlを選択。

スクリーンショット 2018-12-17 15.51.04.png

  • Servicephp-fpmを選択

スクリーンショット 2018-12-17 16.02.29.png

  • docker-compose.ymlが読み込まれ、設定に反映されます。

スクリーンショット 2018-12-17 16.04.10.png

2 PHPUnitの設定

  • Preference > Languages & Frameworks > Test Frameworksを選択。
  • +をクリックして、PHPUnit by Remote Interpreterを選択。

スクリーンショット 2018-12-17 16.13.10.png

  • プルダウンから、先ほど設定したphp-fpmを選択し、OKをクリック。

スクリーンショット 2018-12-17 15.26.09.png

  • Use Composer autoloaderを選択。
  • Path to Scriptに、vendor/autoload.phpのパスを設定(リモートパス)。
  • Default configuration filephpunit.xmlのパスを設定(こちらもリモートパス)

スクリーンショット 2018-12-17 15.27.13.png

3. パスマッピングの設定

  • Preference > languages & Frameworks > PHPPath mappingsのフォルダマークをクリック。
  • Local Pathにプロジェクトルート、Remote PathにDocker内のプロジェクトルートを設定し、OKをクリック。

スクリーンショット 2018-12-17 16.26.54.png

4. テスト設定

  • メニュー > RUN > Edit Configurationsを選択。
  • Nameに適当な名前、Defined in the configuration fileを選択。

5. テスト実行

  • メニュー > RUN > RUN... もしくは control + Rでテスト実行。
Why do not you register as a user and use Qiita more conveniently?
You seem to be reading articles frequently this month. You can use this function by logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away