Files
Gnuboard7/plugins/_bundled/sirsoft-message_bizppurio/tests/PluginTestCase.php
T
chym1217 b48ac91fec feat(message_bizppurio): 비즈뿌리오 메시징 플러그인 골격 + 환경설정
Phase 1 — 플러그인 설치·활성화 시 권한·메뉴·환경설정 화면이 뜨는 기반 구축.
이후 발송엔진·채널·이력·템플릿 Phase 의 전제가 된다.

- 관리자 환경설정 화면(3섹션: API 연동/발송 설정/연동 안내) — 비즈뿌리오
 아이디·비밀번호·API 키·발신번호·알림톡 발신프로필 키·연동 환경(검수/운영).
 크리덴셜은 마스킹 + 프론트 미노출.
- 조회/관리 권한 2개 + 「메시지 발송 관리」 관리자 메뉴(알림톡 템플릿·발송 이력 하위).
- 잔액 부족 시 관리자 알림 정의(webhook 결과코드 감지는 Phase 4).
- 발송 관련 Enum 4종(채널/상태/출처/결과분류) — Phase 2~4 소비용 골격.

알림톡 채널 기본 body 시드는 채널 등록(Phase 3)·탭 연동(Phase 6)과 강결합이라
Phase 6 으로 이관(plugin.php 주석 명시).

테스트: PHPUnit 12건(설치·권한·메뉴·알림 정의·Enum) + Vitest 22건(환경설정 레이아웃).
설치→활성화 실검증으로 권한 4·메뉴 3·알림 1·설정 초기값 로드 확인.
2026-07-28 12:36:18 +09:00

108 lines
3.0 KiB
PHP

<?php
namespace Plugins\Sirsoft\MessageBizppurio\Tests;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
* 비즈뿌리오 메시징 플러그인 테스트 베이스 클래스
*
* 모든 플러그인 테스트는 이 클래스를 상속받아야 합니다.
* 코어 + 번들 확장 마이그레이션을 자동으로 처리합니다.
*/
abstract class PluginTestCase extends TestCase
{
use RefreshDatabase;
/**
* HookManager static state 스냅샷 — tearDown 에서 복원하여 테스트 간 훅 격리 보장.
*
* @var array{hooks: array, filters: array, dispatching: array}|null
*/
private ?array $hookSnapshot = null;
/**
* 테스트 환경 설정
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->snapshotHookManager();
}
/**
* tearDown 에 HookManager 상태 복원.
*
* @return void
*/
protected function tearDown(): void
{
$this->restoreHookManager();
parent::tearDown();
}
/**
* HookManager static $hooks / $filters / $dispatching 를 스냅샷.
*
* @return void
*/
private function snapshotHookManager(): void
{
$ref = new \ReflectionClass(\App\Extension\HookManager::class);
$this->hookSnapshot = [
'hooks' => $ref->getProperty('hooks')->getValue(),
'filters' => $ref->getProperty('filters')->getValue(),
'dispatching' => $ref->getProperty('dispatching')->getValue(),
];
}
/**
* 스냅샷 시점으로 HookManager 복원.
*
* @return void
*/
private function restoreHookManager(): void
{
if ($this->hookSnapshot === null) {
return;
}
$ref = new \ReflectionClass(\App\Extension\HookManager::class);
$ref->getProperty('hooks')->setValue(null, $this->hookSnapshot['hooks']);
$ref->getProperty('filters')->setValue(null, $this->hookSnapshot['filters']);
$ref->getProperty('dispatching')->setValue(null, $this->hookSnapshot['dispatching']);
$this->hookSnapshot = null;
}
/**
* 마이그레이션 경로를 반환합니다.
*
* RefreshDatabase 의 migrate:fresh 명령에 코어 + 번들 확장 마이그레이션 경로를 전달합니다.
*
* @return array<string, mixed>
*/
protected function migrateFreshUsing(): array
{
$paths = ['database/migrations'];
foreach (glob(base_path('modules/_bundled/*/database/migrations'), GLOB_ONLYDIR) as $p) {
$paths[] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $p);
}
foreach (glob(base_path('plugins/_bundled/*/database/migrations'), GLOB_ONLYDIR) as $p) {
$paths[] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $p);
}
return [
'--drop-views' => $this->shouldDropViews(),
'--drop-types' => $this->shouldDropTypes(),
'--seed' => false,
'--path' => $paths,
];
}
}