作者:TheMadelein
项目:Syliu
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();
}
作者:ReissClothin
项目:Syliu
function it_creates_a_cart_item_and_assigns_a_product_variant(FactoryInterface $decoratedFactory, VariantResolverInterface $variantResolver, OrderItemInterface $cartItem, ProductInterface $product, ProductVariantInterface $productVariant)
{
$decoratedFactory->createNew()->willReturn($cartItem);
$variantResolver->getVariant($product)->willReturn($productVariant);
$cartItem->setVariant($productVariant)->shouldBeCalled();
$this->createForProduct($product)->shouldReturn($cartItem);
}
作者:gabiudresc
项目:Syliu
function it_calls_proper_factory_methods_based_on_configuration(RequestConfiguration $requestConfiguration, FactoryInterface $factory)
{
$requestConfiguration->getFactoryMethod()->willReturn('createNew');
$requestConfiguration->getFactoryArguments()->willReturn(['00032']);
$factory->createNew('00032')->willReturn(['foo', 'bar']);
$this->create($requestConfiguration, $factory)->shouldReturn(['foo', 'bar']);
}
作者:alehers
项目:Syliu
function it_calls_proper_method_with_arguments_based_on_configuration_when_creating_resource(FactoryInterface $factory, $configuration)
{
$configuration->getFactoryMethod('createNew')->willReturn('createNew');
$configuration->getFactoryArguments(array())->willReturn(array());
$factory->createNew()->willReturn(array('foo', 'bar'));
$this->createResource($factory, 'createNew')->shouldReturn(array('foo', 'bar'));
}
作者:ReissClothin
项目:Syliu
function it_creates_a_nth_order_rule(FactoryInterface $decoratedFactory, RuleInterface $rule)
{
$decoratedFactory->createNew()->willReturn($rule);
$rule->setType(NthOrderRuleChecker::TYPE)->shouldBeCalled();
$rule->setConfiguration(['nth' => 10])->shouldBeCalled();
$this->createNthOrder(10)->shouldReturn($rule);
}
作者:vikey8
项目:Syliu
function it_creates_a_taxon_and_assigns_a_taxonomy_to_id(FactoryInterface $factory, RepositoryInterface $taxonomyRepository, TaxonomyInterface $taxonomy, TaxonInterface $taxon)
{
$factory->createNew()->willReturn($taxon);
$taxonomyRepository->find(13)->willReturn($taxonomy);
$taxon->setTaxonomy($taxonomy)->shouldBeCalled();
$this->createForTaxonomy(13)->shouldReturn($taxon);
}
作者:syliu
项目:cor
function it_creates_a_contains_product_rule(FactoryInterface $decoratedFactory, PromotionRuleInterface $rule)
{
$decoratedFactory->createNew()->willReturn($rule);
$rule->setType(ContainsProductRuleChecker::TYPE)->shouldBeCalled();
$rule->setConfiguration(['product_code' => 1])->shouldBeCalled();
$this->createContainsProduct(1)->shouldReturn($rule);
}
作者:syliu
项目:cor
function it_creates_a_shipping_percentage_discount_action_with_a_given_discount_rate(FactoryInterface $decoratedFactory, PromotionActionInterface $promotionAction)
{
$decoratedFactory->createNew()->willReturn($promotionAction);
$promotionAction->setType(ShippingPercentageDiscountPromotionActionCommand::TYPE)->shouldBeCalled();
$promotionAction->setConfiguration(['percentage' => 0.1])->shouldBeCalled();
$this->createShippingPercentageDiscount(0.1)->shouldReturn($promotionAction);
}
作者:ahmadrabi
项目:Syliu
function it_creates_payment_with_currency_and_amout(FactoryInterface $paymentFactory, PaymentInterface $payment)
{
$paymentFactory->createNew()->willReturn($payment);
$payment->setAmount(1234)->shouldBeCalled();
$payment->setCurrency('EUR')->shouldBeCalled();
$this->createWithAmountAndCurrency(1234, 'EUR');
}
作者:loic42
项目:Syliu
function it_creates_a_review_with_subject_and_reviewer(FactoryInterface $factory, ReviewableInterface $subject, ReviewInterface $review, ReviewerInterface $reviewer)
{
$factory->createNew()->willReturn($review);
$review->setReviewSubject($subject)->shouldBeCalled();
$review->setAuthor($reviewer)->shouldBeCalled();
$this->createForSubjectWithReviewer($subject, $reviewer);
}
作者:TheMadelein
项目:Syliu
function it_creates_new_product_with_variant(FactoryInterface $factory, FactoryInterface $variantFactory, ProductInterface $product, ProductVariantInterface $variant)
{
$variantFactory->createNew()->willReturn($variant);
$factory->createNew()->willReturn($product);
$product->addVariant($variant)->shouldBeCalled();
$this->createWithVariant()->shouldReturn($product);
}
作者:malukenh
项目:Syliu
function it_creates_new_taxonomy_with_root(TaxonInterface $taxon, TaxonomyInterface $taxonomy, FactoryInterface $taxonFactory, TranslatableFactoryInterface $translatableFactory)
{
$taxonFactory->createNew()->shouldBeCalled()->willReturn($taxon);
$translatableFactory->createNew()->shouldBeCalled()->willReturn($taxonomy);
$taxonomy->setRoot($taxon)->shouldBeCalled();
$this->createNew()->shouldReturn($taxonomy);
}
作者:Mangets
项目:Syliu
function it_creates_a_variant_and_assigns_a_product_to_id(FactoryInterface $factory, RepositoryInterface $productRepository, ProductInterface $product, VariantInterface $variant)
{
$factory->createNew()->willReturn($variant);
$productRepository->find(13)->willReturn($product);
$variant->setProduct($product)->shouldBeCalled();
$this->createForProduct(13)->shouldReturn($variant);
}
作者:loic42
项目:Syliu
function it_applies_percentage_discount_on_every_unit_in_order(FactoryInterface $adjustmentFactory, FilterInterface $priceRangeFilter, FilterInterface $taxonFilter, FilterInterface $productFilter, AdjustmentInterface $promotionAdjustment1, AdjustmentInterface $promotionAdjustment2, Collection $originalItems, Collection $units, OrderInterface $order, OrderItemInterface $orderItem1, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2, PromotionInterface $promotion)
{
$order->getItems()->willReturn($originalItems);
$originalItems->toArray()->willReturn([$orderItem1]);
$priceRangeFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$taxonFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$productFilter->filter([$orderItem1], ['percentage' => 0.2])->willReturn([$orderItem1]);
$orderItem1->getQuantity()->willReturn(2);
$orderItem1->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit1->getWrappedObject(), $unit2->getWrappedObject()]));
$orderItem1->getUnitPrice()->willReturn(500);
$promotion->getName()->willReturn('Test promotion');
$promotion->getCode()->willReturn('TEST_PROMOTION');
$adjustmentFactory->createNew()->willReturn($promotionAdjustment1, $promotionAdjustment2);
$promotionAdjustment1->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment1->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment1->setAmount(-100)->shouldBeCalled();
$promotionAdjustment1->setOriginCode('TEST_PROMOTION')->shouldBeCalled();
$promotionAdjustment2->setType(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldBeCalled();
$promotionAdjustment2->setLabel('Test promotion')->shouldBeCalled();
$promotionAdjustment2->setAmount(-100)->shouldBeCalled();
$promotionAdjustment2->setOriginCode('TEST_PROMOTION')->shouldBeCalled();
$unit1->addAdjustment($promotionAdjustment1)->shouldBeCalled();
$unit2->addAdjustment($promotionAdjustment2)->shouldBeCalled();
$this->execute($order, ['percentage' => 0.2], $promotion);
}
作者:ahmadrabi
项目:Syliu
function it_creates_a_coupon_and_assigns_a_promotion_to_id(FactoryInterface $factory, PromotionRepositoryInterface $promotionRepository, PromotionInterface $promotion, CouponInterface $coupon)
{
$factory->createNew()->willReturn($coupon);
$promotionRepository->find(13)->willReturn($promotion);
$coupon->setPromotion($promotion)->shouldBeCalled();
$this->createForPromotion(13)->shouldReturn($coupon);
}
作者:stevedie
项目:Syliu
/**
* @param string $name
*/
private function createCountryNamed($name)
{
/** @var CountryInterface $country */
$country = $this->countryFactory->createNew();
$country->setCode($this->getCountryCodeByEnglishCountryName($name));
$this->countryRepository->add($country);
}
作者:Moza
项目:Syliu
/**
* @param string $name
*
* @return TaxonInterface
*/
private function createTaxon($name)
{
$taxon = $this->taxonFactory->createNew();
$taxon->setName($name);
$taxon->setCode($this->getCodeFromName($name));
return $taxon;
}
作者:alehers
项目:Syliu
/**
* {@inheritdoc}
*/
public function generate(VariableInterface $variable)
{
if (!$variable->hasOptions()) {
throw new \InvalidArgumentException('Cannot generate variants for an object without options.');
}
$optionSet = array();
$optionMap = array();
foreach ($variable->getOptions() as $k => $option) {
foreach ($option->getValues() as $value) {
$optionSet[$k][] = $value->getId();
$optionMap[$value->getId()] = $value;
}
}
$permutations = $this->setBuilder->build($optionSet);
foreach ($permutations as $permutation) {
$variant = $this->variantFactory->createNew();
$variant->setObject($variable);
$variant->setDefaults($variable->getMasterVariant());
if (is_array($permutation)) {
foreach ($permutation as $id) {
$variant->addOption($optionMap[$id]);
}
} else {
$variant->addOption($optionMap[$permutation]);
}
$variable->addVariant($variant);
$this->process($variable, $variant);
}
}
作者:ReissClothin
项目:Syliu
/**
* {@inheritdoc}
*/
public function createNew()
{
/** @var Route $route */
$route = $this->decoratedFactory->createNew();
$route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
return $route;
}
作者:ReissClothin
项目:Syliu
/**
* {@inheritdoc}
*/
public function createForPromotion(PromotionInterface $promotion)
{
Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
$coupon = $this->factory->createNew();
$coupon->setPromotion($promotion);
return $coupon;
}