Skip to content

feat: implement User Delete API / ユーザー削除APIの実装#524

Open
zigzagdev wants to merge 11 commits into
feat/userfrom
feat/user-delete
Open

feat: implement User Delete API / ユーザー削除APIの実装#524
zigzagdev wants to merge 11 commits into
feat/userfrom
feat/user-delete

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

Implement the User Delete API (DELETE /api/v1/users/{id}) across all layers as part of #514.

ユーザー削除API(DELETE /api/v1/users/{id})をInfra・Application・Presentation層にわたって実装しました(#514)。

What I have done / 実施内容

Infra層 (PR #521)

  • UserRepositroyInterface: deleteUser(int $id): void を追加
  • UserRepository: deleteUser 実装
    • IDでユーザーを検索し、存在しない場合は Exception('User not found.') をスロー
    • delete() でレコードを削除
  • UserRepositoryTest: DBインテグレーションテストを2件追加

Application層 (PR #522)

  • DeleteUserUseCase: handle(int $id): void
    • Command オブジェクト不要(削除に必要なのは ID のみ)
    • UserRepositroyInterface::deleteUser() を呼び出し、例外はリポジトリから自動伝播

Presentation層 (PR #523)

  • UserController::deleteUser(): route {id} を int にキャストして DeleteUserUseCase を呼び出す
    • 200 on success
    • 404 when 'User not found.' exception is thrown
    • 500 on other errors with Log::error
  • Route: DELETE /api/v1/users/{id}

Test Results / テスト結果

Infra層

  • test_deleteUser_removes_user_when_exists
  • test_deleteUser_throws_exception_when_user_not_found

Application層

  • test_handle_calls_repository_deleteUser_with_given_id
  • test_handle_propagates_exception_when_user_not_found

Presentation層

  • test_delete_user_returns_200_when_user_exists
  • test_delete_user_returns_404_when_user_not_found

Closes #514

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.01124% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.30%. Comparing base (07483b1) to head (8836cc7).

Files with missing lines Patch % Lines
...pp/Packages/Features/Controller/UserController.php 57.89% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##             feat/user     #524      +/-   ##
===============================================
+ Coverage        59.94%   60.30%   +0.35%     
- Complexity        1515     1534      +19     
===============================================
  Files              120      123       +3     
  Lines             7765     7854      +89     
===============================================
+ Hits              4655     4736      +81     
- Misses            3110     3118       +8     
Files with missing lines Coverage Δ
.../app/Packages/Domains/Tests/UserRepositoryTest.php 100.00% <100.00%> (ø)
src/app/Packages/Domains/UserRepository.php 97.43% <100.00%> (+0.37%) ⬆️
...CommandUseCases/UseCase/User/DeleteUserUseCase.php 100.00% <100.00%> (ø)
...es/Tests/CommandUseCases/DeleteUserUseCaseTest.php 100.00% <100.00%> (ø)
src/app/Packages/Features/Tests/DeleteUserTest.php 100.00% <100.00%> (ø)
...pp/Packages/Features/Controller/UserController.php 79.74% <57.89%> (-6.92%) ⬇️
🚀 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.

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.

1 participant