/** * @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); }
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(); }