Skip to content

Commit f76907b

Browse files
authored
Merge pull request #2196 from opensource-workshop/dev-dusk
[ブラウザテスト] .envからDUSK_NO_MANUAL_ALL/DUSK_NO_API_TEST_ALLを設定できるように対応
2 parents 319d4db + 7ff40cd commit f76907b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ FACE_AI_API_KEY="${COMMON_API_KEY}"
170170

171171
#DUSK_DRIVER_URL=
172172

173+
# Do not create manuals in Dusk.
174+
#DUSK_NO_MANUAL_ALL=true
175+
176+
# Do not run API tests in Dusk.
177+
#DUSK_NO_API_TEST_ALL=true
178+
173179
# dusk use uploads dir.
174180
#UPLOADS_DIRECTORY_BASE=uploads_dusk/
175181

tests/DuskTestCase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ protected function setUp(): void
108108
});
109109
}
110110

111+
// Laravel9以前
111112
// コマンドライン引数 第5(配列インデックス4)に no_manual が指定されていた場合は、マニュアル作成しない。
112113
if ($_SERVER && count($_SERVER['argv']) > 4) {
113114
if ($_SERVER['argv'][4] == 'no_manual') {
@@ -119,6 +120,17 @@ protected function setUp(): void
119120
}
120121
}
121122

123+
// Laravel 10対応(phpunit 10.x) dusk実行時のコマンドライン引数はテストクラスのパスと認識されるため、envで対応
124+
// .envの DUSK_NO_MANUAL_ALL に何か値が指定されていた場合は、マニュアル作成しない。
125+
if (env('DUSK_NO_MANUAL_ALL')) {
126+
$this->no_manual = true;
127+
}
128+
129+
// .envの DUSK_NO_API_TEST_ALL に何か値が指定されていた場合は、APIテストを実行しない。
130+
if (env('DUSK_NO_API_TEST_ALL')) {
131+
$this->no_api_test = true;
132+
}
133+
122134
/* 一旦コメントアウト。データのクリアは、意識して行いたいかもしれないので。
123135

124136
// テスト実行のタイミングで一度だけ実行する
@@ -557,6 +569,11 @@ public function putManualData($img_args = null, $method = null, $sort = 0, $leve
557569
*/
558570
public function putManualTemplateData($frame, $category, $test_path, $plugin, $templates)
559571
{
572+
// マニュアル用データ出力がOFF の場合は、出力せずに戻る。
573+
if ($this->no_manual) {
574+
return;
575+
}
576+
560577
// 画像関係パス
561578
$img_args = "";
562579

0 commit comments

Comments
 (0)