type: FileChange

type: add

content:
<?php

use App\Enums\PaymentStatus;
use App\Models\InventoryItem;
use App\Models\Order;
use App\Models\Product;
use App\Models\ShippingRate;
use App\Models\Store;
use Database\Seeders\ShopSeeder;

uses(\Illuminate\Foundation\Testing\LazilyRefreshDatabase::class);

beforeEach(function (): void {
    config(['cache.default' => 'array']);
    $this->seed(ShopSeeder::class);
    $this->store = Store::query()->where('handle', 'acme-fashion')->firstOrFail();
    app()->instance('current_store', $this->store);
});

test('guest cart and card checkout create a paid order', function (): void {
    $variant = Product::query()->where('handle', 'classic-cotton-t-shirt')->firstOrFail()->variants()->firstOrFail();

    $cart = $this->postJson('http://shop.test/api/storefront/v1/carts', ['currency' => 'EUR'])
        ->assertCreated()
        ->json();

    $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", [
        'variant_id' => $variant->getKey(),
        'quantity' => 1,
        'cart_version' => 1,
    ])->assertCreated();

    $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', [
        'cart_id' => $cart['id'],
        'email' => 'flow@example.test',
    ])->assertCreated()->json();

    $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", [
        'shipping_address' => [
            'first_name' => 'Flow',
            'last_name' => 'Tester',
            'address1' => '1 Test Street',
            'city' => 'Berlin',
            'country_code' => 'DE',
            'postal_code' => '10115',
        ],
    ])->assertOk()->assertJsonPath('status', 'addressed');

    $rate = ShippingRate::query()->firstOrFail();
    $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/shipping-method", [
        'shipping_method_id' => $rate->getKey(),
    ])->assertOk()->assertJsonPath('status', 'shipping_selected');

    $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", [
        'payment_method' => 'credit_card',
        'card_number' => '4242424242424242',
    ])->assertOk()->assertJsonPath('order.financial_status', 'paid');

    $order = Order::query()->latest('id')->firstOrFail();

    expect($order->payment_method)->toBe('credit_card')
        ->and($order->financial_status->value)->toBe('paid')
        ->and($order->payments()->firstOrFail()->status)->toBe(PaymentStatus::Captured)
        ->and($order->checkout->status->value)->toBe('completed');
});

test('declined payments release the reservation and do not create an order', function (): void {
    $variant = Product::query()->where('handle', 'classic-cotton-t-shirt')->firstOrFail()->variants()->firstOrFail();
    $inventoryBefore = InventoryItem::query()->where('variant_id', $variant->getKey())->firstOrFail()->quantity_reserved;

    $cart = $this->postJson('http://shop.test/api/storefront/v1/carts')->json();
    $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", ['variant_id' => $variant->getKey(), 'quantity' => 1, 'cart_version' => 1]);
    $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', ['cart_id' => $cart['id'], 'email' => 'declined@example.test'])->json();
    $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", ['shipping_address' => ['first_name' => 'Declined', 'last_name' => 'Tester', 'address1' => '1 Test Street', 'city' => 'Berlin', 'country_code' => 'DE', 'postal_code' => '10115']]);
    $rate = ShippingRate::query()->firstOrFail();
    $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/shipping-method", ['shipping_method_id' => $rate->getKey()]);

    $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", ['payment_method' => 'credit_card', 'card_number' => '4000000000000002'])->assertUnprocessable();

    expect(InventoryItem::query()->where('variant_id', $variant->getKey())->firstOrFail()->quantity_reserved)->toBe($inventoryBefore)
        ->and(Order::query()->where('email', 'declined@example.test')->exists())->toBeFalse();
});

test('stale cart versions return a conflict response', function (): void {
    $variant = Product::query()->where('handle', 'classic-cotton-t-shirt')->firstOrFail()->variants()->firstOrFail();
    $cart = $this->postJson('http://shop.test/api/storefront/v1/carts')->json();

    $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", ['variant_id' => $variant->getKey(), 'quantity' => 1, 'cart_version' => 1])->assertCreated();
    $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", ['variant_id' => $variant->getKey(), 'quantity' => 1, 'cart_version' => 1])->assertConflict();
});

content:
<?php

use App\Enums\DiscountValueType;
use App\Enums\PaymentMethod;
use App\Enums\PaymentStatus;
use App\Models\Checkout;
use App\Models\Discount;
use App\Services\DiscountService;
use App\Services\MockPaymentProvider;
use App\Services\TaxCalculator;

test('tax calculations use integer minor-unit arithmetic', function (): void {
    $calculator = new TaxCalculator;

    expect($calculator->addExclusive(2499, 1900))->toBe(474)
        ->and($calculator->extractInclusive(2973, 1900))->toBe(474);
});

test('discount calculations cap fixed discounts and allocate percentages', function (): void {
    $service = new DiscountService;
    $discount = new Discount(['value_type' => DiscountValueType::Percent, 'value_amount' => 10]);

    $result = $service->calculate($discount, 10000, [
        ['line_id' => 1, 'amount' => 6000],
        ['line_id' => 2, 'amount' => 4000],
    ]);

    expect($result->amount)->toBe(1000)
        ->and($result->allocations)->toBe([1 => 600, 2 => 400]);

    $fixed = new Discount(['value_type' => DiscountValueType::Fixed, 'value_amount' => 5000]);

    expect($service->calculate($fixed, 300, [['line_id' => 1, 'amount' => 300]])->amount)->toBe(300);
});

test('free shipping discounts do not reduce merchandise totals', function (): void {
    $discount = new Discount(['value_type' => DiscountValueType::FreeShipping, 'value_amount' => 0]);
    $result = (new DiscountService)->calculate($discount, 2500, [['line_id' => 1, 'amount' => 2500]]);

    expect($result->amount)->toBe(0)->and($result->freeShipping)->toBeTrue();
});

test('mock payment provider supports the documented magic cards and deferred transfers', function (): void {
    $provider = new MockPaymentProvider;
    $checkout = new Checkout;

    expect($provider->charge($checkout, PaymentMethod::CreditCard, ['card_number' => '4242424242424242'])->status)
        ->toBe(PaymentStatus::Captured)
        ->and($provider->charge($checkout, PaymentMethod::CreditCard, ['card_number' => '4000000000000002'])->status)
        ->toBe(PaymentStatus::Failed)
        ->and($provider->charge($checkout, PaymentMethod::BankTransfer, [])->status)
        ->toBe(PaymentStatus::Pending);
});

stdout:
Success. Updated the following files:
A /Users/wesner/Herd/shop/tests/Unit/PricingEngineTest.php
A /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php
D /Users/wesner/Herd/shop/tests/Unit/PricingEngineTest.php
D /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php


text:
Script completed
Wall time 0.0 seconds
Output:


exec

status: completed

