-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add a person as an offer field type #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||||||||||||||||
| use Tests\Support\StrictCreateOfferRequest; | ||||||||||||||||||||
| use Tests\Support\User; | ||||||||||||||||||||
| use Tests\TestCase; | ||||||||||||||||||||
| use Whilesmart\Admin\Contracts\OfferField; | ||||||||||||||||||||
| use Whilesmart\Admin\Http\Requests\UpdateMailTemplateRequest; | ||||||||||||||||||||
| use Whilesmart\Admin\Support\Offer; | ||||||||||||||||||||
| use Whilesmart\Admin\Support\OfferRegistry; | ||||||||||||||||||||
|
|
@@ -200,4 +201,15 @@ public static function unknownProvider(): array | |||||||||||||||||||
| 'revoking' => ['DELETE', 'api/admin/offers/credits/1'], | ||||||||||||||||||||
| ]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public function test_a_field_may_ask_for_a_person(): void | ||||||||||||||||||||
| { | ||||||||||||||||||||
| $field = new OfferField( | ||||||||||||||||||||
| name: 'for_email', | ||||||||||||||||||||
| label: 'Only for', | ||||||||||||||||||||
| type: 'user', | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| $this->assertSame('user', $field->toArray()['type']); | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As written, the assertion only verifies that the constructor echoes back the value it was given, so it would still pass for any string (e.g. a typo like
Suggested change
|
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new test verifies the contract at the producer boundary only through
toArray()['type']. Asserting the fulltoArray()shape pins the output schema that the consumer (offer/field JSON) depends on, so any future change to the field keys or defaults is caught here rather than silently changing what consumers receive. This keeps the producer contract explicit without introducing a second formatter.