Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThemeFoldersController::batch のユニットテスト #2767

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ThemeFoldersController extends BcAdminApiController
* @param ThemeFoldersService $service
* @checked
* @noTodo
* @unitTest
*/
public function batch(ThemeFoldersServiceInterface $service)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@ public function tearDown(): void
parent::tearDown();
}

/**
* test batch
*/
public function test_batch()
{
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/';
(new Folder())->create($fullpath . 'delete_folder', 0777);
//APIをコール
$this->post('/baser/api/admin/bc-theme-file/theme_folders/batch.json?token=' . $this->accessToken,
[
'batch' => 'delete',
'batch_targets' => [$fullpath]
]);
//レスポンスコードを確認
$this->assertResponseSuccess();
//戻る値を確認
$result = json_decode((string)$this->_response->getBody());
$this->assertEquals('一括処理が完了しました。', $result->message);
//実際にフォルダが削除されいてるか確認すること
$this->assertFalse(file_exists($fullpath . 'delete_folder'));

//$allowMethodは削除ではない場合、
$this->post('/baser/api/admin/bc-theme-file/theme_folders/batch.json?token=' . $this->accessToken,
[
'batch' => 'create',
'batch_targets' => [$fullpath]
]);
$this->assertResponseCode(500);
}

/**
* [API] テーマフォルダ 一覧取得
*/
Expand Down