input:
const results = await Promise.all([
  tools.exec_command({cmd:"php artisan test tests/Unit/PricingEngineTest.php",workdir:"/Users/wesner/Herd/shop",yield_time_ms:30000,max_output_tokens:8000}),
  tools.exec_command({cmd:"php artisan test tests/Feature/CommerceFlowTest.php",workdir:"/Users/wesner/Herd/shop",yield_time_ms:30000,max_output_tokens:12000})
]);
for (const r of results) text(r.output);


type: CommandExecution

command: php artisan test tests/Unit/PricingEngineTest.php

type: unknown

status: completed

stdout:
   PASS  Tests\Unit\PricingEngineTest
  ✓ tax calculations use integer minor-unit arithmetic
  ✓ discount calculations cap fixed discounts and allocate percentages
  ✓ free shipping discounts do not reduce merchandise totals
  ✓ mock payment provider supports the documented magic cards and deferred transfers

  Tests:    4 passed (10 assertions)
  Duration: 0.04s


command: php artisan test tests/Feature/CommerceFlowTest.php

status: failed

stdout:
   FAIL  Tests\Feature\CommerceFlowTest
  ⨯ guest cart and card checkout create a paid order                     0.13s
  ⨯ declined payments release the reservation and do not create an orde… 0.03s
  ✓ stale cart versions return a conflict response                       0.03s
  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > guest cart and card checkout cre…
  Expected response status code [201] but received 500.
Failed asserting that 500 is identical to 201.

The following exception occurred during the last request:

RuntimeException: Session store not set on request. in /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Request.php:610
Stack trace:
#0 /Users/wesner/Herd/shop/app/Providers/AppServiceProvider.php(39): Illuminate\Http\Request->session()
#1 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(74): App\Providers\AppServiceProvider->{closure:App\Providers\AppServiceProvider::boot():39}(Object(Illuminate\Http\Request))
#2 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(121): Illuminate\Cache\RateLimiter->{closure:Illuminate\Cache\RateLimiter::limiter():73}(Object(Illuminate\Http\Request))
#3 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'checkout', Object(Closure))
#4 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'checkout')
#5 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#6 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#7 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront', Object(Closure))
#8 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront')
#9 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#10 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(821): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#12 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#13 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#14 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#15 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Kernel->{closure:Illuminate\Foundation\Http\Kernel::dispatchToRouter():197}(Object(Illuminate\Http\Request))
#16 /Users/wesner/Herd/shop/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#17 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Livewire\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#19 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#22 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#25 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#27 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(74): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#29 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#31 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#33 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePathEncoding.php(26): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#35 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePathEncoding->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#37 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#38 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#39 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(607): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#40 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(573): Illuminate\Foundation\Testing\TestCase->call('POST', 'http://shop.tes...', Array, Array, Array, Array, '{"cart_id":1,"e...')
#41 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(411): Illuminate\Foundation\Testing\TestCase->json('POST', 'http://shop.tes...', Array, Array, 0)
#42 /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php(33): Illuminate\Foundation\Testing\TestCase->postJson('http://shop.tes...', Array)
#43 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php(168): P\Tests\Feature\CommerceFlowTest->{closure:/Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php:20}()
#44 [internal function]: P\Tests\Feature\CommerceFlowTest->{closure:Pest\Factories\TestCaseMethodFactory::getClosure():158}()
#45 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): call_user_func_array(Object(Closure), Array)
#46 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Support/ExceptionTrace.php(26): P\Tests\Feature\CommerceFlowTest->{closure:Pest\Concerns\Testable::__callClosure():429}()
#47 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): Pest\Support\ExceptionTrace::ensure(Object(Closure))
#48 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(331): P\Tests\Feature\CommerceFlowTest->__callClosure(Object(Closure), Array)
#49 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseFactory.php(169) : eval()'d code(17): P\Tests\Feature\CommerceFlowTest->__runTest(Object(Closure))
#50 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(1332): P\Tests\Feature\CommerceFlowTest->__pest_evaluable_guest_cart_and_card_checkout_create_a_paid_order()
#51 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(519): PHPUnit\Framework\TestCase->runTest()
#52 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php(99): PHPUnit\Framework\TestCase->runBare()
#53 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(359): PHPUnit\Framework\TestRunner->run(Object(P\Tests\Feature\CommerceFlowTest))
#54 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestSuite.php(374): PHPUnit\Framework\TestCase->run()
#55 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
#56 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/Application.php(229): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\DefaultResultCache), Object(PHPUnit\Framework\TestSuite))
#57 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Kernel.php(103): PHPUnit\TextUI\Application->run(Array)
#58 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(184): Pest\Kernel->handle(Array, Array)
#59 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(192): {closure:/Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest:18}()
#60 {main}

----------------------------------------------------------------------------------

