feat: implement User registration API / ユーザー登録APIの実装#495
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat: usersテーブルのmigrationとUserモデルの追加 / Add users table migration and User model
feat: add User domain layer / Userドメイン層の追加
feat: add User registration infrastructure layer
…eateUserCommand and UserDtoFactory
…_layer feat: add User registration application layer
…n_layer feat: add User registration presentation layer / ユーザー登録プレゼンテーション層の追加
feat: add Codecov integration for PR coverage reporting / CodecovによるPRカバレッジレポートの追加
Closed
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
…erage test: add unit tests to improve Codecov patch coverage / ユニットテストを追加してCodecovのパッチカバレッジを改善
…erage test: add unit tests for factories and UserEntity to improve patch coverage / FactoryとUserEntityのユニットテストを追加してパッチカバレッジを改善
…erage refactor: move unit tests to app/Packages/ so phpunit.xml discovers them / ユニットテストをapp/Packages/配下に移動してCIで検出されるように修正
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The application needed a full vertical slice for user registration, from the database layer up to the HTTP endpoint. This PR implements the complete User registration feature across all layers — domain, infrastructure, application, and presentation — along with test coverage and Codecov integration.
What I have done
Domain layer
userstable migration andUserEloquent modelAgeRangeenum,SubscriptionTierenum,Subscriptionvalue object, andUserEntitySubscriptionFactoryandUserEntityFactoryInfrastructure layer
UserRepositoryInterfaceandUserRepository(mapsCreateUserCommandto DB columns, useswasRecentlyCreatedto detect insert failures)UserDtowith typed public readonly propertiesUserDtoFactoryto buildUserDtofrom a raw attribute arrayApplication layer
CreateUserCommandwith required key validation (first_name,last_name,email,password,age_range,subscription_tier)CreateUserUseCasedelegating toUserRepositoryInterfacePresentation layer
UserViewModelandUserViewModelFactoryUserControllerwith try/catch: returns 201 on success, 500 to client +Log::erroron failurePOST /api/v1/user/createrouteUserRepositroyInterface→UserRepositoryinRepositoryProviderCI / Coverage
pcovto the CI workflow and configured PHPUnit to generate Clover XMLcodecov/codecov-action@v5for per-PR coverage reportingcodecov.yml(80% patch coverage threshold)モチベーション
ユーザー登録機能をDBからHTTPエンドポイントまで縦断的に実装する必要がありました。このPRはドメイン・インフラ・アプリケーション・プレゼンテーションの全層にわたってユーザー登録機能を実装し、テストカバレッジとCodecov連携も合わせて導入します。
実装内容
ドメイン層
usersテーブルのマイグレーションとUserEloquentモデルを追加AgeRangeenum・SubscriptionTierenum・Subscription値オブジェクト・UserEntityを追加SubscriptionFactory・UserEntityFactoryを追加インフラ層
UserRepositoryInterfaceとUserRepositoryを追加(CreateUserCommandをDBカラムにマッピング、wasRecentlyCreatedで挿入失敗を検出)UserDtoを追加(型付き public readonly プロパティ)UserDtoFactoryを追加(生配列からUserDtoを生成)アプリケーション層
CreateUserCommandを追加(必須キーのバリデーション:first_name・last_name・email・password・age_range・subscription_tier)CreateUserUseCaseを追加(UserRepositoryInterfaceに委譲)プレゼンテーション層
UserViewModelとUserViewModelFactoryを追加UserControllerを追加(try/catch:成功時201、失敗時クライアントに500 +Log::errorで詳細を記録)POST /api/v1/user/createルートを登録RepositoryProviderにUserRepositroyInterface→UserRepositoryのバインドを追加CI / カバレッジ
pcovを追加し、PHPUnitがClover XMLを生成するよう設定codecov/codecov-action@v5を追加してPRごとにカバレッジを報告codecov.ymlを追加(patchカバレッジ閾値80%)Test Results