function it_throws_an_exception_if_resource_can_not_be_located(Filesystem $filesystem, ThemeInterface $theme)
 {
     $theme->getSlug()->willReturn('theme/slug');
     $theme->getPath()->willReturn('/theme/path');
     $filesystem->exists('/theme/path/resource')->willReturn(false);
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateResource', ['resource', $theme]);
 }
 function it_returns_theme_list_in_hierarchized_order(ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme)
 {
     $firstTheme->getSlug()->willReturn("foo/bar1");
     $firstTheme->getParentsSlugs()->willReturn(["foo/bar2"]);
     $secondTheme->getSlug()->willReturn("foo/bar2");
     $secondTheme->getParentsSlugs()->willReturn([]);
     $themeRepository->findOneBySlug("foo/bar1")->willReturn($firstTheme);
     $themeRepository->findOneBySlug("foo/bar2")->willReturn($secondTheme);
     $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]);
 }
 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->getSlug()->willReturn('theme/slug');
     $cache->contains('Logical:Name|theme/slug')->willReturn(true);
     $cache->fetch('Logical:Name|theme/slug')->willReturn(null);
     $decoratedTemplateLocator->locateTemplate(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(ResourceNotFoundException::class)->during('locateTemplate', [$template, $theme]);
 }
 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->getSlug()->willReturn('theme/slug');
     $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]);
 }
 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->getSlug()->willReturn('theme/slug');
     $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/slug', '/First/Theme/index.html.twig')->shouldBeCalled();
     $cache->save('Logical:Name:Second|theme/slug', null)->shouldBeCalled();
     $this->warmUp(null);
 }
Esempio n. 6
0
 /**
  * @param TemplateReferenceInterface $template
  * @param ThemeInterface $theme
  *
  * @return string
  */
 private function getCacheKey(TemplateReferenceInterface $template, ThemeInterface $theme)
 {
     return $template->getLogicalName() . '|' . $theme->getSlug();
 }
Esempio n. 7
0
 function it_returns_null_if_theme_with_given_slug_is_not_found(ThemeInterface $theme)
 {
     $theme->getSlug()->willReturn("foo/bar");
     $this->beConstructedWith([$theme]);
     $this->findOneBySlug("blah/blah")->shouldReturn(null);
 }
 function let(ThemeInterface $theme)
 {
     $theme->getSlug()->willReturn('theme/slug');
     $this->beConstructedWith('resource name', $theme);
 }
Esempio n. 9
0
 function it_returns_id_if_there_is_no_given_choice_translation(TranslatorInterface $translator, ThemeContextInterface $themeContext, ThemeInterface $theme)
 {
     $theme->getSlug()->willReturn('theme/slug');
     $themeContext->getThemeHierarchy()->willReturn([$theme]);
     $translator->transChoice('id|theme/slug', 42, Argument::cetera())->willReturn('id|theme/slug');
     $translator->transChoice('id', 42, Argument::cetera())->willReturn('id');
     $this->transChoice('id', 42)->shouldReturn('id');
 }
 /**
  * @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->getSlug()));
 }