function it_creates_default_france_channel_with_country_zone_and_eur_as_default_currency($channelRepository, $countryRepository, $currencyRepository, $zoneMemberRepository, $zoneRepository, $channelFactory, $countryFactory, $currencyFactory, $zoneMemberFactory, $zoneFactory, ZoneMemberInterface $zoneMember, ZoneInterface $zone, ChannelInterface $channel, CountryInterface $france, CurrencyInterface $euro) { $channel->getName()->willReturn('France'); $channelFactory->createNamed('France')->willReturn($channel); $zoneMemberFactory->createNew()->willReturn($zoneMember); $zoneFactory->createNew()->willReturn($zone); $channel->setCode('WEB-FR')->shouldBeCalled(); $zoneMember->setCode('FR')->shouldBeCalled(); $zone->setCode('FR')->shouldBeCalled(); $zone->setName('France')->shouldBeCalled(); $zone->setType(ZoneInterface::TYPE_COUNTRY)->shouldBeCalled(); $zone->addMember($zoneMember)->shouldBeCalled(); $countryFactory->createNew()->willReturn($france); $france->setCode('FR')->shouldBeCalled(); $currencyFactory->createNew()->willReturn($euro); $euro->setCode('EUR')->shouldBeCalled(); $euro->setExchangeRate(1.0)->shouldBeCalled(); $euro->setBase(true)->shouldBeCalled(); $channel->setDefaultCurrency($euro)->shouldBeCalled(); $currencyRepository->add($euro)->shouldBeCalled(); $countryRepository->add($france)->shouldBeCalled(); $channelRepository->add($channel)->shouldBeCalled(); $zoneRepository->add($zone)->shouldBeCalled(); $zoneMemberRepository->add($zoneMember)->shouldBeCalled(); $this->create(); }
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(); }
/** * {@inheritdoc} */ public function specifyPriceForChannelAndCurrency($price, ChannelInterface $channel, CurrencyInterface $currency) { $calculatorElement = $this->getElement('calculator'); $calculatorElement->waitFor(5, function () use($channel, $currency) { return $this->getElement('calculator')->hasField(sprintf('%s %s', $channel->getName(), $currency->getCode())); }); $calculatorElement->fillField(sprintf('%s %s', $channel->getName(), $currency->getCode()), $price); }
function it_creates_query_builder_for_the_payment_method($em, QueryBuilder $builder, ChannelInterface $channel, ArrayCollection $paymentMethods, PaymentMethodInterface $paymentMethod) { $em->createQueryBuilder()->shouldBeCalled()->willReturn($builder); $builder->select('method')->shouldBeCalled()->willReturn($builder); $builder->from(Argument::any(), 'method', Argument::cetera())->shouldBeCalled()->willReturn($builder); $builder->andWhere('method IN (:methods)')->shouldBeCalled()->willReturn($builder); $channel->getPaymentMethods()->shouldBeCalled()->willReturn($paymentMethods); $paymentMethods->toArray()->shouldBeCalled()->willReturn(array($paymentMethod)); $builder->setParameter('methods', array($paymentMethod))->shouldBeCalled()->willReturn($builder); $this->getQueryBuidlerForChoiceType(array('channel' => $channel, 'disabled' => true))->shouldReturn($builder); }
function it_creates_france_country_and_zone($channelRepository, $zoneMemberRepository, $zoneRepository, $channelFactory, $zoneMemberFactory, $zoneFactory, ZoneMemberInterface $zoneMember, ZoneInterface $zone, ChannelInterface $channel) { $channel->getName()->willReturn('France'); $channelFactory->createNamed('France')->willReturn($channel); $zoneMemberFactory->createNew()->willReturn($zoneMember); $zoneFactory->createNew()->willReturn($zone); $channel->setCode('WEB-FR')->shouldBeCalled(); $zoneMember->setCode('FR')->shouldBeCalled(); $zone->setCode('FR')->shouldBeCalled(); $zone->setName('France')->shouldBeCalled(); $zone->setType(ZoneInterface::TYPE_COUNTRY)->shouldBeCalled(); $zone->addMember($zoneMember)->shouldBeCalled(); $channelRepository->add($channel)->shouldBeCalled(); $zoneRepository->add($zone)->shouldBeCalled(); $zoneMemberRepository->add($zoneMember)->shouldBeCalled(); $this->create(); }
/** * @Given /^the store has "([^"]+)" shipping method with ("[^"]+") fee per unit for ("[^"]+" channel) and ("[^"]+") for ("[^"]+" channel)$/ */ public function storeHasShippingMethodWithFeePerUnitForChannels($shippingMethodName, $firstFee, ChannelInterface $firstChannel, $secondFee, ChannelInterface $secondChannel) { $configuration = []; $configuration[$firstChannel->getCode()] = ['amount' => $firstFee]; $configuration[$secondChannel->getCode()] = ['amount' => $secondFee]; $this->createShippingMethod($shippingMethodName, null, null, null, 'en', $configuration, DefaultCalculators::PER_UNIT_RATE, true, false, [$firstChannel, $secondChannel]); }
/** * @param ChannelInterface $channel * @param bool $state */ private function assertChannelState(ChannelInterface $channel, $state) { $this->iWantToBrowseChannels(); Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $channel->getName(), 'enabled' => $state]), sprintf('Channel with name %s and state %s has not been found.', $channel->getName(), $state)); }
/** * @When I change my current channel to :channel */ public function iChangeMyCurrentChannelTo(ChannelInterface $channel) { $this->prepareSessionIfNeeded(); $this->minkSession->setCookie('_channel_code', $channel->getCode()); }
/** * @param ChannelInterface $channel * @param bool $state */ private function changeChannelState(ChannelInterface $channel, $state) { $channel->setEnabled($state); $this->channelManager->flush(); $this->sharedStorage->set('channel', $channel); }
/** * @Given /^(that channel)(?: also|) allows to shop using the "([^"]+)" currency$/ * @Given /^(that channel)(?: also|) allows to shop using "([^"]+)" and "([^"]+)" currencies$/ * @Given /^(that channel)(?: also|) allows to shop using "([^"]+)", "([^"]+)" and "([^"]+)" currencies$/ */ public function thatChannelAllowsToShopUsingAndCurrencies(ChannelInterface $channel, ...$currenciesCodes) { foreach ($currenciesCodes as $currencyCode) { $channel->addCurrency($this->provideCurrency($currencyCode)); } $this->channelManager->flush(); }
private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null, $taxonomyNames = null) { if ($shippingMethodNames) { $shippingMethodNames = array_map('trim', explode(',', $shippingMethodNames)); foreach ($shippingMethodNames as $shippingMethodName) { $shippingMethod = $shippingMethods = $this->getRepository('shipping_method')->findOneBy(array('name' => $shippingMethodName)); $channel->addShippingMethod($shippingMethod); } } if ($paymentMethodNames) { $paymentMethodNames = array_map('trim', explode(',', $paymentMethodNames)); $paymentMethods = $this->getRepository('payment_method')->findBy(array('name' => $paymentMethodNames)); foreach ($paymentMethods as $paymentMethod) { $channel->addPaymentMethod($paymentMethod); } } if ($localeCodes) { $localeCodes = array_map('trim', explode(',', $localeCodes)); $locales = $this->getRepository('locale')->findBy(array('code' => $localeCodes)); foreach ($locales as $locale) { $channel->addLocale($locale); } } if ($currencyCodes) { $currencyCodes = array_map('trim', explode(',', $currencyCodes)); $currencies = $this->getRepository('currency')->findBy(array('code' => $currencyCodes)); foreach ($currencies as $currency) { $channel->addCurrency($currency); } } if ($taxonomyNames) { $taxonomyNames = array_map('trim', explode(',', $taxonomyNames)); foreach ($taxonomyNames as $taxonomyName) { $taxonomy = $this->getRepository('taxonomy')->findOneBy(array('name' => $taxonomyName)); $channel->addTaxonomy($taxonomy); } } }
/** * @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()); }
/** * @Given /^(it) uses the "([^"]+)" locale by default$/ */ public function itUsesTheLocaleByDefault(ChannelInterface $channel, $localeName) { $locale = $this->provideLocale($this->localeConverter->convertNameToCode($localeName)); $this->localeManager->flush(); $channel->addLocale($locale); $channel->setDefaultLocale($locale); $this->channelManager->flush(); }
/** * @Given channel :channel does not use any theme */ public function channelDoesNotUseAnyTheme(ChannelInterface $channel) { $channel->setThemeName(null); $this->channelManager->flush(); $this->sharedStorage->set('channel', $channel); }
/** * @param PromotionInterface $promotion * @param int $discount * @param array $configuration * @param PromotionRuleInterface|null $rule * @param ChannelInterface|null $channel */ private function createFixedPromotion(PromotionInterface $promotion, $discount, array $configuration = [], PromotionRuleInterface $rule = null, ChannelInterface $channel = null) { $channelCode = null !== $channel ? $channel->getCode() : $this->sharedStorage->get('channel')->getCode(); $this->persistPromotion($promotion, $this->actionFactory->createFixedDiscount($discount, $channelCode), $configuration, $rule); }
/** * @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()); }
/** * @Given /^(that channel)(?: also|) allows to shop using the "([^"]+)" currency with exchange rate ([0-9\.]+)$/ */ public function thatChannelAllowsToShopUsingCurrency(ChannelInterface $channel, $currencyCode, $exchangeRate = 1.0) { $currency = $this->createCurrency($currencyCode, $exchangeRate); $channel->addCurrency($currency); $this->saveCurrency($currency); $this->channelManager->flush(); }
/** * {@inheritdoc} */ public function getPricingConfigurationForChannelAndCurrencyCalculator(ChannelInterface $channel, CurrencyInterface $currency) { $priceConfigurationElement = $this->getElement('pricing_configuration'); $priceElement = $priceConfigurationElement->find('css', sprintf('label:contains("%s %s")', $channel->getCode(), $currency->getCode()))->getParent(); return $priceElement->find('css', 'input')->getValue(); }
/** * @Given /^(it) uses the "([^"]+)" currency by default$/ */ public function itUsesTheCurrencyByDefault(ChannelInterface $channel, $currencyCode) { $currency = $this->provideCurrency($currencyCode); $currency->setExchangeRate(1.0); $this->currencyManager->flush(); $channel->addCurrency($currency); $channel->setDefaultCurrency($currency); $this->channelManager->flush(); }
/** * @param ChannelInterface $channel * @param string $configuration * @param array $data * * @return FormInterface */ private function createConfigurationFieldForChannel(ChannelInterface $channel, $configuration, array $data) { $config = ['auto_initialize' => false, 'label' => $channel->getName(), 'currency' => $channel->getBaseCurrency()->getCode()]; $data = empty($data) ? $data : $data[$channel->getCode()]; return $this->factory->createNamed($channel->getCode(), $configuration, $data, $config); }
/** * @Given /^(it) has price ("[^"]+") for ("[^"]+" channel) and "([^"]+)" currency$/ */ public function itHasPriceForChannelAndCurrency(ProductInterface $product, $price, ChannelInterface $channel, $currency) { /** @var ProductVariantInterface $variant */ $variant = $this->defaultVariantResolver->getVariant($product); $pricingConfiguration = $variant->getPricingConfiguration(); $pricingConfiguration[$channel->getCode()][$currency] = $price; $variant->setPricingConfiguration($pricingConfiguration); $this->objectManager->flush(); }
/** * {@inheritdoc} */ public function findEnabledForChannel(ChannelInterface $channel) { return $this->createQueryBuilder('o')->where('o.enabled = true')->andWhere('o IN (:channelShippingMethods)')->setParameter('channelShippingMethods', $channel->getShippingMethods()->toArray())->getQuery()->getResult(); }
/** * @Given /^the store has "([^"]+)" shipping method with ("[^"]+") fee per unit for ("[^"]+" channel) and ("[^"]+") for ("[^"]+" channel)$/ */ public function storeHasShippingMethodWithFeePerUnitForChannels($shippingMethodName, $firstFee, ChannelInterface $firstChannel, $secondFee, ChannelInterface $secondChannel) { $configuration = []; $configuration[$firstChannel->getCode()] = ['amount' => $firstFee]; $configuration[$secondChannel->getCode()] = ['amount' => $secondFee]; $this->saveShippingMethod($this->shippingMethodExampleFactory->create(['name' => $shippingMethodName, 'enabled' => true, 'calculator' => ['type' => DefaultCalculators::PER_UNIT_RATE, 'configuration' => $configuration], 'channels' => [$firstChannel, $secondChannel]])); }