<?php

namespace MintyPHP\Tests\Service\Directory;

use MintyPHP\Repository\Access\RoleRepository;
use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Service\Access\RoleService;
use MintyPHP\Service\Directory\DirectoryScopeGateway;
use MintyPHP\Service\Directory\DirectoryServicesFactory;
use MintyPHP\Service\Directory\DirectorySettingsGateway;
use MintyPHP\Service\Org\DepartmentService;
use MintyPHP\Service\Tenant\TenantService;
use PHPUnit\Framework\TestCase;

class DirectoryServicesFactoryTest extends TestCase
{
    public function testFactoryReturnsStableInstancesPerFactoryObject(): void
    {
        $factory = new DirectoryServicesFactory();

        $this->assertInstanceOf(TenantRepository::class, $factory->createTenantRepository());
        $this->assertSame($factory->createTenantRepository(), $factory->createTenantRepository());

        $this->assertInstanceOf(DepartmentRepository::class, $factory->createDepartmentRepository());
        $this->assertSame($factory->createDepartmentRepository(), $factory->createDepartmentRepository());

        $this->assertInstanceOf(RoleRepository::class, $factory->createRoleRepository());
        $this->assertSame($factory->createRoleRepository(), $factory->createRoleRepository());

        $this->assertInstanceOf(DirectorySettingsGateway::class, $factory->createDirectorySettingsGateway());
        $this->assertSame($factory->createDirectorySettingsGateway(), $factory->createDirectorySettingsGateway());

        $this->assertInstanceOf(DirectoryScopeGateway::class, $factory->createDirectoryScopeGateway());
        $this->assertSame($factory->createDirectoryScopeGateway(), $factory->createDirectoryScopeGateway());

        $this->assertInstanceOf(TenantService::class, $factory->createTenantService());
        $this->assertSame($factory->createTenantService(), $factory->createTenantService());

        $this->assertInstanceOf(DepartmentService::class, $factory->createDepartmentService());
        $this->assertSame($factory->createDepartmentService(), $factory->createDepartmentService());

        $this->assertInstanceOf(RoleService::class, $factory->createRoleService());
        $this->assertSame($factory->createRoleService(), $factory->createRoleService());
    }
}
