function its_price_is_mutable(VariantInterface $masterVariant) { $masterVariant->setPrice(499)->shouldBeCalled(); $masterVariant->getPrice()->willReturn(499); $this->setPrice(499); $this->getPrice()->shouldReturn(499); }
function it_should_inherit_price_from_master_variant(ProductVariantInterface $masterVariant) { $masterVariant->isMaster()->willReturn(true); $masterVariant->getAvailableOn()->willReturn(new \DateTime('yesterday')); $masterVariant->getPrice()->willReturn(499); $this->setDefaults($masterVariant); $this->getPrice()->shouldReturn(499); }
/** * @param ProductVariantInterface $variant * @param array $priceRange * * @return bool */ private function isItemVariantInPriceRange(ProductVariantInterface $variant, array $priceRange) { $price = $variant->getPrice(); if (isset($priceRange['min']) && isset($priceRange['max'])) { return $priceRange['min'] <= $price && $priceRange['max'] >= $price; } return $priceRange['min'] <= $price; }
/** * @param ProductVariantInterface $variant * * @return array */ private function constructOptionsMap(ProductVariantInterface $variant) { $optionMap = []; /** @var ProductOptionValueInterface $option */ foreach ($variant->getOptionValues() as $option) { $optionMap[$option->getOptionCode()] = $option->getValue(); } $optionMap['value'] = $variant->getPrice(); return $optionMap; }
function it_provides_array_containing_product_variant_options_map_with_corresponding_price(ProductInterface $tShirt, ProductOptionValueInterface $black, ProductOptionValueInterface $large, ProductOptionValueInterface $small, ProductOptionValueInterface $white, ProductVariantInterface $blackLargeTShirt, ProductVariantInterface $blackSmallTShirt, ProductVariantInterface $whiteLargeTShirt, ProductVariantInterface $whiteSmallTShirt) { $tShirt->getVariants()->willReturn([$blackSmallTShirt, $whiteSmallTShirt, $blackLargeTShirt, $whiteLargeTShirt]); $blackSmallTShirt->getOptionValues()->willReturn([$black, $small]); $whiteSmallTShirt->getOptionValues()->willReturn([$white, $small]); $blackLargeTShirt->getOptionValues()->willReturn([$black, $large]); $whiteLargeTShirt->getOptionValues()->willReturn([$white, $large]); $blackSmallTShirt->getPrice()->willReturn(1000); $whiteSmallTShirt->getPrice()->willReturn(1500); $blackLargeTShirt->getPrice()->willReturn(2000); $whiteLargeTShirt->getPrice()->willReturn(2500); $black->getOptionCode()->willReturn('t_shirt_color'); $white->getOptionCode()->willReturn('t_shirt_color'); $small->getOptionCode()->willReturn('t_shirt_size'); $large->getOptionCode()->willReturn('t_shirt_size'); $black->getValue()->willReturn('Black'); $white->getValue()->willReturn('White'); $small->getValue()->willReturn('Small'); $large->getValue()->willReturn('Large'); $this->provideVariantsPrices($tShirt)->shouldReturn([['t_shirt_color' => 'Black', 't_shirt_size' => 'Small', 'value' => 1000], ['t_shirt_color' => 'White', 't_shirt_size' => 'Small', 'value' => 1500], ['t_shirt_color' => 'Black', 't_shirt_size' => 'Large', 'value' => 2000], ['t_shirt_color' => 'White', 't_shirt_size' => 'Large', 'value' => 2500]]); }
function it_returns_a_first_variants_price_as_product_price(VariantInterface $variant) { $variant->getPrice()->willReturn(1000); $this->addVariant($variant); $this->getPrice()->shouldReturn(1000); }
function it_adds_single_product_variant_as_item_by_customer(FactoryInterface $orderItemFactory, OrderInterface $order, OrderItemInterface $item, OrderItemQuantityModifierInterface $itemQuantityModifier, SharedStorageInterface $sharedStorage, ProductVariantInterface $variant, ObjectManager $objectManager) { $sharedStorage->get('order')->willReturn($order); $orderItemFactory->createNew()->willReturn($item); $variant->getPrice()->willReturn(1234); $itemQuantityModifier->modify($item, 1)->shouldBeCalled(); $item->setVariant($variant)->shouldBeCalled(); $item->setUnitPrice(1234)->shouldBeCalled(); $order->addItem($item)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->theCustomerBoughtSingleProductVariant($variant); }