Session store not set on request.

  at tests/Feature/CommerceFlowTest.php:36
     32▕
     33▕     $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', [
     34▕         'cart_id' => $cart['id'],
     35▕         'email' => 'flow@example.test',
  ➜  36▕     ])->assertCreated()->json();
     37▕
     38▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", [
     39▕         'shipping_address' => [
     40▕             'first_name' => 'Flow',

  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > declined payment…  ErrorException
  Undefined array key "id"

  at tests/Feature/CommerceFlowTest.php:74
     70▕
     71▕     $cart = $this->postJson('http://shop.test/api/storefront/v1/carts')->json();
     72▕     $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", ['variant_id' => $variant->getKey(), 'quantity' => 1, 'cart_version' => 1]);
     73▕     $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', ['cart_id' => $cart['id'], 'email' => 'declined@example.test'])->json();
  ➜  74▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", ['shipping_address' => ['first_name' => 'Declined', 'last_name' => 'Tester', 'address1' => '1 Test Street', 'city' => 'Berlin', 'country_code' => 'DE', 'postal_code' => '10115']]);
     75▕     $rate = ShippingRate::query()->firstOrFail();
     76▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/shipping-method", ['shipping_method_id' => $rate->getKey()]);
     77▕
     78▕     $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", ['payment_method' => 'credit_card', 'card_number' => '4000000000000002'])->assertUnprocessable();

  Tests:    2 failed, 1 passed (5 assertions)
  Duration: 0.22s


text:
Script completed
Wall time 0.4 seconds
Output:

text:
   PASS  Tests\Unit\PricingEngineTest
  ✓ tax calculations use integer minor-unit arithmetic
  ✓ discount calculations cap fixed discounts and allocate percentages
  ✓ free shipping discounts do not reduce merchandise totals
  ✓ mock payment provider supports the documented magic cards and deferred transfers

  Tests:    4 passed (10 assertions)
  Duration: 0.04s

text:
   FAIL  Tests\Feature\CommerceFlowTest
  ⨯ guest cart and card checkout create a paid order                     0.13s
  ⨯ declined payments release the reservation and do not create an orde… 0.03s
  ✓ stale cart versions return a conflict response                       0.03s
  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > guest cart and card checkout cre…
  Expected response status code [201] but received 500.
Failed asserting that 500 is identical to 201.

The following exception occurred during the last request:

RuntimeException: Session store not set on request. in /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Request.php:610
Stack trace:
#0 /Users/wesner/Herd/shop/app/Providers/AppServiceProvider.php(39): Illuminate\Http\Request->session()
#1 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Cache/RateLimiter.php(74): App\Providers\AppServiceProvider->{closure:App\Providers\AppServiceProvider::boot():39}(Object(Illuminate\Http\Request))
#2 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(121): Illuminate\Cache\RateLimiter->{closure:Illuminate\Cache\RateLimiter::limiter():73}(Object(Illuminate\Http\Request))
#3 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'checkout', Object(Closure))
#4 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'checkout')
#5 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#6 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#7 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront', Object(Closure))
#8 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront')
#9 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#10 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(821): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#11 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#12 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#13 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#14 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#15 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Kernel->{closure:Illuminate\Foundation\Http\Kernel::dispatchToRouter():197}(Object(Illuminate\Http\Request))
#16 /Users/wesner/Herd/shop/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#17 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Livewire\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#19 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#22 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#24 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#25 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#27 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(74): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#29 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#31 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#33 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePathEncoding.php(26): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#35 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePathEncoding->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#37 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#38 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#39 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(607): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#40 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(573): Illuminate\Foundation\Testing\TestCase->call('POST', 'http://shop.tes...', Array, Array, Array, Array, '{"cart_id":1,"e...')
#41 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(411): Illuminate\Foundation\Testing\TestCase->json('POST', 'http://shop.tes...', Array, Array, 0)
#42 /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php(33): Illuminate\Foundation\Testing\TestCase->postJson('http://shop.tes...', Array)
#43 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php(168): P\Tests\Feature\CommerceFlowTest->{closure:/Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php:20}()
#44 [internal function]: P\Tests\Feature\CommerceFlowTest->{closure:Pest\Factories\TestCaseMethodFactory::getClosure():158}()
#45 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): call_user_func_array(Object(Closure), Array)
#46 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Support/ExceptionTrace.php(26): P\Tests\Feature\CommerceFlowTest->{closure:Pest\Concerns\Testable::__callClosure():429}()
#47 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): Pest\Support\ExceptionTrace::ensure(Object(Closure))
#48 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(331): P\Tests\Feature\CommerceFlowTest->__callClosure(Object(Closure), Array)
#49 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseFactory.php(169) : eval()'d code(17): P\Tests\Feature\CommerceFlowTest->__runTest(Object(Closure))
#50 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(1332): P\Tests\Feature\CommerceFlowTest->__pest_evaluable_guest_cart_and_card_checkout_create_a_paid_order()
#51 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(519): PHPUnit\Framework\TestCase->runTest()
#52 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php(99): PHPUnit\Framework\TestCase->runBare()
#53 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(359): PHPUnit\Framework\TestRunner->run(Object(P\Tests\Feature\CommerceFlowTest))
#54 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestSuite.php(374): PHPUnit\Framework\TestCase->run()
#55 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
#56 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/Application.php(229): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\DefaultResultCache), Object(PHPUnit\Framework\TestSuite))
#57 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Kernel.php(103): PHPUnit\TextUI\Application->run(Array)
#58 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(184): Pest\Kernel->handle(Array, Array)
#59 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(192): {closure:/Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest:18}()
#60 {main}

----------------------------------------------------------------------------------

Session store not set on request.

  at tests/Feature/CommerceFlowTest.php:36
     32▕
     33▕     $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', [
     34▕         'cart_id' => $cart['id'],
     35▕         'email' => 'flow@example.test',
  ➜  36▕     ])->assertCreated()->json();
     37▕
     38▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", [
     39▕         'shipping_address' => [
     40▕             'first_name' => 'Flow',

  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > declined payment…  ErrorException
  Undefined array key "id"

  at tests/Feature/CommerceFlowTest.php:74
     70▕
     71▕     $cart = $this->postJson('http://shop.test/api/storefront/v1/carts')->json();
     72▕     $this->postJson("http://shop.test/api/storefront/v1/carts/{$cart['id']}/lines", ['variant_id' => $variant->getKey(), 'quantity' => 1, 'cart_version' => 1]);
     73▕     $checkout = $this->postJson('http://shop.test/api/storefront/v1/checkouts', ['cart_id' => $cart['id'], 'email' => 'declined@example.test'])->json();
  ➜  74▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/address", ['shipping_address' => ['first_name' => 'Declined', 'last_name' => 'Tester', 'address1' => '1 Test Street', 'city' => 'Berlin', 'country_code' => 'DE', 'postal_code' => '10115']]);
     75▕     $rate = ShippingRate::query()->firstOrFail();
     76▕     $this->putJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/shipping-method", ['shipping_method_id' => $rate->getKey()]);
     77▕
     78▕     $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", ['payment_method' => 'credit_card', 'card_number' => '4000000000000002'])->assertUnprocessable();

  Tests:    2 failed, 1 passed (5 assertions)
  Duration: 0.22s


status: completed

input:
const patch = "*** Begin Patch\n*** Update File: /Users/wesner/Herd/shop/app/Providers/AppServiceProvider.php\n@@\n-        RateLimiter::for('checkout', fn (Request $request): Limit => Limit::perMinute(10)->by($request->session()->getId()));\n+        RateLimiter::for('checkout', fn (Request $request): Limit => Limit::perMinute(10)->by($request->hasSession() ? $request->session()->getId() : $request->ip()));\n*** End Patch";
text(await tools.apply_patch(patch));


type: update

unified_diff:
@@ -38,3 +38,3 @@
         RateLimiter::for('api.storefront', fn (Request $request): Limit => Limit::perMinute(120)->by($request->ip()));
-        RateLimiter::for('checkout', fn (Request $request): Limit => Limit::perMinute(10)->by($request->session()->getId()));
+        RateLimiter::for('checkout', fn (Request $request): Limit => Limit::perMinute(10)->by($request->hasSession() ? $request->session()->getId() : $request->ip()));
     }

stdout:
Success. Updated the following files:
M /Users/wesner/Herd/shop/app/Providers/AppServiceProvider.php


text:
Script completed
Wall time 0.0 seconds
Output:


status: completed

input: const r = await tools.exec_command({cmd:"php artisan test tests/Feature/CommerceFlowTest.php",workdir:"/Users/wesner/Herd/shop",yield_time_ms:30000,max_output_tokens:16000}); text(r.output);


cmd: php artisan test tests/Feature/CommerceFlowTest.php

stdout:
   FAIL  Tests\Feature\CommerceFlowTest
  ⨯ guest cart and card checkout create a paid order                     0.14s
  ✓ declined payments release the reservation and do not create an orde… 0.04s
  ✓ stale cart versions return a conflict response                       0.03s
  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > guest cart and card checkout cre…
  Expected response status code [200] but received 500.
