This commit completes the PR #53 integration by optimizing the test suite: Performance Improvements: - Migrated 25 test files from RefreshDatabase to DatabaseTransactions - Tests now run in 12.69s parallel (previously 30s+) - Increased PostgreSQL max_locks_per_transaction to 256 for parallel testing Test Infrastructure Changes: - Disabled broadcasting in tests (set to null) to avoid Reverb connectivity issues - Reverted 5 integration tests to RefreshDatabase (CheckoutFlowTest + 4 Service tests) that require full schema recreation due to complex fixtures PR #53 Integration Fixes: - Added Product.inStock() scope for inventory queries - Fixed ProductFactory to create InventoryItem records instead of using removed columns - Added Department.products() relationship - Fixed FulfillmentWorkOrderController view variables - Fixed orders migration location_id foreign key constraint - Created seller-layout component wrapper All 146 tests now pass with optimal performance.
53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Models;
|
|
|
|
use App\Models\Business;
|
|
use App\Models\DeliveryWindow;
|
|
use App\Models\Order;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Tests\TestCase;
|
|
|
|
class OrderDeliveryWindowTest extends TestCase
|
|
{
|
|
use DatabaseTransactions;
|
|
|
|
public function test_order_belongs_to_delivery_window(): void
|
|
{
|
|
$seller = Business::factory()->seller()->create();
|
|
$deliveryWindow = DeliveryWindow::factory()->create([
|
|
'business_id' => $seller->id,
|
|
]);
|
|
|
|
$order = Order::factory()->create([
|
|
'delivery_window_id' => $deliveryWindow->id,
|
|
]);
|
|
|
|
$this->assertInstanceOf(DeliveryWindow::class, $order->deliveryWindow);
|
|
$this->assertEquals($deliveryWindow->id, $order->delivery_window_id);
|
|
}
|
|
|
|
public function test_order_stores_actual_delivery_date(): void
|
|
{
|
|
$order = Order::factory()->create([
|
|
'delivery_window_date' => '2025-11-15',
|
|
]);
|
|
|
|
$this->assertNotNull($order->delivery_window_date);
|
|
$this->assertEquals('2025-11-15', $order->delivery_window_date->format('Y-m-d'));
|
|
$this->assertInstanceOf(\Illuminate\Support\Carbon::class, $order->delivery_window_date);
|
|
}
|
|
|
|
public function test_order_can_have_null_delivery_window(): void
|
|
{
|
|
$order = Order::factory()->create([
|
|
'delivery_window_id' => null,
|
|
'delivery_window_date' => null,
|
|
]);
|
|
|
|
$this->assertNull($order->delivery_window_id);
|
|
$this->assertNull($order->delivery_window_date);
|
|
$this->assertNull($order->deliveryWindow);
|
|
}
|
|
}
|