v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
+194
-34
@@ -3,12 +3,14 @@
|
||||
namespace Modules\Sirsoft\Board\Tests\Feature\Admin;
|
||||
|
||||
// ModuleTestCase를 수동으로 require (autoload 전에 로드 필요)
|
||||
require_once __DIR__ . '/../../ModuleTestCase.php';
|
||||
require_once __DIR__.'/../../ModuleTestCase.php';
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Modules\Sirsoft\Board\Models\Board;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
use Modules\Sirsoft\Board\Services\BoardPermissionService;
|
||||
use Modules\Sirsoft\Board\Tests\ModuleTestCase;
|
||||
|
||||
/**
|
||||
@@ -143,7 +145,7 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
$response->assertStatus(200);
|
||||
|
||||
// 저장된 값이 파일에 반영되었는지 확인
|
||||
$filePath = $this->settingsStoragePath . '/basic_defaults.json';
|
||||
$filePath = $this->settingsStoragePath.'/basic_defaults.json';
|
||||
$this->assertFileExists($filePath);
|
||||
|
||||
$content = json_decode(File::get($filePath), true);
|
||||
@@ -169,7 +171,7 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
$response->assertStatus(200);
|
||||
|
||||
// 저장된 값이 파일에 반영되었는지 확인
|
||||
$filePath = $this->settingsStoragePath . '/notifications.json';
|
||||
$filePath = $this->settingsStoragePath.'/notifications.json';
|
||||
$this->assertFileExists($filePath);
|
||||
|
||||
$content = json_decode(File::get($filePath), true);
|
||||
@@ -190,52 +192,39 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 정책의 알림 채널 배열이 저장 시 보존되는지 확인
|
||||
* 신고 알림 활성화 토글 제거 후, 저장 시 두 활성화 값이 항상 true 로 강제되는지 확인
|
||||
*
|
||||
* 회귀 방지: StoreBoardSettingsRequest 에 채널 검증 규칙이 누락되면
|
||||
* validatedSettings() 가 채널 키를 stripping 하여 사용자가 선택한 값이
|
||||
* 사라지고 저장 후 응답에 기본값이 반환되던 버그 (2026-04-27 발견).
|
||||
* 활성화 토글(notify_admin_on_report / notify_author_on_report_action)을 화면에서 제거하면서,
|
||||
* 발송 게이트(BoardNotificationDataListener)가 false 로 막히지 않도록 백엔드에서 항상 true 강제 저장한다.
|
||||
* 회귀 방지: 사용자가 false 를 보내거나 키를 누락해도 저장값은 true 여야 한다.
|
||||
*/
|
||||
public function test_admin_can_save_report_policy_notification_channels(): void
|
||||
public function test_report_notification_enable_flags_are_forced_true_on_save(): void
|
||||
{
|
||||
// 사용자가 의도적으로 false 를 보내는 시나리오 (또는 키 누락)
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'_tab' => 'report_policy',
|
||||
'report_policy' => [
|
||||
'notify_admin_on_report' => true,
|
||||
'notify_admin_on_report' => false,
|
||||
'notify_admin_on_report_scope' => 'per_case',
|
||||
'notify_admin_on_report_channels' => ['mail'], // 사용자가 mail 만 선택
|
||||
'notify_author_on_report_action' => true,
|
||||
'notify_author_on_report_action_channels' => ['database'], // 사용자가 database 만 선택
|
||||
'notify_author_on_report_action' => false,
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertTrue($response->json('success'));
|
||||
|
||||
// PUT 응답에서 사용자 선택값이 그대로 반영되는지 확인
|
||||
$this->assertEquals(
|
||||
['mail'],
|
||||
$response->json('data.report_policy.notify_admin_on_report_channels')
|
||||
);
|
||||
$this->assertEquals(
|
||||
['database'],
|
||||
$response->json('data.report_policy.notify_author_on_report_action_channels')
|
||||
);
|
||||
// PUT 응답에서 두 값이 true 로 강제되었는지 확인
|
||||
$this->assertTrue($response->json('data.report_policy.notify_admin_on_report'));
|
||||
$this->assertTrue($response->json('data.report_policy.notify_author_on_report_action'));
|
||||
|
||||
// 후속 GET 요청에서도 영구 저장 확인
|
||||
// 후속 GET 요청에서도 영구적으로 true 저장 확인
|
||||
$followUp = $this->actingAs($this->adminUser)
|
||||
->getJson('/api/modules/sirsoft-board/admin/settings/report_policy');
|
||||
|
||||
$followUp->assertStatus(200);
|
||||
$this->assertEquals(
|
||||
['mail'],
|
||||
$followUp->json('data.settings.notify_admin_on_report_channels')
|
||||
);
|
||||
$this->assertEquals(
|
||||
['database'],
|
||||
$followUp->json('data.settings.notify_author_on_report_action_channels')
|
||||
);
|
||||
$this->assertTrue($followUp->json('data.settings.notify_admin_on_report'));
|
||||
$this->assertTrue($followUp->json('data.settings.notify_author_on_report_action'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +259,7 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
$response->assertStatus(200);
|
||||
|
||||
// invalid_category 파일이 생성되지 않아야 함
|
||||
$this->assertFileDoesNotExist($this->settingsStoragePath . '/invalid_category.json');
|
||||
$this->assertFileDoesNotExist($this->settingsStoragePath.'/invalid_category.json');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +286,7 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
// 테스트용 게시판 생성
|
||||
$board = Board::create([
|
||||
'name' => ['ko' => '테스트', 'en' => 'Test'],
|
||||
'slug' => 'settings-test-' . substr(md5(microtime()), 0, 8),
|
||||
'slug' => 'settings-test-'.substr(md5(microtime()), 0, 8),
|
||||
'type' => 'gallery',
|
||||
'per_page' => 10,
|
||||
]);
|
||||
@@ -327,14 +316,14 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
// 테스트용 게시판 2개 생성
|
||||
$board1 = Board::create([
|
||||
'name' => ['ko' => '테스트1', 'en' => 'Test1'],
|
||||
'slug' => 'settings-test-' . substr(md5(microtime() . '1'), 0, 8),
|
||||
'slug' => 'settings-test-'.substr(md5(microtime().'1'), 0, 8),
|
||||
'type' => 'gallery',
|
||||
'per_page' => 10,
|
||||
]);
|
||||
|
||||
$board2 = Board::create([
|
||||
'name' => ['ko' => '테스트2', 'en' => 'Test2'],
|
||||
'slug' => 'settings-test-' . substr(md5(microtime() . '2'), 0, 8),
|
||||
'slug' => 'settings-test-'.substr(md5(microtime().'2'), 0, 8),
|
||||
'type' => 'gallery',
|
||||
'per_page' => 10,
|
||||
]);
|
||||
@@ -431,6 +420,78 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// StoreBoardSettingsRequest 검증 경계값 테스트 (회귀: issue#413)
|
||||
// ========================================
|
||||
|
||||
/**
|
||||
* basic_defaults.max_reply_depth 는 config max_reply_depth_max(10)까지 허용 (회귀: issue#413)
|
||||
*/
|
||||
public function test_settings_request_max_reply_depth_allows_up_to_config_max(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'basic_defaults' => ['max_reply_depth' => 10],
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* basic_defaults.max_reply_depth 가 config max(10) 초과 시 422 (회귀: issue#413)
|
||||
*/
|
||||
public function test_settings_request_max_reply_depth_rejects_above_config_max(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'basic_defaults' => ['max_reply_depth' => 11],
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['basic_defaults.max_reply_depth']);
|
||||
}
|
||||
|
||||
/**
|
||||
* basic_defaults.per_page 는 config per_page_min(5) 미만 시 422 (회귀: issue#413)
|
||||
*/
|
||||
public function test_settings_request_per_page_rejects_below_config_min(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'basic_defaults' => ['per_page' => 4],
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['basic_defaults.per_page']);
|
||||
}
|
||||
|
||||
/**
|
||||
* basic_defaults.per_page 는 config per_page_min(5) 이상 허용 (회귀: issue#413)
|
||||
*/
|
||||
public function test_settings_request_per_page_allows_config_min(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'basic_defaults' => ['per_page' => 5],
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* basic_defaults.per_page_mobile 는 config per_page_min(5) 미만 시 422 (회귀: issue#413)
|
||||
*/
|
||||
public function test_settings_request_per_page_mobile_rejects_below_config_min(): void
|
||||
{
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->putJson('/api/modules/sirsoft-board/admin/settings', [
|
||||
'basic_defaults' => ['per_page_mobile' => 4],
|
||||
]);
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors(['basic_defaults.per_page_mobile']);
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// clearCache (캐시 초기화) 테스트
|
||||
// ========================================
|
||||
@@ -456,4 +517,103 @@ class BoardSettingsControllerTest extends ModuleTestCase
|
||||
|
||||
$response->assertStatus(401);
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// bulkApply 원자적 롤백 (회귀: issue#413-26)
|
||||
// ========================================
|
||||
|
||||
/**
|
||||
* 권한 적용이 중간 게시판에서 실패하면 전체 변경이 롤백되는지 확인 (회귀: issue#413-26)
|
||||
*
|
||||
* 3개 게시판 중 2번째에서 권한 적용 실패를 강제하면:
|
||||
* - 응답은 HTTP 200 + data.rolled_back=true + board(실패 게시판) 포함
|
||||
* - 이미 적용됐어야 할 1번 게시판도 원복 (원자성)
|
||||
* - 3번 게시판은 미적용
|
||||
* - 컬럼 업데이트(혼합 경로)도 원복
|
||||
*/
|
||||
public function test_bulk_apply_rolls_back_all_when_permission_fails_midway(): void
|
||||
{
|
||||
$boards = [];
|
||||
foreach (['a', 'b', 'c'] as $suffix) {
|
||||
$boards[$suffix] = Board::create([
|
||||
'name' => ['ko' => "롤백테스트{$suffix}", 'en' => "Rollback {$suffix}"],
|
||||
'slug' => 'settings-test-rollback-'.$suffix,
|
||||
'type' => 'gallery',
|
||||
'per_page' => 10,
|
||||
]);
|
||||
}
|
||||
|
||||
// 2번째(b) 게시판에서 권한 적용 시 예외를 던지도록 mock
|
||||
$this->mock(BoardPermissionService::class, function ($mock) use ($boards) {
|
||||
$mock->shouldReceive('updateBoardPermissions')
|
||||
->andReturnUsing(function (Board $board) use ($boards) {
|
||||
if ($board->id === $boards['b']->id) {
|
||||
throw new \RuntimeException('강제 권한 적용 실패');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->postJson('/api/modules/sirsoft-board/admin/settings/bulk-apply', [
|
||||
'fields' => ['per_page', 'manager'],
|
||||
'apply_all' => false,
|
||||
'board_ids' => [$boards['a']->id, $boards['b']->id, $boards['c']->id],
|
||||
// 테스트 DB 에는 모듈 settings 가 시드되지 않으므로 권한 기본값을 직접 주입
|
||||
// (권한 루프가 실행되어 mock 예외가 중간에 발생하도록)
|
||||
'override_values' => [
|
||||
'default_board_permissions' => ['manager' => ['admin']],
|
||||
],
|
||||
]);
|
||||
|
||||
// 롤백도 의도된 정상 동작 → HTTP 200 + rolled_back 플래그
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('data.rolled_back', true)
|
||||
->assertJsonPath('data.board.board_id', $boards['b']->id);
|
||||
|
||||
// 원자성: 컬럼(per_page)이 전부 원복 (1번 게시판도 변경 전 값 유지)
|
||||
foreach ($boards as $board) {
|
||||
$board->refresh();
|
||||
$this->assertEquals(10, $board->per_page, "{$board->slug} per_page 가 롤백되지 않음");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 컬럼 일괄 업데이트가 실패하면 전체 롤백되고 generic 안내가 반환되는지 확인 (회귀: issue#413-26)
|
||||
*
|
||||
* 컬럼 업데이트(bulkUpdate)는 단일 쿼리라 특정 게시판을 짚을 수 없음:
|
||||
* - 응답은 HTTP 200 + data.rolled_back=true + board=null
|
||||
* - 권한도 미적용(원복)
|
||||
*/
|
||||
public function test_bulk_apply_rolls_back_with_generic_when_column_update_fails(): void
|
||||
{
|
||||
$board = Board::create([
|
||||
'name' => ['ko' => '컬럼롤백', 'en' => 'Column Rollback'],
|
||||
'slug' => 'settings-test-column-rollback',
|
||||
'type' => 'gallery',
|
||||
'per_page' => 10,
|
||||
]);
|
||||
|
||||
// 컬럼 일괄 업데이트(bulkUpdate)에서 예외를 던지도록 mock
|
||||
$this->mock(BoardRepositoryInterface::class, function ($mock) {
|
||||
$mock->shouldReceive('bulkUpdate')
|
||||
->andThrow(new \RuntimeException('강제 컬럼 업데이트 실패'));
|
||||
// 그 외 메서드는 통과 (query 등)
|
||||
$mock->shouldReceive('query')->andReturnUsing(fn () => Board::query());
|
||||
});
|
||||
|
||||
$response = $this->actingAs($this->adminUser)
|
||||
->postJson('/api/modules/sirsoft-board/admin/settings/bulk-apply', [
|
||||
'fields' => ['per_page'],
|
||||
'apply_all' => false,
|
||||
'board_ids' => [$board->id],
|
||||
]);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonPath('data.rolled_back', true)
|
||||
->assertJsonPath('data.board', null);
|
||||
|
||||
// 컬럼 값 원복 확인
|
||||
$board->refresh();
|
||||
$this->assertEquals(10, $board->per_page);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user