作者:TheMadelein
项目:Syliu
function it_executes_request(InvoiceNumberGeneratorInterface $invoiceNumberGenerator, CurrencyConverterInterface $currencyConverter, Convert $request, PaymentInterface $payment, OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ProductInterface $product)
{
$request->getTo()->willReturn('array');
$payment->getId()->willReturn(19);
$order->getId()->willReturn(92);
$order->getId()->willReturn(92);
$order->getCurrencyCode()->willReturn('PLN');
$order->getTotal()->willReturn(22000);
$order->getItems()->willReturn([$orderItem]);
$order->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(0);
$order->getOrderPromotionTotal()->willReturn(0);
$order->getShippingTotal()->willReturn(2000);
$orderItem->getVariant()->willReturn($productVariant);
$orderItem->getDiscountedUnitPrice()->willReturn(20000);
$orderItem->getQuantity()->willReturn(1);
$productVariant->getProduct()->willReturn($product);
$product->getName()->willReturn('Lamborghini Aventador Model');
$request->getSource()->willReturn($payment);
$payment->getOrder()->willReturn($order);
$invoiceNumberGenerator->generate($order, $payment)->willReturn('19-92');
$currencyConverter->convertFromBase(22000, 'PLN')->willReturn(88000);
$currencyConverter->convertFromBase(20000, 'PLN')->willReturn(80000);
$currencyConverter->convertFromBase(2000, 'PLN')->willReturn(8000);
$details = ['PAYMENTREQUEST_0_INVNUM' => '19-92', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'PLN', 'PAYMENTREQUEST_0_AMT' => 880.0, 'PAYMENTREQUEST_0_ITEMAMT' => 880.0, 'L_PAYMENTREQUEST_0_NAME0' => 'Lamborghini Aventador Model', 'L_PAYMENTREQUEST_0_AMT0' => 800.0, 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_NAME1' => 'Shipping Total', 'L_PAYMENTREQUEST_0_AMT1' => 80.0, 'L_PAYMENTREQUEST_0_QTY1' => 1];
$request->setResult($details)->shouldBeCalled();
$this->execute($request);
}
作者:ahmadrabi
项目:Syliu
function it_returns_regular_price_of_discount_order_item(OrderItemInterface $orderItem)
{
$orderItem->getQuantity()->willReturn(2);
$orderItem->getUnitPrice()->willReturn(1000);
$orderItem->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(1000);
$this->getRegularPrice($orderItem)->shouldReturn(3000);
}
作者:TheMadelein
项目:Syliu
function it_filters_items_which_has_product_with_price_equal_to_configured_minimum_criteria(OrderItemInterface $item1, OrderItemInterface $item2, ProductVariantInterface $item1Variant, ProductVariantInterface $item2Variant)
{
$item1->getVariant()->willReturn($item1Variant);
$item2->getVariant()->willReturn($item2Variant);
$item1Variant->getPrice()->willReturn(500);
$item2Variant->getPrice()->willReturn(1000);
$this->filter([$item1, $item2], ['filters' => ['price_range' => ['min' => 1000]]])->shouldReturn([$item2]);
}
作者:syliu
项目:cor
function it_filters_passed_order_items_with_given_configuration(OrderItemInterface $item1, OrderItemInterface $item2, ProductInterface $product1, ProductInterface $product2)
{
$item1->getProduct()->willReturn($product1);
$product1->getCode()->willReturn('product1');
$item2->getProduct()->willReturn($product2);
$product2->getCode()->willReturn('product2');
$this->filter([$item1, $item2], ['filters' => ['products_filter' => ['products' => ['product1']]]])->shouldReturn([$item1]);
}
作者:benakach
项目:Syliu
function it_does_nothing_if_target_quantity_is_below_0($orderItemUnitFactory, OrderItemInterface $orderItem)
{
$orderItem->getQuantity()->willReturn(3);
$orderItemUnitFactory->createForItem(Argument::any())->shouldNotBeCalled();
$orderItem->addUnit(Argument::any())->shouldNotBeCalled();
$orderItem->removeUnit(Argument::any())->shouldNotBeCalled();
$this->modify($orderItem, -10);
}
作者:syliu
项目:cor
function it_filters_items_which_has_product_with_price_equal_to_configured_minimum_criteria(ChannelInterface $channel, OrderItemInterface $item1, OrderItemInterface $item2, ProductVariantInterface $item1Variant, ProductVariantInterface $item2Variant, ProductVariantPriceCalculatorInterface $productVariantPriceCalculator)
{
$item1->getVariant()->willReturn($item1Variant);
$item2->getVariant()->willReturn($item2Variant);
$productVariantPriceCalculator->calculate($item1Variant, ['channel' => $channel])->willReturn(500);
$productVariantPriceCalculator->calculate($item2Variant, ['channel' => $channel])->willReturn(1000);
$this->filter([$item1, $item2], ['filters' => ['price_range_filter' => ['min' => 1000]], 'channel' => $channel])->shouldReturn([$item2]);
}
作者:loic42
项目:Syliu
function it_recognizes_a_subject_as_not_eligible_if_a_product_taxon_is_not_matched(OrderInterface $subject, OrderItemInterface $item, ProductInterface $reflexBow, TaxonInterface $bows)
{
$configuration = ['taxons' => ['swords', 'axes']];
$bows->getCode()->willReturn('bows');
$reflexBow->getTaxons()->willReturn([$bows]);
$item->getProduct()->willReturn($reflexBow);
$subject->getItems()->willReturn([$item]);
$this->isEligible($subject, $configuration)->shouldReturn(false);
}
作者:loic42
项目:Syliu
function it_returns_false_if_product_is_wrong(OrderInterface $subject, OrderItemInterface $firstOrderItem, OrderItemInterface $secondOrderItem, ProductInterface $shaft, ProductInterface $head)
{
$subject->getItems()->willReturn([$firstOrderItem, $secondOrderItem]);
$firstOrderItem->getProduct()->willReturn($head);
$secondOrderItem->getProduct()->willReturn($shaft);
$head->getCode()->willReturn('LACROSSE_HEAD');
$shaft->getCode()->willReturn('LACROSSE_SHAFT');
$this->isEligible($subject, ['product_code' => 'LACROSSE_STRING'])->shouldReturn(false);
}
作者:vikey8
项目:Syliu
function it_should_recognize_subject_as_not_eligible_if_product_taxonomy_is_matched_and_exclude_is_set(OrderInterface $subject, OrderItemInterface $item, Taxon $taxon, Product $product, ArrayCollection $collection)
{
$configuration = ['taxons' => $collection, 'exclude' => true];
$collection->contains(2)->willReturn(true);
$taxon->getId()->willReturn(2);
$product->getTaxons()->willReturn([$taxon]);
$item->getProduct()->willReturn($product);
$subject->getItems()->willReturn([$item]);
$this->isEligible($subject, $configuration)->shouldReturn(false);
}
作者:stevedie
项目:Syliu
/**
* @param OrderItemInterface $item
* @param array $configuration
*
* @return bool
*/
private function isItemEligible(OrderItemInterface $item, array $configuration)
{
if (!$configuration['exclude']) {
if (isset($configuration['count'])) {
return $this->isItemQuantityEligible($item->getQuantity(), $configuration);
}
return true;
}
return false;
}
作者:ReissClothin
项目:Syliu
function it_throws_exception_when_recalculated_on_hand_quantity_is_lower_than_zero(OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant)
{
$order->getItems()->willReturn([$orderItem]);
$orderItem->getQuantity()->willReturn(5);
$orderItem->getVariant()->willReturn($productVariant);
$productVariant->isTracked()->willReturn(true);
$productVariant->getOnHand()->willReturn(4);
$productVariant->getName()->willReturn('Variant');
$this->shouldThrow(\InvalidArgumentException::class)->during('decrease', [$order]);
}
作者:ahmadrabi
项目:Syliu
/**
* @param OrderItemInterface $item
* @param array $distributedAmounts
* @param PromotionInterface $promotion
*/
private function setUnitsAdjustments(OrderItemInterface $item, array $distributedAmounts, PromotionInterface $promotion)
{
$i = 0;
foreach ($item->getUnits() as $unit) {
if (0 === $distributedAmounts[$i]) {
break;
}
$this->addAdjustmentToUnit($unit, $distributedAmounts[$i], $promotion);
$i++;
}
}
作者:loic42
项目:Syliu
function it_does_not_process_taxes_if_there_is_no_tax_zone(ZoneProviderInterface $defaultTaxZoneProvider, ZoneMatcherInterface $zoneMatcher, PrioritizedServiceRegistryInterface $strategyRegistry, OrderInterface $order, OrderItemInterface $orderItem, AddressInterface $address)
{
$order->getItems()->willReturn([$orderItem]);
$order->isEmpty()->willReturn(false);
$order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
$orderItem->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled();
$order->getShippingAddress()->willReturn($address);
$zoneMatcher->match($address)->willReturn(null);
$defaultTaxZoneProvider->getZone($order)->willReturn(null);
$strategyRegistry->all()->shouldNotBeCalled();
$this->process($order);
}
作者:ReissClothin
项目:Syliu
/**
* @param OrderItemInterface $item
* @param PromotionInterface $promotion
* @param int $itemPromotionAmount
*/
private function applyAdjustmentsOnItemUnits(OrderItemInterface $item, PromotionInterface $promotion, $itemPromotionAmount)
{
$splitPromotionAmount = $this->distributor->distribute($itemPromotionAmount, $item->getQuantity());
$i = 0;
foreach ($item->getUnits() as $unit) {
$promotionAmount = $splitPromotionAmount[$i++];
if (0 === $promotionAmount) {
continue;
}
$this->addAdjustment($promotion, $unit, $promotionAmount);
}
}
作者:TheMadelein
项目:Syliu
function it_does_not_recognize_a_subject_as_eligible_if_items_from_required_taxon_has_too_low_total(TaxonRepositoryInterface $taxonRepository, OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows)
{
$order->getItems()->willReturn([$compositeBowItem, $longswordItem]);
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getTotal()->willReturn(5000);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getTotal()->willReturn(4000);
$this->isEligible($order, ['taxon' => 'bows', 'amount' => 10000])->shouldReturn(false);
}
作者:TheMadelein
项目:Syliu
function it_recalculates_prices_without_adding_anything_to_the_context_if_its_not_needed(DelegatingCalculatorInterface $priceCalculator, OrderInterface $order, OrderItemInterface $item, PriceableInterface $variant)
{
$order->getCustomer()->willReturn(null);
$order->getChannel()->willReturn(null);
$order->getItems()->willReturn([$item]);
$item->isImmutable()->willReturn(false);
$item->getQuantity()->willReturn(5);
$item->getVariant()->willReturn($variant);
$priceCalculator->calculate($variant, ['quantity' => 5])->willReturn(10);
$item->setUnitPrice(10)->shouldBeCalled();
$this->process($order);
}
作者:okwinz
项目:Syliu
function it_reverts_order_units_order_promotion_adjustments(AdjustmentInterface $firstAdjustment, AdjustmentInterface $secondAdjustment, OrderInterface $order, OrderItemInterface $item, OrderItemUnitInterface $unit, OriginatorInterface $originator, PromotionInterface $otherPromotion, PromotionInterface $promotion)
{
$order->countItems()->willReturn(1);
$order->getItems()->willReturn(new \ArrayIterator([$item->getWrappedObject()]));
$item->getUnits()->willReturn(new \ArrayIterator([$unit->getWrappedObject()]));
$unit->getAdjustments(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn(new \ArrayIterator([$firstAdjustment->getWrappedObject(), $secondAdjustment->getWrappedObject()]));
$originator->getOrigin($firstAdjustment)->willReturn($promotion);
$originator->getOrigin($secondAdjustment)->willReturn($otherPromotion);
$unit->removeAdjustment($firstAdjustment)->shouldBeCalled();
$unit->removeAdjustment($secondAdjustment)->shouldNotBeCalled();
$this->revert($order, [], $promotion);
}
作者:loic42
项目:Syliu
function it_does_not_check_an_item_if_its_product_has_no_required_taxon(OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows, TaxonRepositoryInterface $taxonRepository)
{
$order->getItems()->willReturn(new \ArrayIterator([$compositeBowItem->getWrappedObject(), $longswordItem->getWrappedObject()]));
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getQuantity()->willReturn(4);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getQuantity()->shouldNotBeCalled();
$this->isEligible($order, ['taxon' => 'bows', 'count' => 5])->shouldReturn(false);
}
作者:TheMadelein
项目:Syliu
function it_reverts_order_units_order_promotion_adjustments(AdjustmentInterface $firstAdjustment, AdjustmentInterface $secondAdjustment, OrderInterface $order, OrderItemInterface $item, OrderItemUnitInterface $unit, PromotionInterface $promotion)
{
$order->countItems()->willReturn(1);
$order->getItems()->willReturn([$item]);
$item->getUnits()->willReturn([$unit]);
$unit->getAdjustments(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->willReturn([$firstAdjustment, $secondAdjustment]);
$promotion->getCode()->willReturn('PROMOTION');
$firstAdjustment->getOriginCode()->willReturn('PROMOTION');
$secondAdjustment->getOriginCode()->willReturn('OTHER_PROMOTION');
$unit->removeAdjustment($firstAdjustment)->shouldBeCalled();
$unit->removeAdjustment($secondAdjustment)->shouldNotBeCalled();
$this->revert($order, [], $promotion);
}
作者:okwinz
项目:Syliu
function it_reverts_proper_promotion_adjustment_from_all_units($originator, AdjustmentInterface $promotionAdjustment1, AdjustmentInterface $promotionAdjustment2, Collection $items, Collection $units, Collection $adjustments, OrderInterface $order, OrderItemInterface $orderItem, OrderItemUnitInterface $unit, PromotionInterface $promotion, PromotionInterface $someOtherPromotion)
{
$order->getItems()->willReturn($items);
$items->getIterator()->willReturn(new \ArrayIterator([$orderItem->getWrappedObject()]));
$orderItem->getUnits()->willReturn($units);
$units->getIterator()->willReturn(new \ArrayIterator([$unit->getWrappedObject()]));
$unit->getAdjustments(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->willReturn($adjustments);
$adjustments->getIterator()->willReturn(new \ArrayIterator([$promotionAdjustment1->getWrappedObject(), $promotionAdjustment2->getWrappedObject()]));
$originator->getOrigin($promotionAdjustment1)->willReturn($promotion);
$unit->removeAdjustment($promotionAdjustment1)->shouldBeCalled();
$originator->getOrigin($promotionAdjustment2)->willReturn($someOtherPromotion);
$unit->removeAdjustment($promotionAdjustment2)->shouldNotBeCalled();
$this->revert($order, ['percentage' => 0.2], $promotion);
}