function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, ThemeInterface $theme)
 {
     $theme->getName()->willReturn('theme/name');
     $theme->getPath()->willReturn('/theme/path');
     $filesystem->exists('/theme/path/resource')->willReturn(false);
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['resource', $theme]);
 }
 function it_throws_an_exception_if_settings_schema_does_not_exist(ThemeInterface $theme)
 {
     $theme->getTitle()->willReturn('Candy shop');
     $theme->getName()->willReturn('candy/shop');
     $theme->getPath()->willReturn($this->vfsStream->url());
     $this->shouldThrow(new \InvalidArgumentException(sprintf('Could not find settings schema of theme "Candy shop" (candy/shop) in file "%s"', $this->vfsStream->url() . '/Settings.php')))->during('getSchema', [$theme]);
 }
Exemplo n.º 3
0
 /**
  * @Given channel :channel uses :theme theme
  */
 public function channelUsesTheme(ChannelInterface $channel, ThemeInterface $theme)
 {
     $channel->setThemeName($theme->getName());
     $this->channelManager->persist($channel);
     $this->channelManager->flush();
     $this->sharedStorage->set('channel', $channel);
     $this->sharedStorage->set('theme', $theme);
 }
Exemplo n.º 4
0
 public function it_should_return_global_variables(ThemeInterface $theme, ThemeContextInterface $themeContext)
 {
     $theme->getName()->willReturn('swp/theme-one');
     $theme->getPath()->willReturn('/path/to/theme/');
     $themeContext->getTheme()->shouldBeCalled()->willReturn($theme);
     $globals = ['theme' => $theme];
     $this->getGlobals()->shouldReturn($globals);
 }
Exemplo n.º 5
0
 /**
  * @param ThemeInterface $theme
  */
 private function updateTheme(ThemeInterface $theme)
 {
     $existingTheme = $this->themeRepository->findOneByName($theme->getName());
     if (null !== $existingTheme) {
         $theme = $this->themeMerger->merge($existingTheme, $theme);
     }
     $this->themeRepository->add($theme);
 }
 public function it_defines_themes_names_choices(OptionsResolver $resolver, ThemeProviderInterface $themeProvider, ThemeInterface $theme)
 {
     $theme->getName()->willReturn('swp/theme-name');
     $themeProvider->getCurrentTenantAvailableThemes()->willReturn([$theme]);
     $resolver->setNormalizer('choices', Argument::type('callable'))->willReturn($resolver);
     $resolver->setDefaults(['invalid_message' => 'The selected theme does not exist'])->shouldBeCalled();
     $this->configureOptions($resolver);
 }
 function it_registers_theme_schema_alias_if_not_exists_during_loading_settings(SettingsManagerInterface $decoratedSettingsManager, ServiceRegistryInterface $schemaRegistry, ThemeSettingsSchemaProviderInterface $themeSettingsSchemaProvider, ThemeInterface $theme, SettingsInterface $settings, SchemaInterface $schema)
 {
     $theme->getName()->willReturn('theme/name');
     $schemaRegistry->has('theme_theme/name')->willReturn(false);
     $themeSettingsSchemaProvider->getSchema($theme)->willReturn($schema);
     $schemaRegistry->register('theme_theme/name', $schema)->shouldBeCalled();
     $decoratedSettingsManager->load('theme_theme/name', null)->willReturn($settings);
     $this->load($theme)->shouldReturn($settings);
 }
 function it_transforms_a_cycle_to_user_friendly_message(ThemeInterface $firstTheme, ThemeInterface $secondTheme, ThemeInterface $thirdTheme, ThemeInterface $fourthTheme)
 {
     $this->beConstructedWith([$firstTheme, $secondTheme, $thirdTheme, $fourthTheme, $thirdTheme]);
     $firstTheme->getName()->willReturn('first/theme');
     $secondTheme->getName()->willReturn('second/theme');
     $thirdTheme->getName()->willReturn('third/theme');
     $fourthTheme->getName()->willReturn('fourth/theme');
     $this->getMessage()->shouldReturn('Circular dependency was found while resolving theme "first/theme", caused by cycle "third/theme -> fourth/theme -> third/theme".');
 }
Exemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function load(ThemeInterface $theme, $namespace = null)
 {
     $schemaAlias = sprintf('theme_%s', $theme->getName());
     if (!$this->schemaRegistry->has($schemaAlias)) {
         $schema = $this->themeSettingsSchemaProvider->getSchema($theme);
         $this->schemaRegistry->register($schemaAlias, $schema);
     }
     return $this->decoratedSettingsManager->load($schemaAlias, $namespace);
 }
 function it_throws_resource_not_found_exception_if_the_location_found_in_cache_is_null(TemplateLocatorInterface $decoratedTemplateLocator, Cache $cache, TemplateReferenceInterface $template, ThemeInterface $theme)
 {
     $template->getLogicalName()->willReturn('Logical:Name');
     $template->getPath()->willReturn('@Acme/template.html.twig');
     $theme->getName()->willReturn('theme/name');
     $cache->contains('Logical:Name|theme/name')->willReturn(true);
     $cache->fetch('Logical:Name|theme/name')->willReturn(null);
     $decoratedTemplateLocator->locateTemplate(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateTemplate', [$template, $theme]);
 }
Exemplo n.º 11
0
 function it_returns_theme_list_in_hierarchized_order(ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme)
 {
     $firstTheme->getName()->willReturn('foo/bar1');
     $firstTheme->getParentsNames()->willReturn(['foo/bar2']);
     $secondTheme->getName()->willReturn('foo/bar2');
     $secondTheme->getParentsNames()->willReturn([]);
     $themeRepository->findOneByName('foo/bar1')->willReturn($firstTheme);
     $themeRepository->findOneByName('foo/bar2')->willReturn($secondTheme);
     $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]);
 }
 function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, KernelInterface $kernel, ThemeInterface $theme, BundleInterface $childBundle, BundleInterface $parentBundle)
 {
     $kernel->getBundle('ParentBundle', false)->willReturn([$childBundle, $parentBundle]);
     $childBundle->getName()->willReturn('ChildBundle');
     $parentBundle->getName()->willReturn('ParentBundle');
     $theme->getName()->willReturn('theme/name');
     $theme->getPath()->willReturn('/theme/path');
     $filesystem->exists('/theme/path/ChildBundle/views/index.html.twig')->shouldBeCalled()->willReturn(false);
     $filesystem->exists('/theme/path/ParentBundle/views/index.html.twig')->shouldBeCalled()->willReturn(false);
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['@ParentBundle/Resources/views/index.html.twig', $theme]);
 }
 /**
  * @param ThemeInterface $theme
  * @param string $filepath
  */
 public function __construct(ThemeInterface $theme, $filepath)
 {
     $this->name = $filepath;
     $parts = explode('.', basename($filepath), 3);
     if (3 !== count($parts)) {
         throw new \InvalidArgumentException(sprintf('Could not create a translation resource with filepath "%s".', $filepath));
     }
     $this->domain = $parts[0];
     $this->locale = $parts[1] . '@' . str_replace('/', '-', $theme->getName());
     $this->format = $parts[2];
 }
 /**
  * {@inheritdoc}
  */
 public function getSchema(ThemeInterface $theme)
 {
     $schemaPath = sprintf('%s/Settings.php', $theme->getPath());
     if (!file_exists($schemaPath)) {
         throw new \InvalidArgumentException(sprintf('Could not find settings schema of theme "%s" (%s) in file "%s"', $theme->getTitle(), $theme->getName(), $schemaPath));
     }
     $schema = (require $schemaPath);
     if (!$schema instanceof SchemaInterface) {
         throw new \InvalidArgumentException(sprintf('File "%s" must return an instance of "%s"', $schemaPath, SchemaInterface::class));
     }
     return $schema;
 }
 function it_finds_circular_dependency_if_theme_parents_are_cycled(ThemeInterface $firstTheme, ThemeInterface $secondTheme, ThemeInterface $thirdTheme, ThemeInterface $fourthTheme)
 {
     $firstTheme->getParents()->willReturn([$secondTheme, $thirdTheme]);
     $secondTheme->getParents()->willReturn([$thirdTheme]);
     $thirdTheme->getParents()->willReturn([$fourthTheme]);
     $fourthTheme->getParents()->willReturn([$secondTheme]);
     $firstTheme->getName()->willReturn('first/theme');
     $secondTheme->getName()->willReturn('second/theme');
     $thirdTheme->getName()->willReturn('third/theme');
     $fourthTheme->getName()->willReturn('fourth/theme');
     $this->shouldThrow(CircularDependencyFoundException::class)->during('check', [$firstTheme]);
 }
 function it_builds_cache_by_warming_up_every_template_and_every_theme_together(TemplateFinderInterface $templateFinder, TemplateLocatorInterface $templateLocator, ThemeRepositoryInterface $themeRepository, Cache $cache, ThemeInterface $theme, TemplateReferenceInterface $firstTemplate, TemplateReferenceInterface $secondTemplate)
 {
     $templateFinder->findAllTemplates()->willReturn([$firstTemplate, $secondTemplate]);
     $themeRepository->findAll()->willReturn([$theme]);
     $theme->getName()->willReturn('theme/name');
     $firstTemplate->getLogicalName()->willReturn('Logical:Name:First');
     $secondTemplate->getLogicalName()->willReturn('Logical:Name:Second');
     $templateLocator->locateTemplate($firstTemplate, $theme)->willReturn('/First/Theme/index.html.twig');
     $templateLocator->locateTemplate($secondTemplate, $theme)->willThrow(ResourceNotFoundException::class);
     $cache->save('Logical:Name:First|theme/name', '/First/Theme/index.html.twig')->shouldBeCalled();
     $cache->save('Logical:Name:Second|theme/name', null)->shouldBeCalled();
     $this->warmUp(null);
 }
