feat(catalog): expose product unavailability messages
This commit is contained in:
43
tests/Unit/Catalog/CatalogItemAllowanceServiceTest.php
Normal file
43
tests/Unit/Catalog/CatalogItemAllowanceServiceTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Catalog;
|
||||
|
||||
use App\Domains\Catalog\Services\CatalogItemAllowanceService;
|
||||
use ReflectionClass;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CatalogItemAllowanceServiceTest extends TestCase
|
||||
{
|
||||
private CatalogItemAllowanceService $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->service = (new ReflectionClass(CatalogItemAllowanceService::class))
|
||||
->newInstanceWithoutConstructor();
|
||||
}
|
||||
|
||||
public function test_it_returns_the_user_quota_message_with_priority_over_stock(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'Alcanzaste el cupo máximo permitido para este producto.',
|
||||
$this->service->unavailableMessage(0, 0),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_returns_the_out_of_stock_message(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'Este producto no tiene stock disponible.',
|
||||
$this->service->unavailableMessage(0, null),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_returns_no_message_when_the_item_is_available(): void
|
||||
{
|
||||
$this->assertNull($this->service->unavailableMessage(1, null));
|
||||
$this->assertNull($this->service->unavailableMessage(null, 1));
|
||||
$this->assertNull($this->service->unavailableMessage(null, null));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user