61 lines
2 KiB
PHP
61 lines
2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\Entities;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Domain\Enums\SellUnit;
|
|
use Domain\Enums\TaxRate;
|
|
use Domain\Enums\Units\InvoicingUnit;
|
|
use Domain\Models\Entities\Product;
|
|
use Domain\Models\ValueObjects\DiscountValue;
|
|
use Domain\Models\ValueObjects\Entities\ProductId;
|
|
use Domain\Models\ValueObjects\ProductWeight;
|
|
use Money\Money;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
describe('Product', function (): void {
|
|
it('can instantiate correctly', function (): void {
|
|
// GIVEN
|
|
$id = new ProductId(Uuid::uuid7());
|
|
$price = Money::EUR(1000);
|
|
$taxRate = TaxRate::TVA_5_5;
|
|
$weight = new ProductWeight(500, false);
|
|
$invoicingUnit = InvoicingUnit::KGM;
|
|
$sellUnit = SellUnit::KGM;
|
|
$discount = DiscountValue::fromPercentage(10);
|
|
$status = true;
|
|
$orderableStart = CarbonImmutable::now()->subDay();
|
|
$orderableEnd = CarbonImmutable::now()->addDay();
|
|
$hasInco = true;
|
|
|
|
// WHEN
|
|
$entity = new Product(
|
|
$id,
|
|
$price,
|
|
$taxRate,
|
|
$weight,
|
|
$invoicingUnit,
|
|
$sellUnit,
|
|
$discount,
|
|
$status,
|
|
$orderableStart,
|
|
$orderableEnd,
|
|
$hasInco
|
|
);
|
|
|
|
// THEN
|
|
expect($entity->id())->toBe($id)
|
|
->and($entity->price)->toBe($price)
|
|
->and($entity->tax_rate)->toBe($taxRate)
|
|
->and($entity->product_weight)->toBe($weight)
|
|
->and($entity->invoicing_unit)->toBe($invoicingUnit)
|
|
->and($entity->sell_unit)->toBe($sellUnit)
|
|
->and($entity->validDiscount)->toBe($discount)
|
|
->and($entity->status)->toBe($status)
|
|
->and($entity->orderable_start)->toBe($orderableStart)
|
|
->and($entity->orderable_end)->toBe($orderableEnd)
|
|
->and($entity->hasInco)->toBe($hasInco);
|
|
});
|
|
});
|