Skip to content

Commit

Permalink
Merge branch 'feature/HES-2128' into 'develop'
Browse files Browse the repository at this point in the history
Change unlimited shipping errors keys

Closes HES-2128

See merge request heseya/core!418
  • Loading branch information
bjuraszewski committed Oct 4, 2023
2 parents 6974c83 + 8a64973 commit 9eecf44
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Enums/ValidationError.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ final class ValidationError extends Enum
public const MEDIASLUG = 'VALIDATION_MEDIA_SLUG';
public const PHONE = 'VALIDATION_PHONE';
public const AUTHPROVIDERACTIVE = 'VALIDATION_AUTH_PROVIDER_ACTIVE';
public const UNLIMITEDSHIPPINGTIME = 'VALIDATION_UNLIMITED_SHIPPING_TIME';
public const UNLIMITEDSHIPPINGDATE = 'VALIDATION_UNLIMITED_SHIPPING_DATE';
}
65 changes: 65 additions & 0 deletions tests/Feature/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Tests\Feature;

use App\Enums\ErrorCode;
use App\Enums\ValidationError;
use App\Events\ItemCreated;
use App\Events\ItemDeleted;
use App\Events\ItemUpdated;
Expand Down Expand Up @@ -726,6 +727,70 @@ public function testUpdateWithPartialDataSku($user): void
Event::assertDispatched(ItemUpdated::class);
}

/**
* @dataProvider authProvider
*/
public function testUpdateWithInvalidUnlimitedDate($user): void
{
$this->{$user}->givePermissionTo('items.edit');

$this->item->update([
'shipping_date' => now(),
]);

Deposit::factory()->create([
'quantity' => 20,
'from_unlimited' => false,
'shipping_date' => now(),
'item_id' => $this->item->getKey(),
]);

$item = [
'unlimited_stock_shipping_date' => now()->subDay(),
];

$this->actingAs($this->{$user})->patchJson(
'/items/id:' . $this->item->getKey(),
$item,
)
->assertUnprocessable()
->assertJsonFragment([
'key' => ValidationError::UNLIMITEDSHIPPINGDATE,
]);
}

/**
* @dataProvider authProvider
*/
public function testUpdateWithInvalidUnlimitedTime($user): void
{
$this->{$user}->givePermissionTo('items.edit');

$this->item->update([
'shipping_time' => 4,
]);

Deposit::factory()->create([
'quantity' => 20,
'from_unlimited' => false,
'shipping_time' => 4,
'item_id' => $this->item->getKey(),
]);

$item = [
'unlimited_stock_shipping_time' => 2,
];

$this->actingAs($this->{$user})->patchJson(
'/items/id:' . $this->item->getKey(),
$item,
)
->assertUnprocessable()
->assertJsonFragment([
'key' => ValidationError::UNLIMITEDSHIPPINGTIME,
]);
}

/**
* @dataProvider authProvider
*/
Expand Down

0 comments on commit 9eecf44

Please sign in to comment.