Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Http/Requests/Cart/UpdateCartRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ private function extraRules()
'customer.name' => ['nullable', 'string'],
'customer.first_name' => ['nullable', 'string'],
'customer.last_name' => ['nullable', 'string'],
'customer.email' => ['nullable', 'email'],
'customer.email' => ['nullable', 'email:filter'],
'name' => ['nullable', 'string'],
'first_name' => ['nullable', 'string'],
'last_name' => ['nullable', 'string'],
'email' => ['nullable', 'email'],
'email' => ['nullable', 'email:filter'],
'discount_code' => ['nullable', 'string', new ValidDiscountCode],
'shipping_method' => ['nullable', 'string'],
'shipping_option' => ['nullable', 'string'],
Expand Down
16 changes: 16 additions & 0 deletions tests/Cart/CartControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,22 @@ public function it_cant_add_invalid_discount_code()
$this->assertNull($cart->fresh()->get('discount_code'));
}

#[Test]
public function it_throws_validation_error_when_customer_email_is_invalid()
{
$cart = $this->makeCart();
$cart->customer(null)->save();

$this
->from('/cart')
->patch('/!/cargo/cart', [
'customer' => ['email' => 'name@domain'],
])
->assertSessionHasErrors('customer.email');

$this->assertNull($cart->fresh()->customer());
}

#[Test]
public function it_deletes_the_cart()
{
Expand Down