Exemplo n.º 17
0
 function it_ensures_cohesion_between_parent_themes(ThemeLoaderInterface $themeLoader, ThemeRepositoryInterface $themeRepository, ThemeMergerInterface $themeMerger, ThemeInterface $loadedTheme, ThemeInterface $loadedParentTheme, ThemeInterface $existingParentTheme)
 {
     $themeRepository->findAll()->willReturn([$existingParentTheme]);
     $existingParentTheme->getName()->willReturn('parent-theme/name');
     $themeLoader->load()->willReturn([$loadedTheme, $loadedParentTheme]);
     $loadedTheme->getName()->willReturn('theme/name');
     $loadedTheme->getParents()->willReturn([$loadedParentTheme]);
     $themeRepository->findOneByName('theme/name')->willReturn(null);
     $loadedParentTheme->getName()->willReturn('parent-theme/name');
     $loadedParentTheme->getParents()->willReturn([]);
     $themeRepository->findOneByName('parent-theme/name')->willReturn($existingParentTheme);
     $loadedTheme->removeParent($loadedParentTheme)->shouldBeCalled();
     $loadedTheme->addParent($existingParentTheme)->shouldBeCalled();
     $themeMerger->merge($existingParentTheme, $loadedParentTheme)->willReturn($existingParentTheme);
     $themeRepository->add($loadedTheme)->shouldBeCalled();
     $themeRepository->add($existingParentTheme)->shouldBeCalled();
     $themeRepository->add($loadedParentTheme)->shouldNotBeCalled();
     $this->synchronize();
 }
Exemplo n.º 18
0
 function it_returns_id_if_there_is_no_given_choice_translation(TranslatorInterface $translator, ThemeContextInterface $themeContext, ThemeHierarchyProviderInterface $themeHierarchyProvider, ThemeInterface $theme)
 {
     $theme->getName()->willReturn('theme/name');
     $themeContext->getTheme()->willReturn($theme);
     $themeHierarchyProvider->getThemeHierarchy($theme)->willReturn([$theme]);
     $translator->transChoice('id|theme/name', 42, Argument::cetera())->willReturn('id|theme/name');
     $translator->transChoice('id', 42, Argument::cetera())->willReturn('id');
     $this->transChoice('id', 42)->shouldReturn('id');
 }