Failed asserting that 500 is identical to 200.

The following exception occurred during the last request:

Illuminate\Database\Eloquent\RelationNotFoundException: Call to undefined relationship [inventory] on model [App\Models\Product]. in /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php:35
Stack trace:
#0 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(969): Illuminate\Database\Eloquent\RelationNotFoundException::make(Object(App\Models\Product), 'inventory')
#1 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(119): Illuminate\Database\Eloquent\Builder->{closure:Illuminate\Database\Eloquent\Builder::getRelation():965}()
#2 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(965): Illuminate\Database\Eloquent\Relations\Relation::noConstraints(Object(Closure))
#3 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(939): Illuminate\Database\Eloquent\Builder->getRelation('inventory')
#4 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'inventory', Object(Closure))
#5 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#6 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#7 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#8 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#9 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'product', Object(Closure))
#10 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#11 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#12 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#13 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#14 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'variant', Object(Closure))
#15 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#16 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#17 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#18 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#19 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'lines', Object(Closure))
#20 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#21 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#22 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#23 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#24 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'cart', Object(Closure))
#25 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(800): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#26 /Users/wesner/Herd/shop/app/Services/OrderService.php(24): Illuminate\Database\Eloquent\Model->load(Array)
#27 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(35): App\Services\OrderService->{closure:App\Services\OrderService::createFromCheckout():23}(Object(Illuminate\Database\SQLiteConnection))
#28 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(491): Illuminate\Database\Connection->transaction(Object(Closure))
#29 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(363): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#30 /Users/wesner/Herd/shop/app/Services/OrderService.php(23): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#31 /Users/wesner/Herd/shop/app/Services/PaymentService.php(42): App\Services\OrderService->createFromCheckout(Object(App\Models\Checkout), Object(App\ValueObjects\PaymentResult))
#32 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(35): App\Services\PaymentService->{closure:App\Services\PaymentService::pay():19}(Object(Illuminate\Database\SQLiteConnection))
#33 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(491): Illuminate\Database\Connection->transaction(Object(Closure))
#34 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(363): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#35 /Users/wesner/Herd/shop/app/Services/PaymentService.php(19): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#36 /Users/wesner/Herd/shop/app/Http/Controllers/Api/StorefrontCheckoutController.php(73): App\Services\PaymentService->pay(Object(App\Models\Checkout), App\Enums\PaymentMethod::CreditCard, Array)
#37 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): App\Http\Controllers\Api\StorefrontCheckoutController->pay(Object(Illuminate\Http\Request), 1)
#38 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(265): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Api\StorefrontCheckoutController), 'pay')
#39 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(211): Illuminate\Routing\Route->runController()
#40 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(822): Illuminate\Routing\Route->run()
#41 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Routing\Router->{closure:Illuminate\Routing\Router::runRouteWithinStack():821}(Object(Illuminate\Http\Request))
#42 /Users/wesner/Herd/shop/app/Http/Middleware/ResolveStore.php(48): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#43 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): App\Http\Middleware\ResolveStore->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#45 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#47 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#48 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'checkout', Object(Closure))
#49 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'checkout')
#50 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#51 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#52 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront', Object(Closure))
#53 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront')
#54 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#55 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(821): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#56 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#57 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#58 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#59 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#60 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Kernel->{closure:Illuminate\Foundation\Http\Kernel::dispatchToRouter():197}(Object(Illuminate\Http\Request))
#61 /Users/wesner/Herd/shop/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#62 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Livewire\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#63 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#64 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#65 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#66 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#67 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#68 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#69 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#70 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#71 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#72 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#73 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(74): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#74 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#75 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#76 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#77 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#78 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks->handle(Object(Illuminate\Http\Request), Object(Closure))
#79 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePathEncoding.php(26): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#80 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePathEncoding->handle(Object(Illuminate\Http\Request), Object(Closure))
#81 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#82 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#83 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#84 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(607): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#85 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(573): Illuminate\Foundation\Testing\TestCase->call('POST', 'http://shop.tes...', Array, Array, Array, Array, '{"payment_metho...')
#86 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(411): Illuminate\Foundation\Testing\TestCase->json('POST', 'http://shop.tes...', Array, Array, 0)
#87 /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php(54): Illuminate\Foundation\Testing\TestCase->postJson('http://shop.tes...', Array)
#88 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php(168): P\Tests\Feature\CommerceFlowTest->{closure:/Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php:20}()
#89 [internal function]: P\Tests\Feature\CommerceFlowTest->{closure:Pest\Factories\TestCaseMethodFactory::getClosure():158}()
#90 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): call_user_func_array(Object(Closure), Array)
#91 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Support/ExceptionTrace.php(26): P\Tests\Feature\CommerceFlowTest->{closure:Pest\Concerns\Testable::__callClosure():429}()
#92 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): Pest\Support\ExceptionTrace::ensure(Object(Closure))
#93 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(331): P\Tests\Feature\CommerceFlowTest->__callClosure(Object(Closure), Array)
#94 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseFactory.php(169) : eval()'d code(17): P\Tests\Feature\CommerceFlowTest->__runTest(Object(Closure))
#95 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(1332): P\Tests\Feature\CommerceFlowTest->__pest_evaluable_guest_cart_and_card_checkout_create_a_paid_order()
#96 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(519): PHPUnit\Framework\TestCase->runTest()
#97 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php(99): PHPUnit\Framework\TestCase->runBare()
#98 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(359): PHPUnit\Framework\TestRunner->run(Object(P\Tests\Feature\CommerceFlowTest))
#99 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestSuite.php(374): PHPUnit\Framework\TestCase->run()
#100 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
#101 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/Application.php(229): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\DefaultResultCache), Object(PHPUnit\Framework\TestSuite))
#102 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Kernel.php(103): PHPUnit\TextUI\Application->run(Array)
#103 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(184): Pest\Kernel->handle(Array, Array)
#104 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(192): {closure:/Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest:18}()
#105 {main}

----------------------------------------------------------------------------------

Call to undefined relationship [inventory] on model [App\Models\Product].

  at tests/Feature/CommerceFlowTest.php:57
     53▕
     54▕     $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", [
     55▕         'payment_method' => 'credit_card',
     56▕         'card_number' => '4242424242424242',
  ➜  57▕     ])->assertOk()->assertJsonPath('order.financial_status', 'paid');
     58▕
     59▕     $order = Order::query()->latest('id')->firstOrFail();
     60▕
     61▕     expect($order->payment_method)->toBe('credit_card')

  Tests:    1 failed, 2 passed (13 assertions)
  Duration: 0.23s


text:
Script completed
Wall time 0.4 seconds
Output:

