はじめに
laradock での開発環境構築はこちら。
PHPStormでPHPUnitを動かす設定
1. CLI Interpreterの設定
-
Preference > Languages & Frameworks > PHP
を選択。 -
CLI InterPreter
の右端の...
をクリック。

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

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

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

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

-
Service
php-fpmを選択

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

2 PHPUnitの設定
-
Preference > Languages & Frameworks > Test Frameworks
を選択。 -
+
をクリックして、PHPUnit by Remote Interpreter
を選択。

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

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

3. パスマッピングの設定
-
Preference > languages & Frameworks > PHP
のPath mappings
のフォルダマークをクリック。 -
Local Path
にプロジェクトルート、Remote PathにDocker内のプロジェクトルートを設定し、OK
をクリック。

4. テスト設定
-
メニュー > RUN > Edit Configurations
を選択。 -
Name
に適当な名前、Defined in the configuration file
を選択。
5. テスト実行
-
メニュー > RUN > RUN...
もしくはcontrol + R
でテスト実行。