function it_updates_a_channel($categoryRepository, $localeRepository, $currencyRepository, ChannelInterface $channel, CategoryInterface $tree, LocaleInterface $enUS, LocaleInterface $frFR, CurrencyInterface $usd, CurrencyInterface $eur) { $values = ['code' => 'ecommerce', 'label' => 'Ecommerce', 'locales' => ['en_US', 'fr_FR'], 'currencies' => ['EUR', 'USD'], 'tree' => 'master_catalog', 'conversion_units' => ['weight' => 'GRAM']]; $channel->setCode('ecommerce')->shouldBeCalled(); $channel->setLabel('Ecommerce')->shouldBeCalled(); $categoryRepository->findOneByIdentifier('master_catalog')->willReturn($tree); $channel->setCategory($tree)->shouldBeCalled(); $localeRepository->findOneByIdentifier('en_US')->willReturn($enUS); $localeRepository->findOneByIdentifier('fr_FR')->willReturn($frFR); $channel->setLocales([$enUS, $frFR])->shouldBeCalled(); $currencyRepository->findOneByIdentifier('EUR')->willReturn($eur); $currencyRepository->findOneByIdentifier('USD')->willReturn($usd); $channel->setCurrencies([$eur, $usd])->shouldBeCalled(); $channel->setConversionUnits(['weight' => 'GRAM'])->shouldBeCalled(); $this->update($channel, $values, []); }
/** * @param ChannelInterface $channel * @param array $localeCodes */ protected function setLocales(ChannelInterface $channel, array $localeCodes) { $locales = []; foreach ($localeCodes as $localeCode) { $locale = $this->localeRepository->findOneByIdentifier($localeCode); if (null === $locale) { throw new \InvalidArgumentException(sprintf('Locale with "%s" code does not exist', $localeCode)); } $locales[] = $locale; } $channel->setLocales($locales); }