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건만 잔존.
160 lines
6.4 KiB
PHP
160 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace Plugins\Sirsoft\MessageBizppurio\Tests\Feature\Notification;
|
|
|
|
use App\Extension\HookManager;
|
|
use App\Services\NotificationLogService;
|
|
use Plugins\Sirsoft\MessageBizppurio\Listeners\LinkNotificationLogListener;
|
|
use Plugins\Sirsoft\MessageBizppurio\Models\BizppurioDispatch;
|
|
use Plugins\Sirsoft\MessageBizppurio\Services\DispatchLinkContext;
|
|
use Plugins\Sirsoft\MessageBizppurio\Tests\PluginTestCase;
|
|
|
|
/**
|
|
* 코어 알림 로그 ↔ 비즈뿌리오 dispatch 연결 통합 테스트 (A-2 연결고리).
|
|
*
|
|
* Hook 도메인 규정(실제 훅 체인 관찰, mock 금지)에 따라, 코어 NotificationLogService 를 실제로
|
|
* 호출해 core.notification_log.after_log_sent / after_log_failed 훅이 발화하고, 우리
|
|
* LinkNotificationLogListener 가 발송 사이클 refkey 로 dispatch 에 코어 로그 id 를 연결하는지
|
|
* 관찰한다(관찰 가능한 상태 변화 = dispatch.notification_log_id).
|
|
*
|
|
* 매칭은 복합키가 아니라 DispatchLinkContext 의 발송 사이클 refkey 직접 표식(A안)이다.
|
|
*/
|
|
class NotificationLogLinkTest extends PluginTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
// 테스트 환경에는 플러그인이 활성 등록되지 않으므로, A-2 연결 리스너를 HookManager 에
|
|
// 명시 등록해 실제 훅 체인(after_log_sent/after_log_failed)이 이 리스너로 흐르게 한다.
|
|
// getSubscribedHooks() 를 그대로 반영해 실제 발화 경로를 검증한다(리스너 직접 호출 아님).
|
|
foreach (LinkNotificationLogListener::getSubscribedHooks() as $hook => $config) {
|
|
HookManager::addAction(
|
|
$hook,
|
|
fn (...$args) => app(LinkNotificationLogListener::class)->{$config['method']}(...$args),
|
|
$config['priority'] ?? 10,
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 발송 사이클을 흉내내 pending dispatch 를 만들고 refkey 를 컨텍스트에 남깁니다.
|
|
*
|
|
* 채널 드라이버 send() 의 dispatch 생성 + linkContext->remember() 와 동일한 상태를 만든다.
|
|
*
|
|
* @param string $channel 발송 채널
|
|
* @return string 부여한 refkey
|
|
*/
|
|
private function beginDispatchCycle(string $channel = 'sms'): string
|
|
{
|
|
$refkey = 'rk_'.uniqid();
|
|
|
|
BizppurioDispatch::create([
|
|
'refkey' => $refkey,
|
|
'channel' => $channel,
|
|
'to_number' => '01011112222',
|
|
'content' => '본문',
|
|
'notification_type' => 'welcome',
|
|
'status' => 'pending',
|
|
'source' => 'auto',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
// 발송 사이클과 동일한 싱글턴 인스턴스에 refkey 를 남긴다.
|
|
app(DispatchLinkContext::class)->remember($refkey);
|
|
|
|
return $refkey;
|
|
}
|
|
|
|
public function test_발송_성공_로그가_dispatch에_연결된다(): void
|
|
{
|
|
$refkey = $this->beginDispatchCycle();
|
|
|
|
// 코어 로그 서비스로 실제 로그 생성 → after_log_sent 훅 발화 → 우리 리스너가 연결
|
|
$log = app(NotificationLogService::class)->logSent([
|
|
'channel' => 'sms',
|
|
'notification_type' => 'welcome',
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'recipient_identifier' => '01011112222',
|
|
'recipient_name' => '홍길동',
|
|
'source' => 'notification',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
$dispatch = BizppurioDispatch::query()->where('refkey', $refkey)->first();
|
|
$this->assertNotNull($dispatch);
|
|
$this->assertSame((int) $log->id, (int) $dispatch->notification_log_id);
|
|
}
|
|
|
|
public function test_발송_실패_로그도_dispatch에_연결된다(): void
|
|
{
|
|
$refkey = $this->beginDispatchCycle('alimtalk');
|
|
|
|
$log = app(NotificationLogService::class)->logFailed([
|
|
'channel' => 'alimtalk',
|
|
'notification_type' => 'welcome',
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'recipient_identifier' => '01011112222',
|
|
'error_message' => 'boom',
|
|
'source' => 'notification',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
$dispatch = BizppurioDispatch::query()->where('refkey', $refkey)->first();
|
|
$this->assertSame((int) $log->id, (int) $dispatch->notification_log_id);
|
|
}
|
|
|
|
public function test_비_비즈뿌리오_로그는_연결되지_않는다(): void
|
|
{
|
|
// remember() 를 부르지 않은 상태(mail/database 등 비-비즈뿌리오 발송 사이클)
|
|
$log = app(NotificationLogService::class)->logSent([
|
|
'channel' => 'mail',
|
|
'notification_type' => 'welcome',
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'recipient_identifier' => 'a@b.com',
|
|
'source' => 'notification',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
// 어떤 dispatch 도 이 로그에 연결되지 않아야 한다.
|
|
$linked = BizppurioDispatch::query()->where('notification_log_id', $log->id)->exists();
|
|
$this->assertFalse($linked);
|
|
}
|
|
|
|
public function test_한_refkey는_한_로그에만_연결된다_consume_후_비워짐(): void
|
|
{
|
|
$refkey = $this->beginDispatchCycle();
|
|
|
|
// 첫 로그 → 연결됨
|
|
$first = app(NotificationLogService::class)->logSent([
|
|
'channel' => 'sms',
|
|
'notification_type' => 'welcome',
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'recipient_identifier' => '01011112222',
|
|
'source' => 'notification',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
// 같은 사이클에서 refkey 를 다시 남기지 않은 채 둘째 로그 발생(다른 채널) → 연결 안 됨
|
|
$second = app(NotificationLogService::class)->logSent([
|
|
'channel' => 'database',
|
|
'notification_type' => 'welcome',
|
|
'extension_type' => 'core',
|
|
'extension_identifier' => 'core',
|
|
'recipient_identifier' => '01011112222',
|
|
'source' => 'notification',
|
|
'sent_at' => now(),
|
|
]);
|
|
|
|
$dispatch = BizppurioDispatch::query()->where('refkey', $refkey)->first();
|
|
$this->assertSame((int) $first->id, (int) $dispatch->notification_log_id);
|
|
$this->assertFalse(
|
|
BizppurioDispatch::query()->where('notification_log_id', $second->id)->exists()
|
|
);
|
|
}
|
|
}
|