<?php

namespace MintyPHP\Tests\Service\Scheduler;

use MintyPHP\Service\Scheduler\ScheduledJobService;
use MintyPHP\Service\Scheduler\SchedulerRunService;
use MintyPHP\Service\Scheduler\SchedulerServicesFactory;
use MintyPHP\Service\User\UserLifecycleService;
use PHPUnit\Framework\TestCase;

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

        $scheduledJobServiceA = $factory->createScheduledJobService();
        $scheduledJobServiceB = $factory->createScheduledJobService();
        $this->assertInstanceOf(ScheduledJobService::class, $scheduledJobServiceA);
        $this->assertSame($scheduledJobServiceA, $scheduledJobServiceB);

        $schedulerRunServiceA = $factory->createSchedulerRunService();
        $schedulerRunServiceB = $factory->createSchedulerRunService();
        $this->assertInstanceOf(SchedulerRunService::class, $schedulerRunServiceA);
        $this->assertSame($schedulerRunServiceA, $schedulerRunServiceB);

        $userLifecycleServiceA = $factory->createUserLifecycleService();
        $userLifecycleServiceB = $factory->createUserLifecycleService();
        $this->assertInstanceOf(UserLifecycleService::class, $userLifecycleServiceA);
        $this->assertSame($userLifecycleServiceA, $userLifecycleServiceB);
    }
}

