<?php

namespace MintyPHP\Tests\Service\Tenant;

use MintyPHP\Repository\Org\DepartmentRepository;
use MintyPHP\Repository\Tenant\TenantRepository;
use MintyPHP\Repository\Tenant\UserTenantRepository;
use MintyPHP\Service\Access\PermissionGateway;
use MintyPHP\Service\Tenant\TenantAvatarService;
use MintyPHP\Service\Tenant\TenantFaviconService;
use MintyPHP\Service\Tenant\TenantScopeService;
use MintyPHP\Service\Tenant\TenantServicesFactory;
use PHPUnit\Framework\TestCase;

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

        $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(UserTenantRepository::class, $factory->createUserTenantRepository());
        $this->assertSame($factory->createUserTenantRepository(), $factory->createUserTenantRepository());

        $this->assertInstanceOf(PermissionGateway::class, $factory->createPermissionGateway());
        $this->assertSame($factory->createPermissionGateway(), $factory->createPermissionGateway());

        $this->assertInstanceOf(TenantScopeService::class, $factory->createTenantScopeService());
        $this->assertSame($factory->createTenantScopeService(), $factory->createTenantScopeService());

        $this->assertInstanceOf(TenantAvatarService::class, $factory->createTenantAvatarService());
        $this->assertSame($factory->createTenantAvatarService(), $factory->createTenantAvatarService());

        $this->assertInstanceOf(TenantFaviconService::class, $factory->createTenantFaviconService());
        $this->assertSame($factory->createTenantFaviconService(), $factory->createTenantFaviconService());
    }
}
