function it_returns_sum_of_configurations_returned_by_nested_configuration_providers(ConfigurationProviderInterface $firstConfigurationProvider, ConfigurationProviderInterface $secondConfigurationProvider) { $this->beConstructedWith([$firstConfigurationProvider, $secondConfigurationProvider]); $firstConfigurationProvider->getConfigurations()->willReturn([['name' => 'first/theme']]); $secondConfigurationProvider->getConfigurations()->willReturn([['name' => 'second/theme'], ['name' => 'third/theme']]); $this->getConfigurations()->shouldReturn([['name' => 'first/theme'], ['name' => 'second/theme'], ['name' => 'third/theme']]); }
/** * {@inheritdoc} */ public function load() { $configurations = $this->configurationProvider->getConfigurations(); $themes = $this->initializeThemes($configurations); $themes = $this->hydrateThemes($configurations, $themes); $this->checkForCircularDependencies($themes); return array_values($themes); }
function it_throws_an_exception_if_there_is_a_circular_dependency_found(ConfigurationProviderInterface $configurationProvider, ThemeFactoryInterface $themeFactory, HydrationInterface $themeHydrator, CircularDependencyCheckerInterface $circularDependencyChecker, ThemeInterface $firstTheme, ThemeInterface $secondTheme) { $configurationProvider->getConfigurations()->willReturn([['name' => 'first/theme', 'path' => '/first/theme/path', 'parents' => ['second/theme'], 'authors' => [], 'screenshots' => []], ['name' => 'second/theme', 'path' => '/second/theme/path', 'parents' => ['first/theme'], 'authors' => [], 'screenshots' => []]]); $themeFactory->create('first/theme', '/first/theme/path')->willReturn($firstTheme); $themeFactory->create('second/theme', '/second/theme/path')->willReturn($secondTheme); $themeHydrator->hydrate(['name' => 'first/theme', 'path' => '/first/theme/path', 'parents' => [$secondTheme], 'authors' => [], 'screenshots' => []], $firstTheme)->willReturn($firstTheme); $themeHydrator->hydrate(['name' => 'second/theme', 'path' => '/second/theme/path', 'parents' => [$firstTheme], 'authors' => [], 'screenshots' => []], $secondTheme)->willReturn($secondTheme); $circularDependencyChecker->check(Argument::cetera())->willThrow(CircularDependencyFoundException::class); $this->shouldThrow(new ThemeLoadingFailedException('Circular dependency found.'))->during('load'); }