Skip to content

feat: test suite + admin config CRUD + repo lint - #4

Merged
cikeyz merged 2 commits into
mainfrom
feat/tests
Jun 27, 2026
Merged

feat: test suite + admin config CRUD + repo lint#4
cikeyz merged 2 commits into
mainfrom
feat/tests

Conversation

@cikeyz

@cikeyz cikeyz commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • adds Auth, Order, PaymentProof, Config, and Prep feature coverage
  • adds admin CRUD endpoints for payment methods, fulfillment options, and shipping zones
  • applies repo-wide Laravel Pint PSR-12 cleanup

Verification

  • php ../tools/composer.phar test: 51 passed, 101 assertions
  • vendor/bin/pint --test: passed

cikeyz added 2 commits June 27, 2026 14:33
…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.
Copilot AI review requested due to automatic review settings June 27, 2026 09:20
@cikeyz
cikeyz merged commit f4be401 into main Jun 27, 2026
1 check passed
@cikeyz
cikeyz deleted the feat/tests branch June 27, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
}
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.

2 participants