feat: introduce user management events

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-07 22:32:45 -04:00
parent 985e4a6450
commit f147ffc5c7
11 changed files with 457 additions and 19 deletions
@@ -5,8 +5,10 @@ declare(strict_types=1);
namespace KTXT\Unit\Console\Tenant;
use KTXC\Console\Tenant\TenantCreateCommand;
use KTXC\Context\TenantContext;
use KTXC\Models\Tenant\TenantObject;
use KTXC\Service\TenantService;
use KTXC\Service\UserAccountsService;
use KTXC\Stores\UserAccountsStore;
use KTXC\Stores\UserRolesStore;
use PHPUnit\Framework\MockObject\MockObject;
@@ -22,6 +24,7 @@ class TenantCreateCommandTest extends TestCase
private TenantService&MockObject $tenantService;
private UserRolesStore $rolesStore;
private UserAccountsStore $userStore;
private UserAccountsService $userService;
private CommandTester $tester;
private ?TenantObject $deposited = null;
@@ -31,12 +34,21 @@ class TenantCreateCommandTest extends TestCase
$this->rolesStore = $this->createStub(UserRolesStore::class);
$this->rolesStore->method('createRole')->willReturn(['rid' => 'admin']);
$this->userStore = $this->createStub(UserAccountsStore::class);
$this->userStore->method('createUser')->willReturn(['uid' => 'admin']);
$this->userService = $this->createStub(UserAccountsService::class);
$this->userService->method('createUser')->willReturn(['uid' => 'admin']);
$contextTenantService = $this->createStub(TenantService::class);
$contextTenantService->method('fetchById')->willReturnCallback(
fn(string $identifier): ?TenantObject => $this->deposited?->getIdentifier() === $identifier
? $this->deposited
: null,
);
$this->tester = new CommandTester(
new TenantCreateCommand(
$this->tenantService,
$this->rolesStore,
$this->userStore,
$this->userService,
new TenantContext($contextTenantService),
new NullLogger(),
)
);