Skip to content

feat: add User registration presentation layer / ユーザー登録プレゼンテーション層の追加 - #492

Merged
zigzagdev merged 7 commits into
feat/user_registerfrom
feat/user_register-presentation_layer
Jun 28, 2026
Merged

feat: add User registration presentation layer / ユーザー登録プレゼンテーション層の追加#492
zigzagdev merged 7 commits into
feat/user_registerfrom
feat/user_register-presentation_layer

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Motivation

With the domain, infrastructure, and application layers in place, the presentation layer is needed to expose user creation as an HTTP endpoint. This PR wires up the controller, view model, and route, completing the full vertical slice for user registration.

What I have done

  • Added password to CreateUserCommand and UserRepository to satisfy the NOT NULL constraint on the users table
  • Added UserViewModel holding a UserDto and exposing toArray() for the JSON response
  • Added UserViewModelFactory to build UserViewModel from UserDto, following the existing factory pattern
  • Added UserController with a createUser action: on success returns 201 with UserViewModelFactory::build($dto)->toArray(); on any error returns 500 to the client and writes full details to Log::error for admin visibility
  • Registered POST /api/v1/user/create in routes/api.php
  • Bound UserRepositroyInterfaceUserRepository in RepositoryProvider so Laravel's container can inject the dependency
  • Added <coverage> section to phpunit.xml (HTML + Clover output); a coverage driver — pcov or xdebug — must be installed in the container to activate it
  • Added integration tests covering: 201 on valid payload, 500 on missing required key, 500 on duplicate email

モチベーション

ドメイン・インフラ・アプリケーション層が揃った状態で、ユーザー登録をHTTPエンドポイントとして公開するプレゼンテーション層が必要でした。このPRでコントローラー・ビューモデル・ルートを繋ぎ合わせ、ユーザー登録の縦断スライスを完成させます。

実装内容

  • CreateUserCommandUserRepositorypassword を追加(users テーブルの NOT NULL 制約を満たすため)
  • UserViewModel を追加:UserDto を保持し、JSONレスポンス用の toArray() を公開
  • UserViewModelFactory を追加:既存のファクトリパターンに倣い UserDto から UserViewModel を生成
  • UserController を追加:成功時は201と UserViewModelFactory::build($dto)->toArray() を返却、エラー時はクライアントに500を返しつつ Log::error で詳細をadmin向けに記録
  • routes/api.phpPOST /api/v1/user/create を登録
  • RepositoryProviderUserRepositroyInterfaceUserRepository のバインドを追加
  • phpunit.xml<coverage> セクション(HTML + Clover出力)を追加。実行には pcov または xdebug のインストールが必要
  • 結合テストを追加:有効データで201・必須キー欠損で500・メール重複で500

Test Results

PASS  App\Packages\Features\Tests\CreateUserTest
✓ create user returns 201 with user data
✓ create user returns 500 when required key is missing
✓ create user returns 500 on duplicate email

Tests: 3 passed (15 assertions)

@zigzagdev
zigzagdev changed the base branch from main to feat/user_register June 28, 2026 10:16
@zigzagdev zigzagdev self-assigned this Jun 28, 2026
@zigzagdev zigzagdev linked an issue Jun 28, 2026 that may be closed by this pull request
3 tasks

@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 3b45bae into feat/user_register Jun 28, 2026
25 checks passed
@zigzagdev
zigzagdev deleted the feat/user_register-presentation_layer branch June 28, 2026 10:31
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.

Create Presentation Layer

1 participant