feat: test suite + admin config CRUD + repo lint - #4
Merged
Merged
Conversation
…g CRUD
Step 8 backend completion + coverage.
Tests (51 total, all green):
- AuthTest: register/login/logout, session, role assignment, me, validation.
- OrderTest: pickup + delivery (shipping fee in total), shipping-zone requirement,
closed-batch + capacity enforcement, status transitions write AuditLog
'status:{from}->{to}', courier-link paste writes audit, customer authz
(404 on another customer's order), customer 403 on admin status update.
- PaymentProofTest: owner upload -> payment_uploaded + audit, non-owner 404,
invalid/missing proof 422, guest 401.
- ConfigTest: public listings + admin CRUD authz for payment methods,
fulfillment options, shipping zones.
- PrepTest: procurement aggregation for confirmed orders, excludes cancelled,
customer 403.
Missing endpoints added: admin CRUD for payment methods + fulfillment options
(ConfigController + routes), so Settings can manage them (UI in Step 9).
Fix: OrderController date comparisons use whereDate() — the Order/Batch
'fulfillment_date' date-cast stores 'Y-m-d H:i:s' in SQLite, so plain
where('fulfillment_date', 'Y-m-d') missed rows (filled=0). whereDate works
in both SQLite and MySQL and keeps the prepared-statement + transaction
boundaries intact.
There was a problem hiding this comment.
Pull request overview
This PR expands the Laravel API backend with new Feature tests across auth/order/payment-proof/prep/config flows, adds admin CRUD endpoints for configuration entities (payment methods and fulfillment options), and applies repo-wide PSR-12 formatting cleanup (Pint) across migrations and related code.
Changes:
- Added Feature tests for Auth, Orders (incl. audit logging), Payment Proof upload, Prep aggregation, and Config endpoints.
- Added admin CRUD endpoints for payment methods and fulfillment options under
/api/admin/*. - Applied PSR-12 formatting updates across migrations and controller return types.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| api/tests/Feature/PrepTest.php | Adds feature coverage for admin prep aggregation and access control. |
| api/tests/Feature/PaymentProofTest.php | Adds feature coverage for payment proof upload + audit log write + ownership enforcement. |
| api/tests/Feature/OrderTest.php | Adds feature coverage for order creation, capacity/cutoff behavior, status transitions, and audit logging. |
| api/tests/Feature/ConfigTest.php | Adds feature coverage for public config listing and admin config creation endpoints. |
| api/tests/Feature/AuthTest.php | Adds feature coverage for register/login/logout/me flows. |
| api/routes/api.php | Wires new admin config CRUD routes for payment methods and fulfillment options. |
| api/database/migrations/2025_06_27_000010_create_audit_logs_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000009_create_settings_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000008_create_order_items_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000007_create_orders_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000006_create_batches_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000005_create_fulfillment_options_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000004_create_payment_methods_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000003_create_recipe_ingredients_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000002_create_menu_items_table.php | PSR-12 formatting adjustments (Pint). |
| api/database/migrations/2025_06_27_000001_create_users_table.php | PSR-12 formatting adjustments (Pint). |
| api/bootstrap/app.php | Uses imported middleware class reference for the role alias. |
| api/app/Traits/JsonResponds.php | Refines return types to Illuminate\Http\Response. |
| api/app/Http/Controllers/Api/PrepController.php | PSR-12/string-concat formatting updates to prepared statement SQL assembly. |
| api/app/Http/Controllers/Api/OrderController.php | Changes fulfillment_date filtering to whereDate() in several queries. |
| api/app/Http/Controllers/Api/ConfigController.php | Adds admin CRUD methods for payment methods and fulfillment options (and validates inputs). |
| api/app/Http/Controllers/Api/AuthController.php | Refines return types to Illuminate\Http\Response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'label' => ['required', 'string', 'max:60'], | ||
| 'account_name' => ['nullable', 'string', 'max:120'], | ||
| 'account_number' => ['nullable', 'string', 'max:60'], | ||
| 'qr_image_url' => ['nullable', 'string', 'url', 'max:500'], |
| 'label' => ['sometimes', 'string', 'max:60'], | ||
| 'account_name' => ['nullable', 'string', 'max:120'], | ||
| 'account_number' => ['nullable', 'string', 'max:60'], | ||
| 'qr_image_url' => ['nullable', 'string', 'url', 'max:500'], |
| $date = $request->query('date', now()->toDateString()); | ||
|
|
||
| $batch = DB::table('batches')->where('fulfillment_date', $date)->first(); | ||
| $batch = DB::table('batches')->whereDate('fulfillment_date', $date)->first(); |
Comment on lines
83
to
86
| $batch = DB::table('batches') | ||
| ->where('fulfillment_date', $data['fulfillment_date']) | ||
| ->whereDate('fulfillment_date', $data['fulfillment_date']) | ||
| ->lockForUpdate() | ||
| ->first(); |
Comment on lines
92
to
95
| $filled = DB::table('orders') | ||
| ->where('fulfillment_date', $data['fulfillment_date']) | ||
| ->whereDate('fulfillment_date', $data['fulfillment_date']) | ||
| ->whereNotIn('status', ['cancelled']) | ||
| ->count(); |
| } | ||
| if ($date = $request->query('date')) { | ||
| $query->where('fulfillment_date', $date); | ||
| $query->whereDate('fulfillment_date', $date); |
Comment on lines
+16
to
+24
| public function test_public_can_list_active_payment_methods(): void | ||
| { | ||
| PaymentMethod::create(['type' => 'gcash', 'label' => 'GCash', 'is_active' => true, 'sort_order' => 1]); | ||
| PaymentMethod::create(['type' => 'cod', 'label' => 'COD', 'is_active' => true, 'sort_order' => 2]); | ||
|
|
||
| $this->getJson('/api/payment-methods') | ||
| ->assertStatus(200) | ||
| ->assertJsonCount(2, 'data'); | ||
| } |
Comment on lines
+26
to
+33
| public function test_public_can_list_fulfillment_options(): void | ||
| { | ||
| FulfillmentOption::create(['mode' => 'pickup', 'label' => 'Pickup', 'is_active' => true, 'sort_order' => 1]); | ||
|
|
||
| $this->getJson('/api/fulfillment-options') | ||
| ->assertStatus(200) | ||
| ->assertJsonCount(1, 'data'); | ||
| } |
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.
Summary
Verification