<?php

declare(strict_types=1);

namespace apexl\Io\TestInfrastructure;

use Apexl\Io\Cache\Interfaces\CacheManagerInterface;
use apexl\Io\factories\ContainerFactory;
use apexl\Io\services\FilePaths;
use Apexl\Tests\Core\Infrastructure\DummyCacheManager;
use Dotenv\Dotenv;
use Faker\Factory as FakerFactory;
use Faker\Generator;
use PHPUnit\Framework\TestCase;

abstract class UnitTest extends TestCase
{
    const string BASE_DIR = __DIR__ . '/../../../../../..';
    protected Generator $faker;

    public static function setUpBeforeClass(): void
    {
        Dotenv::createImmutable(self::BASE_DIR)->load();
        $container = new ContainerFactory()->make(self::BASE_DIR);
        $container->set(FilePaths::class, new FilePaths(self::BASE_DIR));
        $container->set(CacheManagerInterface::class, new DummyCacheManager());

        $GLOBALS['container'] = $container;
    }

    protected function setUp(): void
    {
        $this->faker = FakerFactory::create();
    }
}
