49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
use Domain\Models\ValueObjects\CrmHashcode;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
covers(CrmHashcode::class);
|
|
|
|
describe('crm hashcode', function (): void {
|
|
$value = Uuid::uuid4();
|
|
|
|
it('creates a valid hashcode', function () use ($value): void {
|
|
// GIVEN / WHEN
|
|
$hashcode = new CrmHashcode($value);
|
|
|
|
// THEN
|
|
expect($hashcode->value)->toBe($value);
|
|
});
|
|
|
|
it('is equal to a hashcode with the same value', function () use ($value): void {
|
|
// GIVEN
|
|
$hashcode = new CrmHashcode($value);
|
|
$other = new CrmHashcode($value);
|
|
|
|
// WHEN / THEN
|
|
expect($hashcode->equals($other))->toBeTrue();
|
|
});
|
|
|
|
it('is not equal to a hashcode with a different value', function () use ($value): void {
|
|
// GIVEN
|
|
$hashcode = new CrmHashcode($value);
|
|
$other = new CrmHashcode(Uuid::uuid4());
|
|
|
|
// WHEN / THEN
|
|
expect($hashcode->equals($other))->toBeFalse();
|
|
});
|
|
|
|
it('is not equal to a value that is not a hashcode', function () use ($value): void {
|
|
// GIVEN
|
|
$hashcode = new CrmHashcode($value);
|
|
|
|
// WHEN / THEN
|
|
expect($hashcode->equals($value))->toBeFalse()
|
|
->and($hashcode->equals(null))->toBeFalse();
|
|
});
|
|
});
|