作者:TeamNovate
项目:Syliu
function it_generates_correct_hierarchy_when_product_does_not_have_archetype(ProductInterface $product)
{
$product->getMetadataIdentifier()->shouldBeCalled()->willReturn('Product-42');
$product->getMetadataClassIdentifier()->shouldBeCalled()->willReturn('Product');
$product->getArchetype()->shouldBeCalled()->willReturn(null);
$this->getHierarchyByMetadataSubject($product)->shouldReturn(['Product-42', 'Product', 'DefaultPage']);
}
作者:Moza
项目:Syliu
/**
* {@inheritdoc}
*/
public function isThereProduct(ProductInterface $product)
{
if (!($table = $this->getDocument()->find('css', 'table'))) {
return false;
}
$row = $this->tableManipulator->getRowWithFields($table, ['id' => $product->getId()]);
return null === $row;
}
作者:Strontium-9
项目:Syliu
function it_is_restricted_if_zone_matcher_match_customers_shipping_address(ProductInterface $product, $customerContext, $zoneMatcher, CustomerInterface $customer, AddressInterface $address, ProductInterface $product, ZoneInterface $zone)
{
$customerContext->getCustomer()->shouldBeCalled()->willReturn($customer);
$customer->getShippingAddress()->shouldBeCalled()->willReturn($address);
$product->getRestrictedZone()->shouldBeCalled()->willReturn($zone);
$zoneMatcher->matchAll($address)->shouldBeCalled()->willReturn(array($zone));
$this->isRestricted($product)->shouldReturn(true);
}
作者: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);
}
作者:gabiudresc
项目:Syliu
/**
* {@inheritdoc}
*/
public function provideVariantsPrices(ProductInterface $product)
{
$variantsPrices = [];
/** @var ProductVariantInterface $variant */
foreach ($product->getVariants() as $variant) {
$variantsPrices[] = $this->constructOptionsMap($variant);
}
return $variantsPrices;
}
作者:TheMadelein
项目:Syliu
/**
* @param ProductInterface $product
* @param array $taxons
*
* @return bool
*/
private function hasProductValidTaxon(ProductInterface $product, array $taxons)
{
foreach ($product->getTaxons() as $taxon) {
if (in_array($taxon->getCode(), $taxons)) {
return true;
}
}
return false;
}
作者:ReissClothin
项目:Syliu
/**
* @When /^I delete the ("[^"]+" product)$/
* @When /^I try to delete the ("([^"]+)" product)$/
*/
public function iDeleteTheProduct(ProductInterface $product)
{
try {
$this->sharedStorage->set('product_id', $product->getId());
$this->productRepository->remove($product);
} catch (DBALException $exception) {
$this->sharedStorage->set('last_exception', $exception);
}
}
作者:bcreme
项目:Syliu
function it_is_restricted_if_zone_matcher_match_users_shipping_address(ProductInterface $product, $securityContext, $zoneMatcher, TokenInterface $token, UserInterface $user, AddressInterface $address, ProductInterface $product, ZoneInterface $zone)
{
$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')->shouldBeCalled()->willReturn(true);
$securityContext->getToken()->shouldBeCalled()->willReturn($token);
$token->getUser()->shouldBeCalled()->willReturn($user);
$user->getShippingAddress()->shouldBeCalled()->willReturn($address);
$product->getRestrictedZone()->shouldBeCalled()->willReturn($zone);
$zoneMatcher->matchAll($address)->shouldBeCalled()->willReturn(array($zone));
$this->isRestricted($product)->shouldReturn(true);
}
作者:starspir
项目:eventmanage
function it_adds_single_item_by_customer(FactoryInterface $orderItemFactory, OrderInterface $order, OrderItemInterface $item, OrderItemQuantityModifierInterface $itemQuantityModifier, ProductInterface $product, SharedStorageInterface $sharedStorage, ProductVariantInterface $variant, ObjectManager $objectManager)
{
$sharedStorage->get('order')->willReturn($order);
$orderItemFactory->createNew()->willReturn($item);
$product->getMasterVariant()->willReturn($variant);
$product->getPrice()->willReturn(1234);
$itemQuantityModifier->modify($item, 1)->shouldBeCalled();
$item->setVariant($variant)->shouldBeCalled();
$item->setUnitPrice(1234)->shouldBeCalled();
$order->addItem($item)->shouldBeCalled();
$objectManager->flush()->shouldBeCalled();
$this->theCustomerBoughtSingle($product);
}
作者:TheMadelein
项目:Syliu
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]]);
}
作者:dominikjagl
项目:Syliu
/**
* @param ProductInterface $product
* @param array $data
*/
private function configureProductPricingCalculator(ProductInterface $product, array $data)
{
$product->getMasterVariant()->setPricingCalculator($data['pricing calculator']);
if (!isset($data['calculator configuration']) || '' === $data['calculator configuration']) {
throw new \InvalidArgumentException('You must set chosen calculator configuration');
}
$product->getMasterVariant()->setPricingConfiguration($this->getPricingCalculatorConfiguration($data));
}
作者:syliu
项目:syliu
/**
* @Then /^average rating of (product "[^"]+") should be (\d+)$/
*/
public function thisProductAverageRatingShouldBe(ProductInterface $product, $averageRating)
{
$this->showPage->tryToOpen(['slug' => $product->getSlug()]);
$this->iShouldSeeAsItsAverageRating($averageRating);
}
作者:origamm
项目:Syliu
/**
* @param ProductInterface $product
* @param int $quantity
*/
private function setProductsQuantity(ProductInterface $product, $quantity)
{
$product->getFirstVariant()->setOnHand($quantity);
$this->saveProduct($product);
}
作者:ahmadrabi
项目:Syliu
function it_adds_taxon_to_product(ProductInterface $product, TaxonInterface $taxon)
{
$product->addTaxon($taxon)->shouldBeCalled();
$this->itBelongsTo($product, $taxon);
}
作者:vikey8
项目:Syliu
protected function addTranslatedFields(ProductInterface $product, $translatedNames)
{
foreach ($translatedNames as $locale => $name) {
$product->setCurrentLocale($locale);
$product->setFallbackLocale($locale);
$product->setName($name);
$product->setDescription($this->fakers[$locale]->paragraph);
$product->setShortDescription($this->fakers[$locale]->sentence);
$product->setMetaKeywords(str_replace(' ', ', ', $this->fakers[$locale]->sentence));
$product->setMetaDescription($this->fakers[$locale]->sentence);
}
$product->setCurrentLocale($this->defaultLocale);
}
作者:syliu
项目:syliu
/**
* @Then /^(this product) should no longer have price for channel "([^"]+)"$/
*/
public function thisProductShouldNoLongerHavePriceForChannel(ProductInterface $product, $channelName)
{
$this->updateSimpleProductPage->open(['id' => $product->getId()]);
try {
$this->updateSimpleProductPage->getPriceForChannel($channelName);
} catch (ElementNotFoundException $exception) {
return;
}
throw new \Exception(sprintf('Product "%s" should not have price defined for channel "%s".', $product->getName(), $channelName));
}
作者:okwinz
项目:Syliu
/**
* @Given /^(this product) has (this product option)$/
* @Given /^(this product) has a ("[^"]+" option)$/
* @Given /^(this product) has an ("[^"]+" option)$/
*/
public function thisProductHasThisProductOption(ProductInterface $product, OptionInterface $option)
{
$product->addOption($option);
$this->objectManager->flush();
}
作者:loic42
项目:Syliu
/**
* @param ProductInterface $product
* @param array $options
*/
private function createImages(ProductInterface $product, array $options)
{
foreach ($options['images'] as $imageCode => $imagePath) {
/** @var ImageInterface $productImage */
$productImage = $this->productImageFactory->createNew();
$productImage->setCode($imageCode);
$productImage->setFile(new UploadedFile($imagePath, basename($imagePath)));
$this->imageUploader->upload($productImage);
$product->addImage($productImage);
}
}
作者:loic42
项目:Syliu
/**
* @Given I want to review product :product
*/
public function iWantToReviewProduct(ProductInterface $product)
{
$this->createPage->open(['slug' => $product->getSlug()]);
}
作者:Moza
项目:Syliu
/**
* @Given /^(it) (belongs to "[^"]+")$/
*/
public function itBelongsTo(ProductInterface $product, TaxonInterface $taxon)
{
$product->addTaxon($taxon);
$this->objectManager->flush($product);
}