7.0.0 정식 출시 커밋에서 PG 3종이 함께 제거되었으나, 그중 토스페이먼츠만 번들로 되돌린다. 삭제 직전 트리를 기준으로 플러그인 40개 파일과 일본어 언어팩 6개 파일을 복원하고, 삭제에 연동되어 변경되었던 README 목록·언어팩 빌드 스크립트 엔트리·이커머스 편집기 샘플의 PG provider 를 함께 되살렸다. 복원된 코드는 삭제 시점에 멈춰 있어 현행 코드베이스와 어긋나는 지점이 있어 함께 정합화했다. - PluginTestCase 가 활성 디렉토리 경로를 참조해 _bundled 단독 실행 시 라우트가 등록되지 않던 문제를 자기 기준 경로로 교체 - SettingsServiceProvider 의 site_url override 로 app.url 이 오염되어 assertRedirect 가 간헐 실패하던 문제를 APP_URL 명시 리셋으로 차단 - 환경설정 레이아웃의 시맨틱 클래스가 한 칸씩 밀려 순환 배치되어 2열 폼이 무너지고 섹션 제목이 에러 색으로 표시되던 결함을 정정 (회귀 테스트 신설) - 편집기 저장 시 silent drop 되던 미표준 root 키 제거, Icon 을 size prop 으로 전환
99 lines
3.1 KiB
PHP
99 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Plugins\Sirsoft\Tosspayments\Tests\Unit\Services;
|
|
|
|
use App\Services\PluginSettingsService;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Plugins\Sirsoft\Tosspayments\Services\TossPaymentsApiService;
|
|
|
|
/**
|
|
* TossPaymentsApiService 단위 테스트
|
|
*/
|
|
class TossPaymentsApiServiceTest extends TestCase
|
|
{
|
|
/**
|
|
* PluginSettingsService mock을 생성합니다.
|
|
*
|
|
* @param array $settings 반환할 설정값
|
|
* @return PluginSettingsService
|
|
*/
|
|
private function mockSettingsService(array $settings): PluginSettingsService
|
|
{
|
|
$mock = $this->createMock(PluginSettingsService::class);
|
|
$mock->method('get')
|
|
->with('sirsoft-tosspayments')
|
|
->willReturn($settings);
|
|
|
|
return $mock;
|
|
}
|
|
|
|
/**
|
|
* 테스트 모드에서 테스트 시크릿 키를 사용하는지 확인
|
|
*/
|
|
public function test_constructor_uses_test_secret_key_in_test_mode(): void
|
|
{
|
|
$service = new TossPaymentsApiService($this->mockSettingsService([
|
|
'is_test_mode' => true,
|
|
'test_secret_key' => 'test_sk_abc123',
|
|
'live_secret_key' => 'live_sk_xyz789',
|
|
]));
|
|
|
|
$reflection = new \ReflectionClass($service);
|
|
$prop = $reflection->getProperty('secretKey');
|
|
$prop->setAccessible(true);
|
|
|
|
$this->assertEquals('test_sk_abc123', $prop->getValue($service));
|
|
}
|
|
|
|
/**
|
|
* 라이브 모드에서 라이브 시크릿 키를 사용하는지 확인
|
|
*/
|
|
public function test_constructor_uses_live_secret_key_in_live_mode(): void
|
|
{
|
|
$service = new TossPaymentsApiService($this->mockSettingsService([
|
|
'is_test_mode' => false,
|
|
'test_secret_key' => 'test_sk_abc123',
|
|
'live_secret_key' => 'live_sk_xyz789',
|
|
]));
|
|
|
|
$reflection = new \ReflectionClass($service);
|
|
$prop = $reflection->getProperty('secretKey');
|
|
$prop->setAccessible(true);
|
|
|
|
$this->assertEquals('live_sk_xyz789', $prop->getValue($service));
|
|
}
|
|
|
|
/**
|
|
* 설정이 비어있을 때 기본값(테스트 모드, 빈 키)으로 초기화되는지 확인
|
|
*/
|
|
public function test_constructor_defaults_to_test_mode_with_empty_key(): void
|
|
{
|
|
$service = new TossPaymentsApiService($this->mockSettingsService([]));
|
|
|
|
$reflection = new \ReflectionClass($service);
|
|
$prop = $reflection->getProperty('secretKey');
|
|
$prop->setAccessible(true);
|
|
|
|
$this->assertEquals('', $prop->getValue($service));
|
|
}
|
|
|
|
/**
|
|
* 플러그인 설정이 null일 때 기본값으로 초기화되는지 확인
|
|
*/
|
|
public function test_constructor_handles_null_settings_gracefully(): void
|
|
{
|
|
$mock = $this->createMock(PluginSettingsService::class);
|
|
$mock->method('get')
|
|
->with('sirsoft-tosspayments')
|
|
->willReturn(null);
|
|
|
|
$service = new TossPaymentsApiService($mock);
|
|
|
|
$reflection = new \ReflectionClass($service);
|
|
$prop = $reflection->getProperty('secretKey');
|
|
$prop->setAccessible(true);
|
|
|
|
$this->assertEquals('', $prop->getValue($service));
|
|
}
|
|
}
|