발송 이력 화면의 "테스트 모드" 표기를 "검수 모드"로 통일하고, 검수 모드 발송 건은 상태 라벨 대신 "검수" 라벨로 표시한다. 설정 미완료 상태에서도 검수 모드 안내가 함께 표시되도록 배너 노출 조건을 수정한다. 발송 요청 payload가 어디에도 저장되지 않아 실패 원인을 사후 재구성할 수 없던 문제를 해결한다. bizppurio_dispatches.request_payload 컬럼을 신설해 발송 시점(성공/실패 무관)에 실제 비즈뿌리오 전송 payload를 저장하되, 다른 컬럼과 중복되는 개인식별 정보(수신번호·치환된 본문 텍스트)는 제외하고 저장한다. 카카오 알림톡 버튼 URL과 완전한 URL 변수(action_url 등, 항상 프로토콜 포함)가 결합될 때 프로토콜이 중복(https://https://...)되어 잘못된 링크로 발송되던 문제를 방지한다. 플러그인 제거 후 재설치 시 sms·alimtalk 채널 템플릿이 재생성되지 않던 문제를 해결한다. 리스너 등록 이력 캐시가 재활성화 후에도 남아있어 재등록이 조용히 스킵되던 것으로, 코어 수정 없이 플러그인 내부에서 리플렉션으로 우회한다.
132 lines
4.6 KiB
PHP
132 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace Plugins\Sirsoft\MessageBizppurio\Tests\Unit\Services;
|
|
|
|
use Plugins\Sirsoft\MessageBizppurio\Models\BizppurioDispatch;
|
|
use Plugins\Sirsoft\MessageBizppurio\Repositories\BizppurioDispatchRepository;
|
|
use Plugins\Sirsoft\MessageBizppurio\Services\DispatchResultService;
|
|
use Plugins\Sirsoft\MessageBizppurio\Services\ResultCodeResolver;
|
|
use Plugins\Sirsoft\MessageBizppurio\Tests\PluginTestCase;
|
|
|
|
/**
|
|
* DispatchResultService — 코어 로그 id 배열 → 결과 표시 맵 변환 검증 (A-2 표시 주입).
|
|
*
|
|
* ResultCodeResolver 재사용으로 상태·`사유 (코드)`·잔액부족·대체발송을 파생하고, 매칭되지 않는
|
|
* 로그 id 는 맵에서 빠지는지(빈 셀) 확인한다. 전화번호 등 민감정보는 결과에 포함하지 않는다.
|
|
*/
|
|
class DispatchResultServiceTest extends PluginTestCase
|
|
{
|
|
private DispatchResultService $service;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->service = new DispatchResultService(
|
|
new BizppurioDispatchRepository,
|
|
new ResultCodeResolver,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 코어 로그 id 에 연결된 dispatch 1건을 만듭니다.
|
|
*
|
|
* @param array<string, mixed> $overrides dispatch 오버라이드
|
|
*/
|
|
private function linkedDispatch(int $logId, array $overrides = []): BizppurioDispatch
|
|
{
|
|
return BizppurioDispatch::create(array_merge([
|
|
'refkey' => 'r'.uniqid(),
|
|
'channel' => 'sms',
|
|
'to_number' => '01011112222',
|
|
'content' => 'x',
|
|
'notification_type' => 'welcome',
|
|
'notification_log_id' => $logId,
|
|
'status' => 'success',
|
|
'result_code' => '4100',
|
|
'source' => 'auto',
|
|
'sent_at' => now(),
|
|
], $overrides));
|
|
}
|
|
|
|
public function test_성공_결과를_로그id_키_맵으로_반환한다(): void
|
|
{
|
|
$this->linkedDispatch(10);
|
|
|
|
$results = $this->service->resultsForLogIds([10]);
|
|
|
|
$this->assertArrayHasKey(10, $results);
|
|
$this->assertSame('success', $results[10]['status']);
|
|
$this->assertSame('4100', $results[10]['result_code']);
|
|
$this->assertFalse($results[10]['is_low_balance']);
|
|
// 민감정보(전화번호)는 결과에 포함하지 않는다.
|
|
$this->assertArrayNotHasKey('to_number', $results[10]);
|
|
}
|
|
|
|
public function test_잔액부족_코드는_is_low_balance_true다(): void
|
|
{
|
|
$this->linkedDispatch(20, ['channel' => 'alimtalk', 'status' => 'failed', 'result_code' => '7436']);
|
|
|
|
$results = $this->service->resultsForLogIds([20]);
|
|
|
|
$this->assertTrue($results[20]['is_low_balance']);
|
|
}
|
|
|
|
public function test_대체발송_상태가_결과에_포함된다(): void
|
|
{
|
|
$this->linkedDispatch(30, ['fallback_status' => '성공']);
|
|
|
|
$results = $this->service->resultsForLogIds([30]);
|
|
|
|
$this->assertSame('성공', $results[30]['fallback_status']);
|
|
}
|
|
|
|
public function test_result_code_없으면_result_label_null이다(): void
|
|
{
|
|
$this->linkedDispatch(40, ['status' => 'sent', 'result_code' => null]);
|
|
|
|
$results = $this->service->resultsForLogIds([40]);
|
|
|
|
$this->assertNull($results[40]['result_label']);
|
|
$this->assertNotNull($results[40]['status_label']); // 상태 라벨은 있음(발송중)
|
|
}
|
|
|
|
public function test_검수_모드_스냅샷이_결과에_포함된다(): void
|
|
{
|
|
$this->linkedDispatch(70, ['is_test_mode' => true]);
|
|
|
|
$results = $this->service->resultsForLogIds([70]);
|
|
|
|
$this->assertTrue($results[70]['is_test_mode']);
|
|
}
|
|
|
|
public function test_검수_모드_스냅샷이_없는_과거_이력은_null이다(): void
|
|
{
|
|
$this->linkedDispatch(71, ['is_test_mode' => null]);
|
|
|
|
$results = $this->service->resultsForLogIds([71]);
|
|
|
|
$this->assertNull($results[71]['is_test_mode']);
|
|
}
|
|
|
|
public function test_매칭되지_않는_로그id는_맵에서_빠진다(): void
|
|
{
|
|
$this->linkedDispatch(50);
|
|
|
|
$results = $this->service->resultsForLogIds([50, 999]);
|
|
|
|
$this->assertArrayHasKey(50, $results);
|
|
$this->assertArrayNotHasKey(999, $results);
|
|
}
|
|
|
|
public function test_recent_results_는_연결된_최근_결과를_로그id_키_맵으로_반환한다(): void
|
|
{
|
|
$this->linkedDispatch(60, ['result_code' => '4100']);
|
|
$this->linkedDispatch(61, ['channel' => 'alimtalk', 'status' => 'failed', 'result_code' => '7436']);
|
|
|
|
$results = $this->service->recentResults();
|
|
|
|
$this->assertSame('success', $results[60]['status']);
|
|
$this->assertTrue($results[61]['is_low_balance']);
|
|
}
|
|
}
|