Skip to content

fix: 응답 매핑 TypeError 수정 및 CI·테스트 인프라 정비#27

Merged
Palbahngmiyine merged 11 commits into
solapi:masterfrom
Palbahngmiyine:master
May 11, 2026
Merged

fix: 응답 매핑 TypeError 수정 및 CI·테스트 인프라 정비#27
Palbahngmiyine merged 11 commits into
solapi:masterfrom
Palbahngmiyine:master

Conversation

@Palbahngmiyine
Copy link
Copy Markdown
Member

Summary

SOLAPI PHP SDK의 응답 매핑 안정성 문제(#26)를 해결하고, CI/CD 파이프라인과 테스트 인프라를 정비합니다.

Bug Fixes

CI / Workflows

  • PR 머지 시 자동 릴리즈하는 release.yml 추가
  • ci.yml 추가 및 매트릭스 중복 제거, PHP 7.1/7.2 의존성 이슈 해결
  • PHP 7.1의 옛 Composer가 audit.block-insecure 설정을 지원하지 않는 문제 회피
  • e2e.yml 추가

Tests

  • 응답 생성자에 대한 단위 테스트 ResponseConstructorTest 추가
  • SolapiMessageService에 대한 단위 테스트 추가 (FakeHttpClient 도입)
  • phpunit.xml에 Unit/E2E testsuite 분리
  • 결과: 77 tests, 217 assertions 통과

Chore / Docs

  • composer.lock: phpunit·sebastian/comparator 패치 버전 업데이트
  • .gitignore: .claude/ 디렉토리 추가
  • AGENTS.md·CLAUDE.md를 테스트 작성 지침 중심으로 교체

Changes

  • src/Libraries/ResponseMapper.php (신규): list/nested 응답 매핑 헬퍼
  • src/Libraries/Fetcher.php: 응답 디코딩 보강
  • src/Models/Response/*: 다수 모델의 생성자 안전성 강화 (GetGroupsResponse, GetMessagesResponse, GroupMessageResponse, GetStatisticsResponse, CommonCashResponse 등)
  • src/Services/SolapiMessageService.php: 응답 매핑 경로 정비
  • tests/Models/Response/ResponseConstructorTest.php (신규)
  • tests/Services/SolapiMessageServiceTest.php (신규)
  • tests/Services/FakeHttpClient.php (신규)
  • .github/workflows/{ci,e2e,release}.yml (신규)

Test plan

  • 로컬 composer test:unit 통과 확인 (77 tests / 217 assertions)
  • upstream CI 매트릭스 (PHP 7.1 ~ 8.x) 통과 확인
  • 실제 API 응답에서 nested object/list 필드 매핑 회귀 없음 확인

🤖 Generated with Claude Code

Palbahngmiyine and others added 10 commits May 11, 2026 08:03
기존 수동 버저닝 체계(composer.json + DefaultAgent.php 직접 수정, v{semver} 태그)를 그대로 유지하면서, master 머지 시 CI가 통과해야만 자동으로 태그/Release를 생성한다. 두 파일 간 버전 drift 검출과 동일 태그 존재 시 idempotent skip 가드를 포함한다. solactl의 workflow_run 분리형 패턴 차용.

- ci.yml: PHP 7.1~8.5 매트릭스 unit test (PHP 7.1/7.2는 PHPUnit ^7.5)
- release.yml: workflow_run으로 CI 성공 + master push에 한해 실행
- e2e.yml: workflow_dispatch 수동 트리거, production environment 보호

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
이전 매트릭스는 phpunit-constraint를 매트릭스 변수로 두고 include로
PHP 7.1/7.2용 ^7.5 조합을 추가했는데, GitHub Actions의 include 규칙상
기존 변수 값을 덮어쓰면 새 조합이 추가되어 PHP 7.1/7.2가 각각 2번씩
실행됐다 (10 + 2 = 12 jobs). 또한 PHP 7.1/7.2의 ^9.5 조합은 PHP 7.3+
요구로 실패했고, 7.2의 ^7.5는 composer의 block-insecure가 PHPUnit 7.5의
보안 권고(PKSA-z3gr-8qht-p93v)를 차단해 실패했다.

- phpunit-constraint를 매트릭스에서 제거하고 step의 case 분기로 결정 → 정확히 10 jobs
- PHP 7.1/7.2 한정으로 composer config audit.block-insecure false 적용
  (CI에서 dev-only 의존성에 대한 audit은 실용 의미가 없음)
- FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env로 Node.js 20 deprecation 경고 제거
- e2e.yml에도 동일한 분기 및 audit 우회 적용

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PHP 7.1 러너에 설치되는 Composer는 <=2.2 버전이라 audit.block-insecure
키 자체를 모르고 InvalidArgumentException으로 종료된다. 다행히 같은 옛
Composer는 block-insecure 기능 자체가 없어 PHPUnit 7.5 설치를 차단하지도
않으므로, 명령 실패를 무시하고 진행하면 install이 정상 동작한다. PHP 7.2의
신 Composer에서는 명령이 성공하여 의도대로 block-insecure를 끈다.
ci: PR 머지 시 자동 릴리즈 GitHub Actions 워크플로 추가
Fetcher::request()가 반환하는 stdClass를 Response 객체로 감싸지 않아
getBalance/getGroup/getGroupMessages/getStatistics에서 TypeError가 발생하던
문제를 수정하고, 응답 매핑의 정확성과 일관성을 전반적으로 개선합니다.

주요 변경:
- 4개 get* 메소드에 Response 객체 래핑 추가 (이슈 solapi#26 회귀 방지)
- send() groupInfo NPE 가드 + 7개 get* 메소드에 null result 가드
- GroupCount/MessageType/CommonCashResponse 등 nested 모델에 생성자 추가
- GroupMessageResponse/GetStatisticsResponse 등에서 nested 객체 자동 변환
- ResponseMapper 헬퍼 신설하여 반복 매핑 패턴 통합 (mapObject/mapList)
- @param mixed → @param \stdClass, @var 타입 114개 nullable 정직화
- PSR-18 fake HTTP client 기반 회귀 테스트 45개 추가 (총 77/217)
- Fetcher::resetForTesting() 추가로 테스트 격리 개선

Fixes solapi#26

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rror

fix: getBalance 등 응답 메소드 TypeError 해결 및 매핑 정리 (solapi#26)
Claude Code의 worktrees 등 로컬 작업 디렉토리가 매번 untracked로 잡혀
git status를 어지럽히는 문제를 해결합니다.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- phpunit/phpunit 9.6.31 → 9.6.34
- sebastian/comparator 4.0.9 → 4.0.10

dev 의존성 패치 업데이트만 적용. 공개 API 영향 없음.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
기존 프로젝트 구조 가이드를 테스트 작성 원칙 문서로 교체합니다.
Read First, Required, Failure Injection, Concurrency, Determinism 등
테스트 작성 시 따라야 할 규약을 명문화하여 자동화 에이전트(Codex,
Claude Code 등)와 사람 모두에게 일관된 가이드를 제공합니다.

User-approved: 사용자가 /wrap-up Phase 1에서 "의도된 교체"로 명시 확인.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
chore: gitignore·의존성·테스트 문서 정리
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the SDK's stability and type safety by refactoring response models to use typed constructors and introducing a ResponseMapper utility to handle API-specific data quirks. It also establishes a comprehensive unit testing suite for services and response mapping. Review feedback identifies a missing assignment for messageList in GetMessagesResponse, suggests using array_values in the mapper to ensure consistent indexed arrays, and recommends adding null coalescing to UploadFileResponse to prevent potential undefined property notices.

Comment thread src/Models/Response/GetMessagesResponse.php
Comment thread src/Libraries/ResponseMapper.php Outdated
Comment thread src/Models/Response/UploadFileResponse.php Outdated
@Palbahngmiyine Palbahngmiyine merged commit af1fdaf into solapi:master May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant