Skip to content

Commit

Permalink
Change product public error key
Browse files Browse the repository at this point in the history
  • Loading branch information
Witold Wiśniewski committed Oct 3, 2023
1 parent 5529d64 commit fc353af
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Enums/ValidationError.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class ValidationError extends Enum
public const EVENTEXIST = 'VALIDATION_EVENT_EXISTS';
public const OPTIONAVAILABLE = 'VALIDATION_OPTION_AVAILABLE';
public const PRODUCTATTRIBUTEOPTIONS = 'VALIDATION_PRODUCT_ATTRIBUTE_OPTIONS';
public const PRODUCTPUBLIC = 'VALIDATION_PRODUCT_PUBLIC';
public const PRODUCTPUBLIC = 'VALIDATION_PRODUCT_EXISTS';
public const PROHIBITEDUNLESS = 'VALIDATION_PROHIBITED_UNLESS';
public const PROHIBITEDWITH = 'VALIDATION_PROHIBITED_WITH';
public const REQUIREDCONSENTS = 'VALIDATION_REQUIRED_CONSENTS';
Expand Down
29 changes: 29 additions & 0 deletions tests/Feature/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Enums\DiscountType;
use App\Enums\RoleType;
use App\Enums\ShippingType;
use App\Enums\ValidationError;
use App\Models\ConditionGroup;
use App\Models\Deposit;
use App\Models\Discount;
Expand Down Expand Up @@ -440,6 +441,34 @@ public function testCartProcessProductDoesntExist($user): void
->assertUnprocessable();
}

/**
* @dataProvider authProvider
*/
public function testCartProcessProductNotPublic(string $user): void
{
$this->{$user}->givePermissionTo('cart.verify');

$product = Product::factory()->create([
'public' => false,
]);

$this->actingAs($this->{$user})->postJson('/cart/process', [
'shipping_method_id' => $this->shippingMethod->getKey(),
'items' => [
[
'cartitem_id' => '1',
'product_id' => $product->getKey(),
'quantity' => 1,
'schemas' => [],
],
],
])
->assertUnprocessable()
->assertJsonFragment([
'key' => ValidationError::PRODUCTPUBLIC,
]);
}

/**
* @dataProvider authProvider
*/
Expand Down

0 comments on commit fc353af

Please sign in to comment.