Files
Gnuboard7/plugins/_bundled/sirsoft-message_bizppurio/tests/Unit/Models/BizppurioDispatchTest.php
T
HeuJung 6a8a537f10 feat(message_bizppurio): 임시 삭제된 비즈뿌리오 플러그인 복구 및 현행 규정 정합화
32afe9530 에서 게시판 반응 기능과 함께 임시 제거됐던 비즈뿌리오 메시징
플러그인 본체(137 파일)와 일본어 번들 언어팩(9 파일)을 삭제 직전 상태
(32afe9530~1)로 복구한다. 템플릿 신청·승인 개편의 기반 작업.

복구 범위
- plugins/_bundled/sirsoft-message_bizppurio 전체 + 번들 ja 언어팩
- 공유 파일의 비즈뿌리오 참조 복원: build-language-pack-ja.cjs 팩 정의,
 api-doc-unfilled-baseline.json(32건), docs/backend/api/README.md 표 행,
 audit coverage 노트·vite-sourcemap-env-gate 룰 주석, via 테스트 주석,
 ·AGENTS.md 확장 API 표(자동 재생성), 라우팅 패리티 스냅샷(+1)

삭제 이후 강화된 규정 2건 정합화
- TokenCheckController: 예외 원문을 메시지 키 자리에 전달하던 422 응답을
 키(token_check.failed) + errors.bizppurio_message 페이로드로 분리
 (GenericCatchStatusCodeContractTest 계약). 관리자 토스트는 errors 페이로드로
 상세 사유를 계속 표시하도록 레이아웃 동기 수정, lang ko/en/ja 키 추가
- AlimtalkTemplateController::index: base Request 주입 금지 룰에 따라
 AlimtalkTemplateListRequest FormRequest 신설 (형태 검증만 — kapi 위임 유지)

미복원(의도)
- 게시판·이커머스 CHANGELOG 의 알림톡 연결 문구 2줄은 연결 방식이 로
 재설계되므로 되살리지 않고, 완료 시점에 새 동작 기준으로 차기 버전에 기재

검증: TokenCheck 7 + AlimtalkController 10 + GenericCatch 계약 3 (PHPUnit),
플러그인 레이아웃 Vitest 137건, BindingShape 라우팅 패리티 8건 green.
audit 는 복구 전부터 baseline 처리된 API 문서 미채움 32건만 잔존.
2026-08-22 22:39:36 +09:00

91 lines
2.6 KiB
PHP

<?php
namespace Plugins\Sirsoft\MessageBizppurio\Tests\Unit\Models;
use App\Models\User;
use Plugins\Sirsoft\MessageBizppurio\Enums\DispatchChannel;
use Plugins\Sirsoft\MessageBizppurio\Enums\DispatchStatus;
use Plugins\Sirsoft\MessageBizppurio\Models\BizppurioDispatch;
use Plugins\Sirsoft\MessageBizppurio\Tests\PluginTestCase;
/**
* BizppurioDispatch 모델 — 캐스트·마스킹 접근자·회원 관계 검증.
*/
class BizppurioDispatchTest extends PluginTestCase
{
/**
* enum 캐스트가 적용된다.
*/
public function test_enum_casts(): void
{
$dispatch = BizppurioDispatch::create([
'refkey' => 'r1',
'channel' => 'lms',
'to_number' => '01011112222',
'content' => 'x',
'status' => 'pending',
'source' => 'auto',
]);
$this->assertSame(DispatchChannel::Lms, $dispatch->channel);
$this->assertSame(DispatchStatus::Pending, $dispatch->status);
}
/**
* 마스킹 접근자는 가운데 4자리를 가린다.
*/
public function test_masked_number(): void
{
$dispatch = new BizppurioDispatch(['to_number' => '01012345678']);
$this->assertSame('010-****-5678', $dispatch->masked_number);
}
/**
* 하이픈 포함 번호도 정규화 후 마스킹한다.
*/
public function test_masked_number_with_hyphens(): void
{
$dispatch = new BizppurioDispatch(['to_number' => '010-1234-5678']);
$this->assertSame('010-****-5678', $dispatch->masked_number);
}
/**
* to_user_id 로 회원 관계를 로드한다.
*/
public function test_user_relation(): void
{
$user = User::factory()->create();
$dispatch = BizppurioDispatch::create([
'refkey' => 'r2',
'channel' => 'sms',
'to_number' => '01011112222',
'to_user_id' => $user->id,
'content' => 'x',
'status' => 'sent',
'source' => 'auto',
]);
$this->assertNotNull($dispatch->user);
$this->assertSame($user->id, $dispatch->user->id);
}
/**
* byRefkey 스코프로 조회한다.
*/
public function test_by_refkey_scope(): void
{
BizppurioDispatch::create([
'refkey' => 'unique_ref',
'channel' => 'sms',
'to_number' => '01000000000',
'content' => 'x',
'status' => 'sent',
'source' => 'auto',
]);
$found = BizppurioDispatch::query()->byRefkey('unique_ref')->first();
$this->assertNotNull($found);
$this->assertSame('unique_ref', $found->refkey);
}
}