Skip to content

refactor: change Repository interface argument from UseCommand to UserEntity#504

Merged
zigzagdev merged 4 commits into
feat/userfrom
refactor/repository-accepts-entity
Jun 29, 2026
Merged

refactor: change Repository interface argument from UseCommand to UserEntity#504
zigzagdev merged 4 commits into
feat/userfrom
refactor/repository-accepts-entity

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

Summary

Motivation

The UserRepositroyInterface was accepting CreateUserCommand (Application layer) as its argument, which violates DDD layering — the Domain layer must not depend on the Application layer.

What I have done

  • UserEntity: make id nullable (?int) to represent a not-yet-persisted entity; add passwordHash field and getPasswordHash() getter
  • UserEntityFactory: support id: null and password_hash key
  • UserRepositroyInterface: change createUser(CreateUserCommand)createUser(UserEntity)
  • UserRepository: use entity getters; password hashing moved from Repository to UseCase
  • CreateUserUseCase: build UserEntity via UserEntityFactory (bcrypt applied here) before passing to repository

Test Results

  • UserRepositoryTest: moved to app/Packages/Domains/Tests/, updated to build UserEntity via factory
  • UserEntityTest: added tests for nullable id and getPasswordHash()
  • UserEntityFactoryTest: added tests for password_hash key and nullable id
  • CreateUserUseCaseTest: verifies UserEntity is passed to repository

@zigzagdev zigzagdev changed the title Refactor/repository accepts entity refactor: change Repository interface argument from UseCommand to UserEntity Jun 28, 2026
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.36%. Comparing base (b78510f) to head (a884076).

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##             feat/user     #504      +/-   ##
===============================================
+ Coverage        58.06%   58.36%   +0.29%     
- Complexity        1453     1460       +7     
===============================================
  Files              112      112              
  Lines             7383     7426      +43     
===============================================
+ Hits              4287     4334      +47     
+ Misses            3096     3092       -4     
Files with missing lines Coverage Δ
...mains/Tests/User/Factory/UserEntityFactoryTest.php 100.00% <100.00%> (ø)
...app/Packages/Domains/Tests/User/UserEntityTest.php 100.00% <100.00%> (ø)
.../app/Packages/Domains/Tests/UserRepositoryTest.php 100.00% <100.00%> (ø)
...ackages/Domains/User/Factory/UserEntityFactory.php 100.00% <100.00%> (ø)
src/app/Packages/Domains/User/UserEntity.php 100.00% <100.00%> (ø)
src/app/Packages/Domains/UserRepository.php 100.00% <100.00%> (ø)
...CommandUseCases/UseCase/User/CreateUserUseCase.php 100.00% <100.00%> (ø)
...es/Tests/CommandUseCases/CreateUserUseCaseTest.php 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 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 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 f54e8ec into feat/user Jun 29, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant