作者:ReissClothin
项目:Syliu
/**
* @Then /^an email with shipment's details of (this order) should be sent to "([^"]+)"$/
*/
public function anEmailWithShipmentDetailsOfOrderShouldBeSentTo(OrderInterface $order, $recipient)
{
$this->assertEmailContainsMessageTo($order->getNumber(), $recipient);
$this->assertEmailContainsMessageTo($order->getLastShipment()->getMethod()->getName(), $recipient);
$tracking = $this->sharedStorage->get('tracking_code');
$this->assertEmailContainsMessageTo($tracking, $recipient);
}
作者:origamm
项目:Syliu
/**
* @Given /^I am logged in as "([^"]+)" administrator$/
*/
public function iAmLoggedInAsAdministrator($email)
{
$user = $this->userRepository->findOneByEmail($email);
Assert::notNull($user);
$this->securityService->logIn($user);
$this->sharedStorage->set('admin', $user);
}
作者:syliu
项目:syliu
/**
* @Given I am a logged in customer
*/
public function iAmLoggedInCustomer()
{
$user = $this->userFactory->create(['email' => 'sylius@example.com', 'password' => 'sylius', 'enabled' => true]);
$this->userRepository->add($user);
$this->securityService->logIn($user);
$this->sharedStorage->set('user', $user);
}
作者:loic42
项目:Syliu
/**
* @Given the store has static content :title with name :name
*/
public function theStoreHasStaticContentWithName($title, $name)
{
$staticContent = $this->staticContentExampleFactory->create(['title' => $title, 'name' => $name]);
$this->staticContentManager->persist($staticContent);
$this->staticContentManager->flush();
$this->sharedStorage->set('static_content', $staticContent);
}
作者:ReissClothin
项目:Syliu
/**
* @Given there is an administrator with name :username
*/
public function thereIsAnAdministratorWithName($username)
{
$adminUser = $this->userFactory->create(['username' => $username]);
$adminUser->setUsername($username);
$this->userRepository->add($adminUser);
$this->sharedStorage->set('administrator', $adminUser);
}
作者:ReissClothin
项目:Syliu
/**
* @Given I am a logged in customer
*/
public function iAmLoggedInCustomer()
{
$user = $this->userFactory->create();
$this->userRepository->add($user);
$this->securityService->logIn($user);
$this->sharedStorage->set('user', $user);
}
作者:TeamNovate
项目:Syliu
/**
* @Given I am logged in as an administrator
*/
public function iAmLoggedInAsAnAdministrator()
{
$admin = $this->testUserFactory->createDefaultAdmin();
$this->userRepository->add($admin);
$this->securityService->logIn($admin->getEmail());
$this->sharedStorage->set('admin', $admin);
}
作者:ReissClothin
项目:Syliu
/**
* @Given the store has route :name with :contentTitle as its content
*/
public function theStoreHasRouteWithAsItsContent($name, $contentTitle)
{
$content = $this->staticContentRepository->findOneBy(['title' => $contentTitle]);
$route = $this->routeExampleFactory->create(['name' => $name, 'content' => $content]);
$this->routeManager->persist($route);
$this->routeManager->flush();
$this->sharedStorage->set('route', $route);
}
作者:ReissClothin
项目:Syliu
/**
* @When I set :channel channel theme to :theme
*/
public function iSetChannelThemeTo(ChannelInterface $channel, ThemeInterface $theme)
{
$this->channelUpdatePage->open(['id' => $channel->getId()]);
$this->channelUpdatePage->setTheme($theme);
$this->channelUpdatePage->saveChanges();
$this->sharedStorage->set('channel', $channel);
$this->sharedStorage->set('theme', $theme);
}
作者:ReissClothin
项目:Syliu
/**
* @Given the store has a product option :productOptionName with a code :productOptionCode
*/
public function theStoreHasAProductOptionWithACode($productOptionName, $productOptionCode)
{
$productOption = $this->productOptionFactory->createNew();
$productOption->setCode($productOptionCode);
$productOption->setName($productOptionName);
$this->sharedStorage->set('product_option', $productOption);
$this->productOptionRepository->add($productOption);
}
作者:TheMadelein
项目:Syliu
/**
* @param string $name
*/
private function createCustomerGroup($name)
{
/** @var CustomerGroupInterface $customerGroup */
$customerGroup = $this->customerGroupFactory->createNew();
$customerGroup->setName(ucfirst($name));
$this->sharedStorage->set('customer_group', $customerGroup);
$this->customerGroupRepository->add($customerGroup);
}
作者:ReissClothin
项目:Syliu
/**
* @When I create a new channel :channelName
*/
public function iCreateNewChannel($channelName)
{
$this->channelCreatePage->open();
$this->channelCreatePage->nameIt($channelName);
$this->channelCreatePage->specifyCode($channelName);
$this->channelCreatePage->create();
$channel = $this->channelRepository->findOneBy(['name' => $channelName]);
$this->sharedStorage->set('channel', $channel);
}
作者:ReissClothin
项目:Syliu
/**
* @param string $type
* @param string $name
* @param string|null $code
*/
private function createProductAttribute($type, $name, $code = null)
{
$productAttribute = $this->productAttributeFactory->createTyped($type);
if (null === $code) {
$code = str_replace(' ', '_', strtoupper($name));
}
$productAttribute->setCode($code);
$productAttribute->setName($name);
$this->productAttributeRepository->add($productAttribute);
$this->sharedStorage->set('product_attribute', $productAttribute);
}
作者:loic42
项目:Syliu
/**
* @param string $type
* @param string $name
* @param string|null $code
*/
private function createProductAttribute($type, $name, $code = null)
{
$productAttribute = $this->productAttributeFactory->createTyped($type);
if (null === $code) {
$code = StringInflector::nameToUppercaseCode($name);
}
$productAttribute->setCode($code);
$productAttribute->setName($name);
$this->productAttributeRepository->add($productAttribute);
$this->sharedStorage->set('product_attribute', $productAttribute);
}
作者:Niik
项目:Syliu
/**
* @param string $shippingCategoryName
* @param string $shippingCategoryCode
*/
private function createShippingCategory($shippingCategoryName, $shippingCategoryCode = null)
{
/** @var ShippingCategoryInterface $shippingCategory */
$shippingCategory = $this->shippingCategoryFactory->createNew();
$shippingCategory->setName($shippingCategoryName);
$shippingCategory->setCode($shippingCategoryCode);
if (null === $shippingCategoryCode) {
$shippingCategory->setCode(StringInflector::nameToCode($shippingCategoryName));
}
$this->shippingCategoryRepository->add($shippingCategory);
$this->sharedStorage->set('shipping_category', $shippingCategory);
}
作者:loic42
项目:Syliu
/**
* @param string $name
* @param string|null $code
* @param int|null $position
* @param ZoneInterface|null $zone
* @param string $locale
* @param array $configuration
* @param string $calculator
* @param bool $enabled
* @param bool $addForCurrentChannel
*/
private function createShippingMethod($name, $code = null, $position = null, ZoneInterface $zone = null, $locale = 'en', $configuration = ['amount' => 0], $calculator = DefaultCalculators::FLAT_RATE, $enabled = true, $addForCurrentChannel = true)
{
if (null === $zone) {
$zone = $this->sharedStorage->get('zone');
}
if (null === $code) {
$code = $this->generateCodeFromNameAndZone($name, $zone->getCode());
}
/** @var ShippingMethodInterface $shippingMethod */
$shippingMethod = $this->shippingMethodFactory->createNew();
$shippingMethod->setCode($code);
$shippingMethod->setName($name);
$shippingMethod->setPosition($position);
$shippingMethod->setCurrentLocale($locale);
$shippingMethod->setConfiguration($configuration);
$shippingMethod->setCalculator($calculator);
$shippingMethod->setZone($zone);
$shippingMethod->setEnabled($enabled);
if ($addForCurrentChannel && $this->sharedStorage->has('channel')) {
$channel = $this->sharedStorage->get('channel');
$channel->addShippingMethod($shippingMethod);
}
$this->shippingMethodRepository->add($shippingMethod);
$this->sharedStorage->set('shipping_method', $shippingMethod);
}
作者:Niik
项目:Syliu
/**
* @param string $name
* @param string|null $code
* @param int|null $position
* @param ZoneInterface|null $zone
* @param string $locale
* @param array $configuration
* @param string $calculator
* @param bool $enabled
* @param bool $addForCurrentChannel
* @param array $channels
*
* @return ShippingMethodInterface
*/
private function createShippingMethod($name, $code = null, $position = null, ZoneInterface $zone = null, $locale = 'en', array $configuration = [], $calculator = DefaultCalculators::FLAT_RATE, $enabled = true, $addForCurrentChannel = true, array $channels = [])
{
$channel = $this->sharedStorage->get('channel');
if (null === $zone) {
$zone = $this->sharedStorage->get('zone');
}
if (null === $code) {
$code = $this->generateCodeFromNameAndZone($name, $zone->getCode());
}
if (empty($configuration)) {
$configuration = $this->getConfigurationByChannels([$channel]);
}
/** @var ShippingMethodInterface $shippingMethod */
$shippingMethod = $this->shippingMethodFactory->createNew();
$shippingMethod->setCode($code);
$shippingMethod->setName($name);
$shippingMethod->setPosition($position);
$shippingMethod->setCurrentLocale($locale);
$shippingMethod->setConfiguration($configuration);
$shippingMethod->setCalculator($calculator);
$shippingMethod->setZone($zone);
$shippingMethod->setEnabled($enabled);
if ($addForCurrentChannel && $channel) {
$shippingMethod->addChannel($channel);
}
if (!$addForCurrentChannel) {
foreach ($channels as $channel) {
$shippingMethod->addChannel($channel);
}
}
$this->shippingMethodRepository->add($shippingMethod);
$this->sharedStorage->set('shipping_method', $shippingMethod);
return $shippingMethod;
}
作者:ReissClothin
项目:Syliu
/**
* @param UserInterface $user
*/
private function prepareUserVerification(UserInterface $user)
{
$token = 'marryhadalittlelamb';
$this->sharedStorage->set('verification_token', $token);
$user->setEmailVerificationToken($token);
$this->userManager->flush();
}
作者:TheMadelein
项目:Syliu
/**
* @param string $element
* @param string $message
*/
private function assertValidationMessage($element, $message)
{
$product = $this->sharedStorage->has('product') ? $this->sharedStorage->get('product') : null;
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createSimpleProductPage, $this->createConfigurableProductPage, $this->updateSimpleProductPage, $this->updateConfigurableProductPage], $product);
Assert::same($currentPage->getValidationMessage($element), $message);
}
作者:syliu
项目:syliu
/**
* @Then /^(this product) should have(?:| also) an image with a code "([^"]*)"$/
* @Then /^the (product "[^"]+") should have(?:| also) an image with a code "([^"]*)"$/
*/
public function thisProductShouldHaveAnImageWithCode(ProductInterface $product, $code)
{
$this->sharedStorage->set('product', $product);
/** @var UpdateSimpleProductPageInterface|UpdateConfigurableProductPageInterface $currentPage */
$currentPage = $this->resolveCurrentPage();
Assert::true($currentPage->isImageWithCodeDisplayed($code), sprintf('Image with a code %s should have been displayed.', $code));
}