Exemplo n.º 19
0
 function it_returns_null_if_theme_with_given_name_is_not_found(ThemeInterface $theme)
 {
     $theme->getName()->willReturn('example/default-theme');
     $this->add($theme);
     $this->findOneByName('example/cristopher-theme')->shouldReturn(null);
 }
 function let(ThemeInterface $theme)
 {
     $theme->getName()->willReturn('theme/name');
     $this->beConstructedWith('resource name', $theme);
 }
Exemplo n.º 21
0
 /**
  * @Then /^(that channel) should use (that theme)$/
  */
 public function channelShouldUseTheme(ChannelInterface $channel, ThemeInterface $theme)
 {
     $this->channelIndexPage->open();
     expect($this->channelIndexPage->getUsedThemeName($channel->getCode()))->toBe($theme->getName());
 }
 /**
  * @param string $resourceName
  * @param ThemeInterface $theme
  */
 public function __construct($resourceName, ThemeInterface $theme)
 {
     parent::__construct(sprintf('Could not find resource "%s" using theme "%s".', $resourceName, $theme->getName()));
 }
 /**
  * @param TemplateReferenceInterface $template
  * @param ThemeInterface $theme
  *
  * @return string
  */
 private function getCacheKey(TemplateReferenceInterface $template, ThemeInterface $theme)
 {
     return $template->getLogicalName() . '|' . $theme->getName();
 }
Exemplo n.º 24
0
 function it_throws_an_invalid_argument_exception_if_failed_to_instantiate_with_given_filepath(ThemeInterface $theme)
 {
     $theme->getName()->willReturn('theme/name');
     $this->beConstructedWith($theme, 'one.dot');
     $this->shouldThrow(\InvalidArgumentException::class)->duringInstantiation();
 }
Exemplo n.º 25
0
 /**
  * @Then /^(that channel) should use (that theme)$/
  */
 public function channelShouldUseTheme(ChannelInterface $channel, ThemeInterface $theme)
 {
     $this->channelIndexPage->open();
     Assert::same($this->channelIndexPage->getUsedThemeName($channel->getCode()), $theme->getName());
 }
 function it_returns_resources_locales_while_using_one_nested_theme(TranslationFilesFinderInterface $translationFilesFinder, ThemeRepositoryInterface $themeRepository, ThemeHierarchyProviderInterface $themeHierarchyProvider, ThemeInterface $mainTheme, ThemeInterface $parentTheme)
 {
     $themeRepository->findAll()->willReturn([$mainTheme]);
     $themeHierarchyProvider->getThemeHierarchy($mainTheme)->willReturn([$mainTheme, $parentTheme]);
     $mainTheme->getPath()->willReturn('/main/theme/path');
     $mainTheme->getName()->willReturn('main-theme/name');
     $parentTheme->getPath()->willReturn('/parent/theme/path');
     $parentTheme->getName()->willReturn('parent-theme/name');
     $translationFilesFinder->findTranslationFiles('/main/theme/path')->willReturn(['/main/theme/path/messages.en.yml']);
     $translationFilesFinder->findTranslationFiles('/parent/theme/path')->willReturn(['/parent/theme/path/messages.en.yml']);
     $this->getResourcesLocales()->shouldReturn(['en@main-theme-name']);
 }
Exemplo n.º 27
0
 function it_returns_modified_path_if_its_referencing_bundle_asset(ThemeInterface $theme)
 {
     $theme->getName()->willReturn('theme/name');
     $this->resolve('bundles/asset.min.js', $theme)->shouldReturn('bundles/_themes/theme/name/asset.min.js');
 }
Exemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 public function resolve($path, ThemeInterface $theme)
 {
     return str_replace('theme/', 'bundles/_themes/' . $theme->getName() . '/', $path);
 }