Skip to content

feat: implement Presentation layer for POST /api/v1/favorites / お気に入り追加のPresentation層実装 - #563

Merged
zigzagdev merged 2 commits into
feat/user-favoritefrom
feat/user-favorite-presentation
Aug 7, 2026
Merged

feat: implement Presentation layer for POST /api/v1/favorites / お気に入り追加のPresentation層実装#563
zigzagdev merged 2 commits into
feat/user-favoritefrom
feat/user-favorite-presentation

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Motivation / 目的

Following the Application layer (#562), this PR implements the Presentation layer for the favorites feature: a FavoriteController exposing POST /api/v1/favorites, so an authenticated user can add a world heritage site to their favorites.

The user id is resolved from the authenticated request ($request->user()->id), not from the request body, following the same pattern as AuthController::me() — this prevents a client from adding favorites on behalf of another user.

What I have done / 実施内容

  • Added FavoriteController::addFavorite, calling AddFavoriteUseCase with the authenticated user id and world_heritage_id from the request body
  • Registered POST /api/v1/favorites behind auth:sanctum middleware
  • Added an integration test covering 201 (success + DB persistence), 401 (unauthenticated), and 500 (unexpected error)

Test Results / テスト結果

  • test_addFavorite_returns_201_and_persists_favorite_when_authenticated
  • test_addFavorite_returns_401_when_unauthenticated
  • test_addFavorite_returns_500_on_unexpected_error

Full suite: 188 passed.

@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

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.29412% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.59%. Comparing base (cb94ab5) to head (2f70034).

Files with missing lines Patch % Lines
...ackages/Features/Controller/FavoriteController.php 80.95% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                    @@
##             feat/user-favorite     #563      +/-   ##
========================================================
+ Coverage                 63.28%   63.59%   +0.31%     
- Complexity                 1640     1652      +12     
========================================================
  Files                       140      142       +2     
  Lines                      8497     8582      +85     
========================================================
+ Hits                       5377     5458      +81     
- Misses                     3120     3124       +4     
Files with missing lines Coverage Δ
...Packages/Features/Tests/FavoriteControllerTest.php 100.00% <100.00%> (ø)
...ackages/Features/Controller/FavoriteController.php 80.95% <80.95%> (ø)
🚀 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 merged commit c293a43 into feat/user-favorite Aug 7, 2026
28 checks passed
@zigzagdev
zigzagdev deleted the feat/user-favorite-presentation branch August 7, 2026 00:34
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.

feat: implement Presentation layer for Favorite Heritage API / お気に入りAPIのPresentation層実装

1 participant