Skip to content

feat: implement User Update API / ユーザー更新APIの実装#520

Merged
zigzagdev merged 15 commits into
feat/userfrom
feat/user_update
Jul 3, 2026
Merged

feat: implement User Update API / ユーザー更新APIの実装#520
zigzagdev merged 15 commits into
feat/userfrom
feat/user_update

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

Implement the User Update API (PATCH /api/v1/users/{id}) across all layers as part of #500.

ユーザー更新API(PATCH /api/v1/users/{id})をInfra・Application・Presentation層にわたって実装しました(#500)。

What I have done / 実施内容

Infra層 (PR #505)

  • UserRepositroyInterface: updateUser(UserEntity $entity): UserDto を追加
  • UserRepository: updateUser 実装
    • IDでユーザーを検索し、存在しない場合は Exception をスロー
    • エンティティの全フィールドを上書き保存し、refresh() 後に UserDto として返却
  • UserRepositoryTest: MockeryベースのユニットテストからDBを使ったインテグレーションテストに刷新

Application層 (PR #518)

  • UpdateUserCommand: id 必須・パスワードなし(パスワード変更は別API)
  • UpdateUserUseCase: UpdateUserCommand から UserEntity を組み立てて updateUser を呼び出す
  • CQSリファクタリング: UserViewModel / UserViewModelFactoryCommandUseCases から QueryUseCases へ移動(読み取り専用オブジェクトのため)

Presentation層 (PR #519)

  • UserController::updateUser(): ルートの {id} とリクエストボディをマージして UpdateUserCommand を生成し、UpdateUserUseCase を実行
    • 200: 成功
    • 404: ユーザー不存在('User not found.' 例外)
    • 500: その他エラー(Log::error でログ記録)
  • Route: PATCH /api/v1/users/{id}

Test Results / テスト結果

Infra層

  • test_createUser_persists_and_returns_user_dto
  • test_findById_returns_user_dto_when_user_exists
  • test_findById_returns_null_when_user_does_not_exist
  • test_updateUser_returns_user_dto_on_success
  • test_updateUser_throws_exception_when_user_not_found

Application層

  • test_update_user_command_builds_from_array
  • test_update_user_command_throws_when_required_key_is_missing
  • test_handle_returns_user_dto_on_success
  • test_handle_calls_repository_with_correct_entity

Presentation層

  • test_update_user_returns_200_with_updated_data
  • test_update_user_returns_404_when_user_not_found
  • test_update_user_returns_500_when_required_key_is_missing

Closes #500

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.26316% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.94%. Comparing base (0a1b83a) to head (21a990a).

Files with missing lines Patch % Lines
...es/Tests/CommandUseCases/UpdateUserCommandTest.php 77.50% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##             feat/user     #520      +/-   ##
===============================================
+ Coverage        59.06%   59.94%   +0.88%     
- Complexity        1488     1515      +27     
===============================================
  Files              115      120       +5     
  Lines             7575     7765     +190     
===============================================
+ Hits              4474     4655     +181     
- Misses            3101     3110       +9     
Files with missing lines Coverage Δ
...CommandUseCases/UseCase/User/UpdateUserUseCase.php 100.00% <100.00%> (ø)
...mandUseCases/UseCommand/User/UpdateUserCommand.php 100.00% <100.00%> (ø)
...pp/Packages/Features/Controller/UserController.php 86.66% <100.00%> (+8.88%) ⬆️
...seCases/Factory/ViewModel/UserViewModelFactory.php 100.00% <ø> (ø)
...Cases/Tests/ViewModel/UserViewModelFactoryTest.php 100.00% <ø> (ø)
...ueryUseCases/Tests/ViewModel/UserViewModelTest.php 100.00% <ø> (ø)
...res/QueryUseCases/ViewModel/User/UserViewModel.php 100.00% <ø> (ø)
...es/Tests/CommandUseCases/UpdateUserUseCaseTest.php 100.00% <100.00%> (ø)
src/app/Packages/Features/Tests/UpdateUserTest.php 100.00% <100.00%> (ø)
...es/Tests/CommandUseCases/UpdateUserCommandTest.php 77.50% <77.50%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zigzagdev zigzagdev self-assigned this Jul 3, 2026
@zigzagdev zigzagdev linked an issue Jul 3, 2026 that may be closed by this pull request

@zigzagdev zigzagdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Ok

@zigzagdev zigzagdev merged commit 07483b1 into feat/user Jul 3, 2026
27 checks passed
@zigzagdev zigzagdev deleted the feat/user_update branch July 3, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User Update API

1 participant