text:
   FAIL  Tests\Feature\CommerceFlowTest
  ⨯ guest cart and card checkout create a paid order                     0.14s
  ✓ declined payments release the reservation and do not create an orde… 0.04s
  ✓ stale cart versions return a conflict response                       0.03s
  ────────────────────────────────────────────────────────────────────────────
   FAILED  Tests\Feature\CommerceFlowTest > guest cart and card checkout cre…
  Expected response status code [200] but received 500.
Failed asserting that 500 is identical to 200.

The following exception occurred during the last request:

Illuminate\Database\Eloquent\RelationNotFoundException: Call to undefined relationship [inventory] on model [App\Models\Product]. in /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php:35
Stack trace:
#0 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(969): Illuminate\Database\Eloquent\RelationNotFoundException::make(Object(App\Models\Product), 'inventory')
#1 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(119): Illuminate\Database\Eloquent\Builder->{closure:Illuminate\Database\Eloquent\Builder::getRelation():965}()
#2 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(965): Illuminate\Database\Eloquent\Relations\Relation::noConstraints(Object(Closure))
#3 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(939): Illuminate\Database\Eloquent\Builder->getRelation('inventory')
#4 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'inventory', Object(Closure))
#5 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#6 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#7 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#8 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#9 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'product', Object(Closure))
#10 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#11 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#12 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#13 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#14 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'variant', Object(Closure))
#15 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#16 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#17 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#18 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#19 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'lines', Object(Closure))
#20 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(885): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#21 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(212): Illuminate\Database\Eloquent\Builder->get(Array)
#22 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(175): Illuminate\Database\Eloquent\Relations\Relation->get()
#23 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(950): Illuminate\Database\Eloquent\Relations\Relation->getEager()
#24 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(919): Illuminate\Database\Eloquent\Builder->eagerLoadRelation(Array, 'cart', Object(Closure))
#25 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(800): Illuminate\Database\Eloquent\Builder->eagerLoadRelations(Array)
#26 /Users/wesner/Herd/shop/app/Services/OrderService.php(24): Illuminate\Database\Eloquent\Model->load(Array)
#27 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(35): App\Services\OrderService->{closure:App\Services\OrderService::createFromCheckout():23}(Object(Illuminate\Database\SQLiteConnection))
#28 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(491): Illuminate\Database\Connection->transaction(Object(Closure))
#29 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(363): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#30 /Users/wesner/Herd/shop/app/Services/OrderService.php(23): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#31 /Users/wesner/Herd/shop/app/Services/PaymentService.php(42): App\Services\OrderService->createFromCheckout(Object(App\Models\Checkout), Object(App\ValueObjects\PaymentResult))
#32 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(35): App\Services\PaymentService->{closure:App\Services\PaymentService::pay():19}(Object(Illuminate\Database\SQLiteConnection))
#33 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(491): Illuminate\Database\Connection->transaction(Object(Closure))
#34 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(363): Illuminate\Database\DatabaseManager->__call('transaction', Array)
#35 /Users/wesner/Herd/shop/app/Services/PaymentService.php(19): Illuminate\Support\Facades\Facade::__callStatic('transaction', Array)
#36 /Users/wesner/Herd/shop/app/Http/Controllers/Api/StorefrontCheckoutController.php(73): App\Services\PaymentService->pay(Object(App\Models\Checkout), App\Enums\PaymentMethod::CreditCard, Array)
#37 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): App\Http\Controllers\Api\StorefrontCheckoutController->pay(Object(Illuminate\Http\Request), 1)
#38 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(265): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Api\StorefrontCheckoutController), 'pay')
#39 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Route.php(211): Illuminate\Routing\Route->runController()
#40 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(822): Illuminate\Routing\Route->run()
#41 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Routing\Router->{closure:Illuminate\Routing\Router::runRouteWithinStack():821}(Object(Illuminate\Http\Request))
#42 /Users/wesner/Herd/shop/app/Http/Middleware/ResolveStore.php(48): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#43 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): App\Http\Middleware\ResolveStore->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#45 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#47 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#48 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'checkout', Object(Closure))
#49 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'checkout')
#50 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(166): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#51 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(129): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#52 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(90): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront', Object(Closure))
#53 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api.storefront')
#54 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#55 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(821): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#56 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#57 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#58 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#59 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#60 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Kernel->{closure:Illuminate\Foundation\Http\Kernel::dispatchToRouter():197}(Object(Illuminate\Http\Request))
#61 /Users/wesner/Herd/shop/vendor/livewire/livewire/src/Features/SupportDisablingBackButtonCache/DisableBackButtonCacheMiddleware.php(19): Illuminate\Pipeline\Pipeline->{closure:Illuminate\Pipeline\Pipeline::prepareDestination():178}(Object(Illuminate\Http\Request))
#62 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Livewire\Features\SupportDisablingBackButtonCache\DisableBackButtonCacheMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#63 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#64 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#65 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#66 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#67 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#68 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#69 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#70 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#71 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#72 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#73 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(74): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#74 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#75 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#76 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#77 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#78 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks->handle(Object(Illuminate\Http\Request), Object(Closure))
#79 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePathEncoding.php(26): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#80 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\Http\Middleware\ValidatePathEncoding->handle(Object(Illuminate\Http\Request), Object(Closure))
#81 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Pipeline\Pipeline->{closure:{closure:Illuminate\Pipeline\Pipeline::carry():194}:195}(Object(Illuminate\Http\Request))
#82 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#83 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#84 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(607): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#85 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(573): Illuminate\Foundation\Testing\TestCase->call('POST', 'http://shop.tes...', Array, Array, Array, Array, '{"payment_metho...')
#86 /Users/wesner/Herd/shop/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php(411): Illuminate\Foundation\Testing\TestCase->json('POST', 'http://shop.tes...', Array, Array, 0)
#87 /Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php(54): Illuminate\Foundation\Testing\TestCase->postJson('http://shop.tes...', Array)
#88 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php(168): P\Tests\Feature\CommerceFlowTest->{closure:/Users/wesner/Herd/shop/tests/Feature/CommerceFlowTest.php:20}()
#89 [internal function]: P\Tests\Feature\CommerceFlowTest->{closure:Pest\Factories\TestCaseMethodFactory::getClosure():158}()
#90 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): call_user_func_array(Object(Closure), Array)
#91 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Support/ExceptionTrace.php(26): P\Tests\Feature\CommerceFlowTest->{closure:Pest\Concerns\Testable::__callClosure():429}()
#92 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(429): Pest\Support\ExceptionTrace::ensure(Object(Closure))
#93 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Concerns/Testable.php(331): P\Tests\Feature\CommerceFlowTest->__callClosure(Object(Closure), Array)
#94 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Factories/TestCaseFactory.php(169) : eval()'d code(17): P\Tests\Feature\CommerceFlowTest->__runTest(Object(Closure))
#95 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(1332): P\Tests\Feature\CommerceFlowTest->__pest_evaluable_guest_cart_and_card_checkout_create_a_paid_order()
#96 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(519): PHPUnit\Framework\TestCase->runTest()
#97 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php(99): PHPUnit\Framework\TestCase->runBare()
#98 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestCase.php(359): PHPUnit\Framework\TestRunner->run(Object(P\Tests\Feature\CommerceFlowTest))
#99 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/Framework/TestSuite.php(374): PHPUnit\Framework\TestCase->run()
#100 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(64): PHPUnit\Framework\TestSuite->run()
#101 /Users/wesner/Herd/shop/vendor/phpunit/phpunit/src/TextUI/Application.php(229): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\TextUI\Configuration\Configuration), Object(PHPUnit\Runner\ResultCache\DefaultResultCache), Object(PHPUnit\Framework\TestSuite))
#102 /Users/wesner/Herd/shop/vendor/pestphp/pest/src/Kernel.php(103): PHPUnit\TextUI\Application->run(Array)
#103 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(184): Pest\Kernel->handle(Array, Array)
#104 /Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest(192): {closure:/Users/wesner/Herd/shop/vendor/pestphp/pest/bin/pest:18}()
#105 {main}

