createApiService(); $service2 = $factory->createApiService(); // THEN expect($service1)->toBeInstanceOf(ApiService::class); expect($service1)->toBeInstanceOf(ArcadiaApiService::class); expect($service1)->toBe($service2); }); it('creates EmployeeService instance and memoizes it', function () { // GIVEN $apiClient = Mockery::mock(ApiClient::class); $config = new ApiConfig( endpoint: new Uri('https://api.example.com'), apiKey: new ClientIdentifier('id'), secret: new ClientSecret('secret'), ); $factory = new ServiceFactory($apiClient, $config); // WHEN $service1 = $factory->createEmployeeService(); $service2 = $factory->createEmployeeService(); $service3 = $factory->employeeService(); // THEN expect($service1)->toBeInstanceOf(EmployeeService::class); expect($service1)->toBeInstanceOf(ArcadiaEmployeeService::class); expect($service1)->toBe($service2); expect($service1)->toBe($service3); }); it('creates IncoService instance and memoizes it', function () { // GIVEN $apiClient = Mockery::mock(ApiClient::class); $config = new ApiConfig( endpoint: new Uri('https://api.example.com'), apiKey: new ClientIdentifier('id'), secret: new ClientSecret('secret'), ); $factory = new ServiceFactory($apiClient, $config); // WHEN $service1 = $factory->createIncoService(); $service2 = $factory->createIncoService(); $service3 = $factory->incoService(); // THEN expect($service1)->toBeInstanceOf(IncoService::class); expect($service1)->toBeInstanceOf(ArcadiaIncoService::class); expect($service1)->toBe($service2); expect($service1)->toBe($service3); }); it('creates BrandService instance and memoizes it', function () { // GIVEN $apiClient = Mockery::mock(ApiClient::class); $config = new ApiConfig( endpoint: new Uri('https://api.example.com'), apiKey: new ClientIdentifier('id'), secret: new ClientSecret('secret'), ); $factory = new ServiceFactory($apiClient, $config); // WHEN $service1 = $factory->createBrandService(); $service2 = $factory->createBrandService(); $service3 = $factory->brandService(); // THEN expect($service1)->toBeInstanceOf(BrandService::class); expect($service1)->toBeInstanceOf(ArcadiaBrandService::class); expect($service1)->toBe($service2); expect($service1)->toBe($service3); }); });