fix: default subscription_tier to free in SubscriptionFactory when omitted / SubscriptionFactoryでsubscription_tier省略時にfreeへデフォルト設定 - #558
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/user #558 +/- ##
===============================================
+ Coverage 62.85% 62.90% +0.04%
- Complexity 1621 1622 +1
===============================================
Files 136 136
Lines 8399 8410 +11
===============================================
+ Hits 5279 5290 +11
Misses 3120 3120
🚀 New features to boost your workflow:
|
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 / 目的
subscription_tierwas already made optional at theCreateUserCommand/CreateUserUseCaselevel, but the Domain-layer factories (UserEntityFactory,SubscriptionFactory) still assumed the key was always present and non-null. Any future caller that omittedsubscription_tierwould hit aTypeErrorfromSubscriptionTier::from(null)instead of getting the intendedfreedefault.subscription_tierはCreateUserCommand/CreateUserUseCase側では既に任意項目化されていましたが、Domain層のファクトリ(UserEntityFactory,SubscriptionFactory)は依然として値が必ず存在する前提でした。将来subscription_tierを省略する呼び出しが増えた場合、SubscriptionTier::from(null)でTypeErrorになってしまう抜けがありました。What I have done / 実施内容
SubscriptionFactory::build(): default the tier toSubscriptionTier::Free->valuewhen$data['tier']is nullUserEntityFactory::build(): pass$data['subscription_tier'] ?? nullinstead of a direct array access, so a missing key no longer raises an undefined array key warning before reachingSubscriptionFactoryTest Results / テスト結果
UserEntityFactoryTest::test_build_returns_user_entity_with_correct_valuesUserEntityFactoryTest::test_build_sets_password_hash_when_providedUserEntityFactoryTest::test_build_defaults_subscription_tier_to_free_when_omittedUserEntityFactoryTest::test_build_passes_expires_at_to_subscriptionSubscriptionTest(all cases)UserEntityTest(all cases)CreateUserCommandTest/CreateUserUseCaseTest/UpdateUserCommandTest/UpdateUserUseCaseTest(all cases)Closes #559