/**
  * {@inheritdoc}
  */
 public function create(array $options = [])
 {
     $options = $this->optionsResolver->resolve($options);
     /** @var ChannelInterface $channel */
     $channel = $this->channelFactory->createNamed($options['name']);
     $channel->setCode($options['code']);
     $channel->setHostname($options['hostname']);
     $channel->setEnabled($options['enabled']);
     $channel->setColor($options['color']);
     $channel->setTaxCalculationStrategy($options['tax_calculation_strategy']);
     $channel->setThemeName($options['theme_name']);
     $channel->setDefaultLocale($options['default_locale']);
     foreach ($options['locales'] as $locale) {
         $channel->addLocale($locale);
     }
     $channel->setDefaultCurrency($options['default_currency']);
     foreach ($options['currencies'] as $currency) {
         $channel->addCurrency($currency);
     }
     foreach ($options['payment_methods'] as $paymentMethod) {
         $channel->addPaymentMethod($paymentMethod);
     }
     foreach ($options['shipping_methods'] as $shippingMethod) {
         $channel->addShippingMethod($shippingMethod);
     }
     return $channel;
 }
Beispiel #2
0
 /**
  * @Given /^the store operates on (?:a|another) channel named "([^"]+)"$/
  */
 public function theStoreOperatesOnAChannelNamed($channelName)
 {
     $channel = $this->channelFactory->createNamed($channelName);
     $channel->setCode($channelName);
     $this->channelRepository->add($channel);
     $this->sharedStorage->set('channel', $channel);
 }
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     $channel = $this->channelFactory->createNamed(self::DEFAULT_CHANNEL_NAME);
     $channel->setCode(self::DEFAULT_CHANNEL_CODE);
     $this->channelRepository->add($channel);
     return ['channel' => $channel];
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function create($code = null, $name = null, $currencyCode = null)
 {
     $currency = $this->provideCurrency($currencyCode);
     $locale = $this->provideLocale();
     /** @var ChannelInterface $channel */
     $channel = $this->channelFactory->createNamed($name ?: self::DEFAULT_CHANNEL_NAME);
     $channel->setCode($code ?: self::DEFAULT_CHANNEL_CODE);
     $channel->setTaxCalculationStrategy('order_items_based');
     $channel->addCurrency($currency);
     $channel->setBaseCurrency($currency);
     $channel->addLocale($locale);
     $channel->setDefaultLocale($locale);
     $this->channelRepository->add($channel);
     return ['channel' => $channel, 'currency' => $currency, 'locale' => $locale];
 }
 function it_creates_a_default_united_states_channel_with_country_zone_and_usd_as_default_currency(RepositoryInterface $channelRepository, RepositoryInterface $countryRepository, RepositoryInterface $currencyRepository, RepositoryInterface $localeRepository, RepositoryInterface $zoneMemberRepository, RepositoryInterface $zoneRepository, ChannelFactoryInterface $channelFactory, FactoryInterface $countryFactory, FactoryInterface $currencyFactory, FactoryInterface $localeFactory, FactoryInterface $zoneFactory, FactoryInterface $zoneMemberFactory, ZoneMemberInterface $zoneMember, ZoneInterface $zone, ChannelInterface $channel, CountryInterface $unitedStates, CurrencyInterface $currency, LocaleInterface $locale)
 {
     $channel->getName()->willReturn('United States');
     $channelFactory->createNamed('United States')->willReturn($channel);
     $localeFactory->createNew()->willReturn($locale);
     $locale->setCode('en_US')->shouldBeCalled();
     $zoneMemberFactory->createNew()->willReturn($zoneMember);
     $zoneFactory->createNew()->willReturn($zone);
     $channel->setCode('WEB-US')->shouldBeCalled();
     $channel->setTaxCalculationStrategy('order_items_based')->shouldBeCalled();
     $zoneMember->setCode('US')->shouldBeCalled();
     $zone->setCode('US')->shouldBeCalled();
     $zone->setName('United States')->shouldBeCalled();
     $zone->setType(ZoneInterface::TYPE_COUNTRY)->shouldBeCalled();
     $zone->addMember($zoneMember)->shouldBeCalled();
     $countryFactory->createNew()->willReturn($unitedStates);
     $unitedStates->setCode('US')->shouldBeCalled();
     $currencyFactory->createNew()->willReturn($currency);
     $currency->setCode('USD')->shouldBeCalled();
     $currency->setExchangeRate(1.0)->shouldBeCalled();
     $channel->setDefaultCurrency($currency)->shouldBeCalled();
     $channel->addCurrency($currency)->shouldBeCalled();
     $channel->setDefaultLocale($locale)->shouldBeCalled();
     $channel->addLocale($locale)->shouldBeCalled();
     $currencyRepository->findOneBy(['code' => 'USD'])->willReturn(null);
     $localeRepository->findOneBy(['code' => 'en_US'])->willReturn(null);
     $currencyRepository->add($currency)->shouldBeCalled();
     $localeRepository->add($locale)->shouldBeCalled();
     $countryRepository->add($unitedStates)->shouldBeCalled();
     $channelRepository->add($channel)->shouldBeCalled();
     $zoneRepository->add($zone)->shouldBeCalled();
     $zoneMemberRepository->add($zoneMember)->shouldBeCalled();
     $this->create();
 }
 function it_creates_a_default_channel_and_persist_it(ChannelFactoryInterface $channelFactory, FactoryInterface $currencyFactory, FactoryInterface $localeFactory, RepositoryInterface $channelRepository, RepositoryInterface $currencyRepository, RepositoryInterface $localeRepository, ChannelInterface $channel, CurrencyInterface $currency, LocaleInterface $locale)
 {
     $localeFactory->createNew()->willReturn($locale);
     $locale->setCode('en_US')->shouldBeCalled();
     $currencyFactory->createNew()->willReturn($currency);
     $currency->setCode('USD')->shouldBeCalled();
     $channelFactory->createNamed('Default')->willReturn($channel);
     $channel->setCode('DEFAULT')->shouldBeCalled();
     $channel->setTaxCalculationStrategy('order_items_based')->shouldBeCalled();
     $channel->addCurrency($currency)->shouldBeCalled();
     $channel->setBaseCurrency($currency)->shouldBeCalled();
     $channel->addLocale($locale)->shouldBeCalled();
     $channel->setDefaultLocale($locale)->shouldBeCalled();
     $currencyRepository->findOneBy(['code' => 'USD'])->willReturn(null);
     $localeRepository->findOneBy(['code' => 'en_US'])->willReturn(null);
     $currencyRepository->add($currency)->shouldBeCalled();
     $localeRepository->add($locale)->shouldBeCalled();
     $channelRepository->add($channel)->shouldBeCalled();
     $this->create()->shouldReturn(['channel' => $channel, 'currency' => $currency, 'locale' => $locale]);
 }
 /**
  * @return ChannelInterface
  */
 private function createChannel($code, $name)
 {
     $channel = $this->channelFactory->createNamed($name);
     $channel->setCode($code);
     return $channel;
 }
 /**
  * @return ChannelInterface
  */
 private function createChannel()
 {
     $channel = $this->channelFactory->createNamed('France');
     $channel->setCode(self::DEFAULT_CHANNEL_CODE);
     return $channel;
 }
 /**
  * @return ChannelInterface
  */
 private function createChannel()
 {
     $channel = $this->channelFactory->createNamed('France');
     $channel->setCode('WEB-FR');
     return $channel;
 }