xylar
xylar

Reputation: 7673

Laravel Dusk - Curl error (code 3): <url> malformed

I have the following form in a view:

{{ Form::open(['url' => route('orders.store')]) }}
{{ Form::hidden('customer_id', $customer->id) }}
{{ Form::hidden('address_1', $customer->address_1) }}
{{ Form::hidden('address_2', $customer->address_2) }}
{{ Form::hidden('address_3', $customer->address_3) }}
{{ Form::hidden('address_4', $customer->address_4) }}
{{ Form::hidden('postcode', $customer->postcode) }}
{{ Form::submit('Create Order') }}
{{ Form::close() }}

If I press the button Create Order myself it's working. However when I try to test via Dusk it fails with "Curl error (code 3): malformed". My dusk test code is:

$this->browse(function (Browser $browser) {
    $browser->on(new LoginPage)
        ->visit('/order')
        ->press('Create Order')
        ->assertSee('Order created');
});

I am testing a number of other forms and they all work. The only difference is that this one all the inputs are hidden. Is there a way to output what the url is that is being reported as malformed?

Update:

It seems to be failing within the store method - I added dd($order) just before the redirect and the Order was present but then it fails on redirect?

public function store(OrderStoreRequest $request)
{
    $data = $request->validated();
    $order = Order::create($data);
    return redirect()->route('orders.show', $order)
        ->with('success', 'Order created');
}

So I believe that the issue must be within the show method.

Upvotes: 1

Views: 641

Answers (1)

xylar
xylar

Reputation: 7673

The problem was related to missing database column and it was trying to log the error to Slack. However I had no defined the Slack Webhook URL in the dusk env file. To fix the issue I just set the following in the .env file:

LOG_CHANNEL=single

Upvotes: 2

Related Questions