function it_loads_valid_theme_file(FilesystemInterface $filesystem, ThemeFactoryInterface $themeFactory, ThemeInterface $theme) { $filesystem->exists('/themes/SampleTheme/theme.json')->willReturn(true); $filesystem->getFileContents('/themes/SampleTheme/theme.json')->willReturn('{ "name": "Sample Theme", "slug": "sylius/sample-theme", "description": "Lorem ipsum dolor sit amet." }'); $themeFactory->createFromArray(["name" => "Sample Theme", "slug" => "sylius/sample-theme", "description" => "Lorem ipsum dolor sit amet."])->willReturn($theme); $theme->setPath('/themes/SampleTheme')->shouldBeCalled(); $this->load('/themes/SampleTheme/theme.json')->shouldReturn($theme); }
/** * @param array $configurations * * @return ThemeInterface[] */ private function initializeThemes(array $configurations) { $themes = []; foreach ($configurations as $configuration) { /** @var ThemeInterface $theme */ $themes[$configuration['name']] = $this->themeFactory->createNamed($configuration['name']); } return $themes; }
/** * {@inheritdoc} */ public function load($resource, $type = null) { if (!$this->filesystem->exists($resource)) { throw new \InvalidArgumentException(sprintf('Given theme metadata file "%s" does not exists!', $resource)); } $themeData = $this->transformResourceContentsToArray($this->filesystem->getFileContents($resource)); $theme = $this->themeFactory->createFromArray($themeData); $theme->setPath(substr($resource, 0, strrpos($resource, '/'))); return $theme; }
/** * {@inheritdoc} */ public function load($resource, $type = null) { if (!file_exists($resource)) { throw new \InvalidArgumentException(sprintf('Given theme metadata file "%s" does not exists!', $resource)); } $themeData = $this->transformResourceContentsToArray(file_get_contents($resource)); $theme = $this->themeFactory->createFromArray($themeData); $theme->setPath(realpath(dirname($resource))); return $theme; }
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', 'parents' => ['second/theme'], 'authors' => []], ['name' => 'second/theme', 'parents' => ['first/theme'], 'authors' => []]]); $themeFactory->createNamed('first/theme')->willReturn($firstTheme); $themeFactory->createNamed('second/theme')->willReturn($secondTheme); $themeHydrator->hydrate(['name' => 'first/theme', 'parents' => [$secondTheme], 'authors' => []], $firstTheme)->willReturn($firstTheme); $themeHydrator->hydrate(['name' => 'second/theme', 'parents' => [$firstTheme], 'authors' => []], $secondTheme)->willReturn($secondTheme); $circularDependencyChecker->check(Argument::cetera())->willThrow(CircularDependencyFoundException::class); $this->shouldThrow(new ThemeLoadingFailedException('Circular dependency found.'))->during('load'); }
/** * @Given the store has :themeName theme */ public function storeHasTheme($themeName) { $theme = $this->themeFactory->createNamed($themeName); $theme->setTitle($themeName); $theme->setPath(sys_get_temp_dir() . '/theme-' . $theme->getCode() . time() . '/'); if (!file_exists($theme->getPath())) { mkdir($theme->getPath(), 0777, true); } $this->themeRepository->add($theme); $this->sharedStorage->set('theme', $theme); }
function it_loads_valid_theme_file(ThemeFactoryInterface $themeFactory, ThemeInterface $theme) { $themeFactory->createFromArray(["name" => "Sample Theme", "logical_name" => "sylius/sample-theme", "description" => "Lorem ipsum dolor sit amet."])->shouldBeCalled()->willReturn($theme); $theme->setPath(realpath(dirname($this->getValidThemeFilePath())))->shouldBeCalled(); $this->load($this->getValidThemeFilePath())->shouldHaveType('Sylius\\Bundle\\ThemeBundle\\Model\\ThemeInterface'); }