----------------------------------------------------------------------------------

Call to undefined relationship [inventory] on model [App\Models\Product].

  at tests/Feature/CommerceFlowTest.php:57
     53▕
     54▕     $this->postJson("http://shop.test/api/storefront/v1/checkouts/{$checkout['id']}/pay", [
     55▕         'payment_method' => 'credit_card',
     56▕         'card_number' => '4242424242424242',
  ➜  57▕     ])->assertOk()->assertJsonPath('order.financial_status', 'paid');
     58▕
     59▕     $order = Order::query()->latest('id')->firstOrFail();
     60▕
     61▕     expect($order->payment_method)->toBe('credit_card')

  Tests:    1 failed, 2 passed (13 assertions)
  Duration: 0.23s


status: completed

input: const r = await tools.exec_command({cmd:"rg -n \"product\\.inventory|variants\\.inventory|with\\(.*inventory\" app | head -100",workdir:"/Users/wesner/Herd/shop",yield_time_ms:10000,max_output_tokens:4000}); text(r.output);


command: rg -n "product\.inventory|variants\.inventory|with\(.*inventory" app | head -100

type: search

cmd: rg -n "product\\.inventory|variants\\.inventory|with\\(.*inventory" app

query: product\.inventory|variants\.inventory|with\(.*inventory

path: app

stdout:
app/Services/CartService.php:32:            $variant = ProductVariant::with(['product', 'inventory'])->findOrFail($variantId);
app/Services/CartService.php:66:            $line = $cart->lines()->with(['variant.inventory'])->findOrFail($lineId);
app/Services/OrderService.php:24:            $checkout->load(['cart.lines.variant.product.inventory', 'shippingRate']);
app/Http/Controllers/Api/StorefrontCartController.php:80:        return Cart::query()->with(['lines.variant.product.media', 'lines.variant.inventory'])->findOrFail($cartId);
app/Livewire/Admin/Products/Index.php:28:        $products = Product::query()->with(['variants.inventory'])->when($this->search !== '', fn ($query) => $query->where('title', 'like', '%'.$this->search.'%'))->when($this->status !== 'all', fn ($query) => $query->where('status', $this->status))->latest()->paginate(15);
app/Livewire/Storefront/Collections/Show.php:18:        $this->collection = ProductCollection::query()->where('handle', $handle)->with(['products.variants.inventory', 'products.media'])->firstOrFail();
app/Livewire/Storefront/Home.php:25:        return view('livewire.storefront.home', ['collections' => Collection::query()->where('status', 'active')->withCount('products')->latest()->take(4)->get(), 'products' => Product::query()->published()->with(['variants.inventory', 'media'])->latest('published_at')->take(8)->get()])->layout('layouts.storefront');
app/Livewire/Storefront/Products/Show.php:21:        $this->product = Product::query()->with(['variants.inventory', 'media', 'options.values'])->where('handle', $handle)->firstOrFail();
app/Livewire/Storefront/Search/Index.php:19:        $products = Product::query()->published()->with(['variants.inventory', 'media'])->when($this->query !== '', fn ($query) => $query->where(fn ($nested) => $nested->where('title', 'like', '%'.$this->query.'%')->orWhere('description', 'like', '%'.$this->query.'%')->orWhere('vendor', 'like', '%'.$this->query.'%')))->latest()->paginate(12);
app/Models/CartLine.php:19:        return $this->belongsTo(ProductVariant::class, 'variant_id')->with(['product', 'inventory']);


text:
Script completed
Wall time 0.1 seconds
Output:

text:
app/Services/CartService.php:32:            $variant = ProductVariant::with(['product', 'inventory'])->findOrFail($variantId);
app/Services/CartService.php:66:            $line = $cart->lines()->with(['variant.inventory'])->findOrFail($lineId);
app/Services/OrderService.php:24:            $checkout->load(['cart.lines.variant.product.inventory', 'shippingRate']);
app/Http/Controllers/Api/StorefrontCartController.php:80:        return Cart::query()->with(['lines.variant.product.media', 'lines.variant.inventory'])->findOrFail($cartId);
app/Livewire/Admin/Products/Index.php:28:        $products = Product::query()->with(['variants.inventory'])->when($this->search !== '', fn ($query) => $query->where('title', 'like', '%'.$this->search.'%'))->when($this->status !== 'all', fn ($query) => $query->where('status', $this->status))->latest()->paginate(15);
app/Livewire/Storefront/Collections/Show.php:18:        $this->collection = ProductCollection::query()->where('handle', $handle)->with(['products.variants.inventory', 'products.media'])->firstOrFail();
app/Livewire/Storefront/Home.php:25:        return view('livewire.storefront.home', ['collections' => Collection::query()->where('status', 'active')->withCount('products')->latest()->take(4)->get(), 'products' => Product::query()->published()->with(['variants.inventory', 'media'])->latest('published_at')->take(8)->get()])->layout('layouts.storefront');
app/Livewire/Storefront/Products/Show.php:21:        $this->product = Product::query()->with(['variants.inventory', 'media', 'options.values'])->where('handle', $handle)->firstOrFail();
app/Livewire/Storefront/Search/Index.php:19:        $products = Product::query()->published()->with(['variants.inventory', 'media'])->when($this->query !== '', fn ($query) => $query->where(fn ($nested) => $nested->where('title', 'like', '%'.$this->query.'%')->orWhere('description', 'like', '%'.$this->query.'%')->orWhere('vendor', 'like', '%'.$this->query.'%')))->latest()->paginate(12);
app/Models/CartLine.php:19:        return $this->belongsTo(ProductVariant::class, 'variant_id')->with(['product', 'inventory']);


status: completed

input:
const patch = "*** Begin Patch\n*** Update File: /Users/wesner/Herd/shop/app/Services/OrderService.php\n@@\n-            $checkout->load(['cart.lines.variant.product.inventory', 'shippingRate']);\n+            $checkout->load(['cart.lines.variant.product', 'cart.lines.variant.inventory', 'shippingRate']);\n*** End Patch";
text(await tools.apply_patch(patch));


unified_diff:
@@ -23,3 +23,3 @@
         return DB::transaction(function () use ($checkout, $paymentResult): Order {
-            $checkout->load(['cart.lines.variant.product.inventory', 'shippingRate']);
+            $checkout->load(['cart.lines.variant.product', 'cart.lines.variant.inventory', 'shippingRate']);
             $existing = Order::withoutGlobalScopes()->where('checkout_id', $checkout->getKey())->first();

stdout:
Success. Updated the following files:
M /Users/wesner/Herd/shop/app/Services/OrderService.php


text:
Script completed
Wall time 0.0 seconds
Output:


status: completed

input: const r = await tools.exec_command({cmd:"php artisan test tests/Feature/CommerceFlowTest.php",workdir:"/Users/wesner/Herd/shop",yield_time_ms:30000,max_output_tokens:12000}); text(r.output);


stdout:
   PASS  Tests\Feature\CommerceFlowTest
  ✓ guest cart and card checkout create a paid order                     0.14s
  ✓ declined payments release the reservation and do not create an orde… 0.04s
  ✓ stale cart versions return a conflict response                       0.03s

  Tests:    3 passed (18 assertions)
  Duration: 0.23s


text:
Script completed
Wall time 0.4 seconds
Output:

text:
   PASS  Tests\Feature\CommerceFlowTest
  ✓ guest cart and card checkout create a paid order                     0.14s
  ✓ declined payments release the reservation and do not create an orde… 0.04s
  ✓ stale cart versions return a conflict response                       0.03s

  Tests:    3 passed (18 assertions)
  Duration: 0.23s


status: completed

input: const r = await tools.exec_command({cmd:"find app -maxdepth 3 -type f | sort; find routes database/migrations -maxdepth 2 -type f | sort | tail -100",workdir:"/Users/wesner/Herd/shop",yield_time_ms:10000,max_output_tokens:12000}); text(r.output);


command: find app -maxdepth 3 -type f | sort; find routes database/migrations -maxdepth 2 -type f | sort | tail -100

cmd: find app -maxdepth 3 -type f

path: app

path: routes

stdout:
app/Actions/Fortify/CreateNewUser.php
app/Actions/Fortify/ResetUserPassword.php
app/Auth/CustomerUserProvider.php
app/Concerns/PasswordValidationRules.php
app/Concerns/ProfileValidationRules.php
app/Contracts/PaymentProvider.php
app/Enums/CartStatus.php
app/Enums/CheckoutStatus.php
app/Enums/CollectionStatus.php
app/Enums/DiscountType.php
app/Enums/DiscountValueType.php
app/Enums/FinancialStatus.php
app/Enums/FulfillmentStatus.php
app/Enums/InventoryPolicy.php
app/Enums/OrderStatus.php
app/Enums/PageStatus.php
app/Enums/PaymentMethod.php
app/Enums/PaymentStatus.php
app/Enums/ProductStatus.php
app/Enums/StoreDomainType.php
app/Enums/StoreStatus.php
app/Enums/StoreUserRole.php
app/Enums/ThemeStatus.php
app/Events/FulfillmentDelivered.php
app/Events/OrderCancelled.php
app/Events/OrderCreated.php
app/Events/OrderFulfilled.php
app/Events/OrderPaid.php
app/Events/OrderRefunded.php
app/Exceptions/CartVersionConflictException.php
app/Exceptions/FulfillmentGuardException.php
app/Exceptions/InsufficientInventoryException.php
app/Exceptions/InvalidDiscountException.php
app/Http/Controllers/Controller.php
app/Http/Middleware/EnsureStoreRole.php
app/Http/Middleware/ResolveStore.php
app/Livewire/Actions/Logout.php
app/Livewire/Admin/Dashboard.php
app/Livewire/Admin/Section.php
app/Livewire/Settings/Appearance.php
app/Livewire/Settings/DeleteUserForm.php
app/Livewire/Settings/Password.php
app/Livewire/Settings/Profile.php
app/Livewire/Settings/TwoFactor.php
app/Livewire/Storefront/Home.php
app/Models/AnalyticsDaily.php
app/Models/AnalyticsEvent.php
app/Models/App.php
app/Models/AppInstallation.php
app/Models/Cart.php
app/Models/CartLine.php
app/Models/Checkout.php
app/Models/Collection.php
app/Models/Concerns/BelongsToStore.php
app/Models/Customer.php
app/Models/CustomerAddress.php
app/Models/Discount.php
app/Models/Fulfillment.php
app/Models/FulfillmentLine.php
app/Models/InventoryItem.php
app/Models/NavigationItem.php
app/Models/NavigationMenu.php
app/Models/Order.php
app/Models/OrderLine.php
app/Models/Organization.php
app/Models/Page.php
app/Models/Payment.php
app/Models/Product.php
app/Models/ProductMedia.php
app/Models/ProductOption.php
app/Models/ProductOptionValue.php
app/Models/ProductVariant.php
app/Models/Refund.php
app/Models/Scopes/StoreScope.php
app/Models/SearchQuery.php
app/Models/SearchSetting.php
app/Models/ShippingRate.php
app/Models/ShippingZone.php
app/Models/Store.php
app/Models/StoreDomain.php
app/Models/StoreSettings.php
app/Models/StoreUser.php
app/Models/TaxSettings.php
app/Models/Theme.php
app/Models/ThemeFile.php
app/Models/ThemeSetting.php
app/Models/User.php
app/Models/WebhookDelivery.php
app/Models/WebhookSubscription.php
app/Policies/CollectionPolicy.php
app/Policies/CustomerPolicy.php
app/Policies/DiscountPolicy.php
app/Policies/FulfillmentPolicy.php
app/Policies/OrderPolicy.php
app/Policies/PagePolicy.php
app/Policies/ProductPolicy.php
app/Policies/RefundPolicy.php
app/Policies/StorePolicy.php
app/Policies/ThemePolicy.php
app/Providers/AppServiceProvider.php
app/Providers/FortifyServiceProvider.php
app/Services/CartService.php
app/Services/CheckoutService.php
app/Services/DiscountService.php
app/Services/FulfillmentService.php
app/Services/InventoryService.php
app/Services/MockPaymentProvider.php
app/Services/OrderService.php
app/Services/PaymentProvider.php
app/Services/PaymentService.php
app/Services/PricingEngine.php
app/Services/ProductService.php
app/Services/RefundService.php
app/Services/ShippingCalculator.php
app/Services/TaxCalculator.php
app/Support/HandleGenerator.php
app/Traits/ChecksStoreRole.php
app/ValueObjects/DiscountResult.php
app/ValueObjects/PaymentResult.php
app/ValueObjects/PricingResult.php
app/ValueObjects/RefundResult.php
app/ValueObjects/TaxLine.php
app/ValueObjects/TaxResult.php
database/migrations/0001_01_01_000000_create_users_table.php
database/migrations/0001_01_01_000001_create_cache_table.php
database/migrations/0001_01_01_000002_create_jobs_table.php
database/migrations/2025_08_14_170933_add_two_factor_columns_to_users_table.php
database/migrations/2026_08_20_000000_create_shop_schema.php
database/migrations/2026_08_20_210057_add_enum_defaults_to_tenancy_tables.php
database/migrations/2026_08_20_210057_add_settings_json_to_store_settings_table.php
database/migrations/2026_08_20_210057_add_tls_mode_to_store_domains_table.php
routes/api.php
routes/console.php
routes/settings.php
routes/web.php


text:
Script completed
Wall time 0.1 seconds
Output:

text:
app/Actions/Fortify/CreateNewUser.php
app/Actions/Fortify/ResetUserPassword.php
app/Auth/CustomerUserProvider.php
app/Concerns/PasswordValidationRules.php
app/Concerns/ProfileValidationRules.php
app/Contracts/PaymentProvider.php
app/Enums/CartStatus.php
app/Enums/CheckoutStatus.php
app/Enums/CollectionStatus.php
app/Enums/DiscountType.php
app/Enums/DiscountValueType.php
app/Enums/FinancialStatus.php
app/Enums/FulfillmentStatus.php
app/Enums/InventoryPolicy.php
app/Enums/OrderStatus.php
app/Enums/PageStatus.php
app/Enums/PaymentMethod.php
app/Enums/PaymentStatus.php
app/Enums/ProductStatus.php
app/Enums/StoreDomainType.php
app/Enums/StoreStatus.php
app/Enums/StoreUserRole.php
app/Enums/ThemeStatus.php
app/Events/FulfillmentDelivered.php
app/Events/OrderCancelled.php
app/Events/OrderCreated.php
app/Events/OrderFulfilled.php
app/Events/OrderPaid.php
app/Events/OrderRefunded.php
app/Exceptions/CartVersionConflictException.php
app/Exceptions/FulfillmentGuardException.php
app/Exceptions/InsufficientInventoryException.php
app/Exceptions/InvalidDiscountException.php
app/Http/Controllers/Controller.php
app/Http/Middleware/EnsureStoreRole.php
app/Http/Middleware/ResolveStore.php
app/Livewire/Actions/Logout.php
app/Livewire/Admin/Dashboard.php
app/Livewire/Admin/Section.php
app/Livewire/Settings/Appearance.php
app/Livewire/Settings/DeleteUserForm.php
app/Livewire/Settings/Password.php
app/Livewire/Settings/Profile.php
app/Livewire/Settings/TwoFactor.php
app/Livewire/Storefront/Home.php
app/Models/AnalyticsDaily.php
app/Models/AnalyticsEvent.php
app/Models/App.php
app/Models/AppInstallation.php
app/Models/Cart.php
app/Models/CartLine.php
app/Models/Checkout.php
app/Models/Collection.php
app/Models/Concerns/BelongsToStore.php
app/Models/Customer.php
app/Models/CustomerAddress.php
app/Models/Discount.php
app/Models/Fulfillment.php
app/Models/FulfillmentLine.php
app/Models/InventoryItem.php
app/Models/NavigationItem.php
app/Models/NavigationMenu.php
app/Models/Order.php
app/Models/OrderLine.php
app/Models/Organization.php
app/Models/Page.php
app/Models/Payment.php
app/Models/Product.php
app/Models/ProductMedia.php
app/Models/ProductOption.php
app/Models/ProductOptionValue.php
app/Models/ProductVariant.php
app/Models/Refund.php
app/Models/Scopes/StoreScope.php
app/Models/SearchQuery.php
app/Models/SearchSetting.php
app/Models/ShippingRate.php
app/Models/ShippingZone.php
app/Models/Store.php
app/Models/StoreDomain.php
app/Models/StoreSettings.php
app/Models/StoreUser.php
app/Models/TaxSettings.php
app/Models/Theme.php
app/Models/ThemeFile.php
app/Models/ThemeSetting.php
app/Models/User.php
app/Models/WebhookDelivery.php
app/Models/WebhookSubscription.php
app/Policies/CollectionPolicy.php
app/Policies/CustomerPolicy.php
app/Policies/DiscountPolicy.php
app/Policies/FulfillmentPolicy.php
app/Policies/OrderPolicy.php
app/Policies/PagePolicy.php
app/Policies/ProductPolicy.php
app/Policies/RefundPolicy.php
app/Policies/StorePolicy.php
app/Policies/ThemePolicy.php
app/Providers/AppServiceProvider.php
app/Providers/FortifyServiceProvider.php
app/Services/CartService.php
app/Services/CheckoutService.php
app/Services/DiscountService.php
app/Services/FulfillmentService.php
app/Services/InventoryService.php
app/Services/MockPaymentProvider.php
app/Services/OrderService.php
app/Services/PaymentProvider.php
app/Services/PaymentService.php
app/Services/PricingEngine.php
app/Services/ProductService.php
app/Services/RefundService.php
app/Services/ShippingCalculator.php
app/Services/TaxCalculator.php
app/Support/HandleGenerator.php
app/Traits/ChecksStoreRole.php
app/ValueObjects/DiscountResult.php
app/ValueObjects/PaymentResult.php
app/ValueObjects/PricingResult.php
app/ValueObjects/RefundResult.php
app/ValueObjects/TaxLine.php
app/ValueObjects/TaxResult.php
database/migrations/0001_01_01_000000_create_users_table.php
database/migrations/0001_01_01_000001_create_cache_table.php
database/migrations/0001_01_01_000002_create_jobs_table.php
database/migrations/2025_08_14_170933_add_two_factor_columns_to_users_table.php
database/migrations/2026_08_20_000000_create_shop_schema.php
database/migrations/2026_08_20_210057_add_enum_defaults_to_tenancy_tables.php
database/migrations/2026_08_20_210057_add_settings_json_to_store_settings_table.php
database/migrations/2026_08_20_210057_add_tls_mode_to_store_domains_table.php
routes/api.php
routes/console.php
routes/settings.php
routes/web.php


status: completed

input: const r = await tools.exec_command({cmd:"rg -n \"Schema::create|Schema::create|Schema::table\" database/migrations/2026_08_20_000000_create_shop_schema.php",workdir:"/Users/wesner/Herd/shop",yield_time_ms:10000,max_output_tokens:7000}); text(r.output);