74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Tests\Unit\Presentation\Console\Presenters\Clients;
|
||
|
|
|
||
|
|
use Application\Security\Models\ValueObjects\ClientIdentifier;
|
||
|
|
use Application\Security\Models\ValueObjects\ClientName;
|
||
|
|
use Application\Security\Models\ValueObjects\Entities\ClientId;
|
||
|
|
use Application\Security\Usecases\ToggleClientStatus\Output;
|
||
|
|
use Presentation\Console\Presenters\Clients\SetClientStatusPresenter;
|
||
|
|
use Presentation\Console\Presenters\Clients\ToggleClientStatusView;
|
||
|
|
use Ramsey\Uuid\Uuid;
|
||
|
|
|
||
|
|
covers(
|
||
|
|
SetClientStatusPresenter::class,
|
||
|
|
ToggleClientStatusView::class,
|
||
|
|
);
|
||
|
|
|
||
|
|
describe('SetClientStatusPresenter Unit Tests', function (): void {
|
||
|
|
it('transforms Output into ToggleClientStatusView for active status', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$clientId = new ClientId(Uuid::uuid7());
|
||
|
|
$identifier = new ClientIdentifier('arcadia_id_' . str_repeat('a', 32));
|
||
|
|
$name = new ClientName('Client 1');
|
||
|
|
|
||
|
|
$output = new Output(
|
||
|
|
clientId: $clientId,
|
||
|
|
clientIdentifier: $identifier,
|
||
|
|
clientName: $name,
|
||
|
|
isActive: true,
|
||
|
|
);
|
||
|
|
|
||
|
|
$presenter = new SetClientStatusPresenter();
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$view = $presenter->present($output);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($view)->toBeInstanceOf(ToggleClientStatusView::class)
|
||
|
|
->and($view->id)->toBe($clientId->value)
|
||
|
|
->and($view->name)->toBe('Client 1')
|
||
|
|
->and($view->identifier)->toBe($identifier->value)
|
||
|
|
->and($view->isActive)->toBeTrue()
|
||
|
|
->and($view->statusLabel)->toBe('Active')
|
||
|
|
->and($view->message)->toBe("Client 'Client 1' (ID: {$clientId->value}) is now Active.");
|
||
|
|
});
|
||
|
|
|
||
|
|
it('transforms Output into ToggleClientStatusView for inactive status', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$clientId = new ClientId(Uuid::uuid7());
|
||
|
|
$identifier = new ClientIdentifier('arcadia_id_' . str_repeat('b', 32));
|
||
|
|
$name = new ClientName('Client 2');
|
||
|
|
|
||
|
|
$output = new Output(
|
||
|
|
clientId: $clientId,
|
||
|
|
clientIdentifier: $identifier,
|
||
|
|
clientName: $name,
|
||
|
|
isActive: false,
|
||
|
|
);
|
||
|
|
|
||
|
|
$presenter = new SetClientStatusPresenter();
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$view = $presenter->present($output);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($view)->toBeInstanceOf(ToggleClientStatusView::class)
|
||
|
|
->and($view->isActive)->toBeFalse()
|
||
|
|
->and($view->statusLabel)->toBe('Inactive')
|
||
|
|
->and($view->message)->toBe("Client 'Client 2' (ID: {$clientId->value}) is now Inactive.");
|
||
|
|
});
|
||
|
|
});
|