Exemplo n.º 1
0
 /**
  * Create customer.
  *
  * @return array
  */
 public function run()
 {
     if ($this->persistCustomer == 'yes') {
         $this->customer->persist();
     }
     return ['customer' => $this->customer];
 }
 /**
  * Prepare data.
  *
  * @param FixtureFactory $fixtureFactory
  * @param Customer $customer
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory, Customer $customer)
 {
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product']);
     $product->persist();
     $customer->persist();
     return ['product' => $product, 'customer' => $customer];
 }
 /**
  * Run delete customer address entity test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     // Preconditions:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[0];
     // Steps:
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->customerAccountIndex->getAccountNavigationBlock()->openNavigationItem('Address Book');
     $this->customerAddress->getBookBlock()->getAdditionalAddressBlock()->deleteAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
 /**
  * Check that clicking "Place order" without setting checkbox for agreement will result in error message displayed
  * under condition.
  *
  * @param CheckoutMultishippingOverview $checkoutMultishippingOverview
  * @param TestStepFactory $stepFactory
  * @param Customer $customer
  * @param CheckoutAgreement $checkoutAgreement
  * @param string $products
  * @param array $payment
  * @param array $shippingData
  * @param array $fillItemsData
  * @param string $newAddresses
  * @return void
  */
 public function processAssert(CheckoutMultishippingOverview $checkoutMultishippingOverview, TestStepFactory $stepFactory, Customer $customer, CheckoutAgreement $checkoutAgreement, $products, array $payment, array $shippingData, array $fillItemsData, $newAddresses)
 {
     $this->stepFactory = $stepFactory;
     $customer->persist();
     $products = $this->createProducts($products);
     $this->login($customer);
     $this->addToCart($products);
     $this->startCheckout();
     $this->processCheckoutWithMultishipping($customer, $products, $fillItemsData, $shippingData, $payment, $newAddresses);
     $alertText = $checkoutMultishippingOverview->getOverviewBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $alertText, 'Notification required message of Terms and Conditions is absent.');
     $checkoutMultishippingOverview->getOverviewBlock()->setAgreement($checkoutAgreement, 'Yes');
     $checkoutMultishippingOverview->getOverviewBlock()->clickContinue();
 }
 /**
  * Assert that Gift Wrapping can be found during one page checkout on frontend.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param BrowserInterface $browser
  * @param CheckoutOnepage $checkoutOnepage
  * @param GiftWrapping $giftWrapping
  * @param Address $billingAddress
  * @param CatalogProductSimple $product
  * @param Customer $customer
  * @param CustomerAccountLogout $customerAccountLogout
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, BrowserInterface $browser, CheckoutOnepage $checkoutOnepage, GiftWrapping $giftWrapping, Address $billingAddress, CatalogProductSimple $product, Customer $customer, CustomerAccountLogout $customerAccountLogout)
 {
     // Preconditions
     $customer->persist();
     $product->persist();
     // Steps
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutCart->open()->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->loginCustomer($customer);
     $checkoutOnepage->getBillingBlock()->fillBilling($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertContains($giftWrapping->getDesign(), $checkoutOnepage->getGiftOptionsBlock()->getGiftWrappingsAvailable(), "Gift Wrapping '{$giftWrapping->getDesign()}' is not present in one page checkout on frontend.");
     $customerAccountLogout->open();
 }
 /**
  * Assert that product is displayed in cross-sell section for customer segment.
  *
  * @param Browser $browser
  * @param Customer $customer
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param InjectableFixture[] $promotedProducts
  * @return void
  */
 public function processAssert(Browser $browser, Customer $customer, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, CustomerAccountLogout $customerAccountLogout, array $promotedProducts)
 {
     // Create customer, logout and login to frontend
     $customer->persist();
     $customerAccountLogout->open();
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     // Clear cart
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     // Check display cross sell products
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $errors = [];
     foreach ($promotedProducts as $promotedProduct) {
         if (!$checkoutCart->getCrosssellBlock()->getItemBlock($promotedProduct)->isVisible()) {
             $errors[] = "Product '{$promotedProduct->getName()}' is absent in cross-sell section.";
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }
 /**
  * Prepare configuration and create customer.
  *
  * @param Customer $customer
  * @param CatalogCategory $category
  * @return array
  */
 public function __prepare(Customer $customer, CatalogCategory $category)
 {
     $customer->persist();
     $category->persist();
     return ['customer' => $customer, 'category' => $category];
 }
 /**
  * Injection data.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param FixtureFactory $fixtureFactory
  * @param WishlistIndex $wishlistIndex
  * @param ObjectManager $objectManager
  * @param Customer $customer
  * @return array
  */
 public function __inject(CmsIndex $cmsIndex, CatalogProductView $catalogProductView, FixtureFactory $fixtureFactory, WishlistIndex $wishlistIndex, ObjectManager $objectManager, Customer $customer)
 {
     $this->cmsIndex = $cmsIndex;
     $this->catalogProductView = $catalogProductView;
     $this->fixtureFactory = $fixtureFactory;
     $this->wishlistIndex = $wishlistIndex;
     $this->objectManager = $objectManager;
     $customer->persist();
     return ['customer' => $customer];
 }
 /**
  * Create customer.
  *
  * @param Customer $customer
  * @return array
  */
 public function __prepare(Customer $customer)
 {
     $customer->persist();
     return ['customer' => $customer];
 }
 /**
  * Run Change customer password test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @return void
  */
 public function test(Customer $initialCustomer, Customer $customer)
 {
     // Preconditions
     $initialCustomer->persist();
     // Steps
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run();
     $this->cmsIndex->getTopLinksBlock()->openAccount();
     $this->cmsIndex->getLinksBlock()->openLink('My Account');
     $this->customerAccountIndex->getInfoBlock()->openChangePassword();
     $this->customerAccountEdit->getAccountInfoForm()->fill($customer);
     $this->customerAccountEdit->getAccountInfoForm()->submit();
 }
 /**
  * Prepare data.
  *
  * @param FixtureFactory $fixtureFactory
  * @param Customer $customer
  * @param Browser $browser
  * @param AssertProductCompareSuccessAddMessage $assertProductCompareSuccessAddMessage
  * @return void
  */
 public function __prepare(FixtureFactory $fixtureFactory, Customer $customer, Browser $browser, AssertProductCompareSuccessAddMessage $assertProductCompareSuccessAddMessage)
 {
     $this->fixtureFactory = $fixtureFactory;
     $this->browser = $browser;
     $this->assertProductCompareSuccessAddMessage = $assertProductCompareSuccessAddMessage;
     $customer->persist();
     $this->customer = $customer;
 }
 /**
  * Create customer and 2 simple products with categories before run test.
  *
  * @param FixtureFactory $fixtureFactory
  * @param Customer $customer
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory, Customer $customer)
 {
     $this->fixtureFactory = $fixtureFactory;
     $customer->persist();
     $products = $this->createProducts(['simple_for_salesrule_1', 'simple_for_salesrule_2']);
     return ['customer' => $customer, 'productForSalesRule1' => $products[0], 'productForSalesRule2' => $products[1]];
 }
 /**
  * Create customer and product.
  *
  * @param CatalogProductSimple $product
  * @param Customer $customer
  * @return array
  */
 public function __prepare(CatalogProductSimple $product, Customer $customer)
 {
     $product->persist();
     $customer->persist();
     return ['customer' => $customer, 'product' => $product];
 }
 /**
  * Run create customer segment test.
  *
  * @param Customer $customer
  * @param CustomerSegment $customerSegment
  * @param CustomerSegment $customerSegmentConditions
  * @param array $salesRule
  * @param Browser $browser
  * @return void
  */
 public function test(Customer $customer, CustomerSegment $customerSegment, CustomerSegment $customerSegmentConditions, array $salesRule, Browser $browser)
 {
     // Preconditions
     $customer->persist();
     $replacement = $this->prepareReplacement($customer);
     // Steps
     $this->customerSegmentIndex->open();
     $this->customerSegmentIndex->getPageActionsBlock()->addNew();
     $this->customerSegmentNew->getCustomerSegmentForm()->fill($customerSegment);
     $this->customerSegmentNew->getPageMainActions()->saveAndContinue();
     // Retrieve customer segment id
     preg_match('@id/(\\d+)/@', $browser->getUrl(), $matches);
     $customerSegmentId = $matches[1];
     $this->customerSegmentEdit->getCustomerSegmentForm()->openTab('conditions');
     $this->customerSegmentEdit->getCustomerSegmentForm()->fillForm($customerSegmentConditions, null, $replacement);
     $this->customerSegmentEdit->getPageMainActions()->save();
     $this->createCartPriceRule($salesRule, $customerSegmentId);
 }