示例#1
0
 /**
  * Apply set up configuration profile.
  *
  * @return void
  */
 public function apply()
 {
     parent::apply();
     if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) {
         $this->objectManager->create('\\Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->config])->run();
     }
 }
 /**
  * Fill customer addresses and proceed to next step.
  *
  * @return void
  */
 public function run()
 {
     $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
     $bindings = [];
     foreach ($this->products as $key => $product) {
         $productName = $product->getName();
         $addressRender = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addresses[$key], 'type' => 'oneline']);
         $bindings[$productName] = $addressRender->render();
     }
     $this->addresses->getAddressesBlock()->selectAddresses($bindings);
 }
 /**
  * Review order contents and place order.
  *
  * @return array
  */
 public function run()
 {
     $this->orderReviewExpress->getReviewBlock()->selectShippingMethod($this->shipping);
     foreach ($this->prices as $priceName => $value) {
         $assertName = 'Assert' . ucfirst($priceName) . 'OrderReview';
         $assert = $this->objectManager->create('Magento\\Checkout\\Test\\Constraint\\' . $assertName);
         $assert->processAssert($this->checkoutOnepage, $value);
     }
     $this->orderReviewExpress->getReviewBlock()->placeOrder();
     return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()];
 }
 /**
  * Run a Mtf application
  *
  * @param $applicationName
  * @param array $arguments
  * @return mixed
  * @throws \DomainException
  */
 public function run($applicationName, array $arguments = [])
 {
     try {
         if (!$this->_locator) {
             $locatorFactory = new \Magento\Mtf\ObjectManagerFactory();
             $this->_locator = $locatorFactory->create();
         }
         return $this->_locator->create($applicationName, $arguments)->launch();
     } catch (\Exception $exception) {
         $message = "Error happened during application run.\n";
         $message .= $exception->getMessage();
         throw new \DomainException($message);
     }
 }
 /**
  * @inheritdoc
  *
  * @return array
  */
 public function run()
 {
     $this->objectManager->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer])->run();
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards');
     $myCreditCardsBlock = $this->myCreditCardsPage->getCreditCardsBlock();
     $creditCardData = $this->creditCard->getData();
     $creditCardNumber = preg_grep('/([a-z]+)_number/', array_flip($creditCardData));
     $lastFourDigits = substr(key($creditCardNumber), -4, 4);
     $availableCreditCards = $myCreditCardsBlock->getCreditCards();
     if (key_exists($lastFourDigits, $availableCreditCards)) {
         $myCreditCardsBlock->deleteCreditCard($availableCreditCards[$lastFourDigits]);
     }
     $this->assertCreditCardDeletedMessage->processAssert($this->myCreditCardsPage);
     return ['deletedCreditCard' => $lastFourDigits];
 }
 /**
  * Process checkout.
  *
  * @param string $checkoutMethod
  * @param Address $billingAddress
  * @param array $shipping
  * @param array $payment
  * @return void
  */
 protected function processCheckout($checkoutMethod, Address $billingAddress, array $shipping, array $payment)
 {
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\SelectCheckoutMethodStep', ['checkoutMethod' => $checkoutMethod])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\FillBillingInformationStep', ['billingAddress' => $billingAddress])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\FillShippingMethodStep', ['shipping' => $shipping])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', ['payment' => $payment])->run();
 }
 /**
  * Assert order is not visible in customer account on frontend
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status)
 {
     $filter = ['id' => $order->getId(), 'status' => $status];
     $customerLogin = $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]);
     $customerLogin->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     \PHPUnit_Framework_Assert::assertFalse($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . implode(', ', $filter) . '\' is present in Orders block on frontend.');
 }
 /**
  * Create products.
  *
  * @param array $products
  * @return array
  */
 protected function createProducts(array $products)
 {
     $resultProduct = [];
     foreach ($products as $key => $product) {
         $resultProduct[$key] = $this->objectManager->create('Mage\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => implode(',', $product)])->run()['products'];
     }
     return $resultProduct;
 }
 /**
  * Assert that order is present in Orders grid on frontend.
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @param string $orderId
  * @param string|null $statusToCheck
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status, $orderId = '', $statusToCheck = null)
 {
     $filter = ['id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $statusToCheck === null ? $status : $statusToCheck];
     $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     $errorMessage = implode(', ', $filter);
     \PHPUnit_Framework_Assert::assertTrue($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . $errorMessage . '\' is absent in Orders block on frontend.');
 }
 /**
  * Review order contents and place order.
  *
  * @return array
  */
 public function run()
 {
     $this->orderReviewExpress->getReviewBlock()->selectShippingMethod($this->shipping);
     foreach ($this->prices as $priceName => $value) {
         $assertName = 'Assert' . ucfirst($priceName) . 'OrderReview';
         $assert = $this->objectManager->create('Magento\\Checkout\\Test\\Constraint\\' . $assertName);
         $assert->processAssert($this->checkoutOnepage, $value);
     }
     $this->orderReviewExpress->getReviewBlock()->placeOrder();
     $order = $this->fixtureFactory->createByCode('orderInjectable', ['data' => ['entity_id' => ['products' => $this->products]]]);
     return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), 'order' => $order];
 }
示例#11
0
 /**
  * Click delete customer address button.
  *
  * @param Address $addressToDelete
  * @return $this
  */
 public function deleteCustomerAddress(Address $addressToDelete)
 {
     $addressRenderer = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addressToDelete, 'type' => 'html']);
     $addressToDelete = $addressRenderer->render();
     $dataList = explode("\n", $addressToDelete);
     $dataList = implode("') and contains(.,'", $dataList);
     $this->_rootElement->find(sprintf($this->addressSelector, $dataList), Locator::SELECTOR_XPATH)->find($this->deleteAddress)->click();
     $element = $this->browser->find($this->confirmModal);
     /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
     $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]);
     $modal->acceptAlert();
     return $this;
 }
 /**
  * Place order and verify there is no checkbox Terms and Conditions.
  *
  * @param FixtureFactory $fixtureFactory
  * @param ObjectManager $objectManager
  * @param string $product
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutAgreement $agreement
  * @param array $shipping
  * @param array $payment
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutAgreement $agreement, $shipping, $payment)
 {
     $createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]);
     $product = $createProductsStep->run();
     $billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']);
     $browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCartButton();
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->clickContinue();
     $checkoutOnepage->getBillingBlock()->fill($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
     $checkoutOnepage->getShippingMethodBlock()->clickContinue();
     $checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment);
     \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
 }
示例#13
0
 /**
  * Set integration data to configuration file.
  *
  * @param Integration $integration
  * @return void
  */
 protected function setConfiguration(Integration $integration)
 {
     $fileConfig = MTF_BP . '/etc/config.xml';
     $dom = new \DOMDocument();
     if (!file_exists($fileConfig)) {
         copy(MTF_BP . '/etc/config.xml.dist', $fileConfig);
     }
     $dom->load($fileConfig);
     $webapiToken = (new \DOMXPath($dom))->query('//config/handler/webapi/token')->item(0);
     if ($webapiToken) {
         $webapiToken->nodeValue = $integration->getToken();
     } else {
         $webapi = (new \DOMXPath($dom))->query('//config/handler/webapi')->item(0);
         $webapi->appendChild($dom->createElement('token', $integration->getToken()));
     }
     $dom->save($fileConfig);
     $this->configuration = $this->objectManager->create('Magento\\Mtf\\Config\\DataInterface');
 }
 /**
  * Verify Terms and Conditions checkbox is absent on checkout page.
  *
  * @param ObjectManager $objectManager
  * @param $products
  * @param CheckoutOnepage $checkoutOnepage
  * @param $shipping
  * @param $payment
  * @param CheckoutAgreement $agreement
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(ObjectManager $objectManager, $products, CheckoutOnepage $checkoutOnepage, $shipping, $payment, CheckoutAgreement $agreement)
 {
     $shippingAddressData = ['shippingAddress' => ['dataSet' => 'US_address_1']];
     $productsData = ['products' => $products];
     $shippingMethodData = ['shipping' => $shipping];
     $paymentData = ['payment' => $payment];
     $products = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', $productsData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $products)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\ProceedToCheckoutStep')->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingAddressStep', $shippingAddressData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingMethodStep', $shippingMethodData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', $paymentData)->run();
     \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
 }
示例#15
0
 /**
  * Find element on the page
  *
  * @param string $selector
  * @param string $strategy
  * @param string $type = select|multiselect|checkbox|null OR custom class with full namespace
  * @param ElementInterface $context
  * @return ElementInterface
  * @throws \Exception
  */
 public function find($selector, $strategy = Locator::SELECTOR_CSS, $type = null, ElementInterface $context = null)
 {
     $locator = new Locator($selector, $strategy);
     $this->eventManager->dispatchEvent(['find'], [__METHOD__, $locator]);
     $className = 'Magento\\Mtf\\Client\\ElementInterface';
     if (null !== $type) {
         if (strpos($type, '\\') === false) {
             $type = ucfirst(strtolower($type));
             if (class_exists('Magento\\Mtf\\Client\\Element\\' . $type . 'Element')) {
                 $className = 'Magento\\Mtf\\Client\\Element\\' . $type . 'Element';
             }
         } else {
             if (!class_exists($type) && !interface_exists($type)) {
                 throw new \Exception(sprintf('Requested interface or class "%s" does not exists!', $type));
             }
             $className = $type;
         }
     }
     return $this->objectManager->create($className, ['driver' => $this, 'locator' => $locator, 'context' => $context]);
 }
示例#16
0
 /**
  * Check that checkbox is present on the last checkout step - Order Review.
  * Check that after Place order without click on checkbox "Terms and Conditions" order was not successfully placed.
  * Check that after clicking on "Terms and Conditions" checkbox and "Place Order" button success place order message
  * appears.
  *
  * @param FixtureFactory $fixtureFactory
  * @param ObjectManager $objectManager
  * @param string $product
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
  * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage
  * @param array $shipping
  * @param array $payment
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, $shipping, $payment)
 {
     $createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]);
     $product = $createProductsStep->run();
     $billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']);
     $browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCartButton();
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->clickContinue();
     $checkoutOnepage->getBillingBlock()->fill($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
     $checkoutOnepage->getShippingMethodBlock()->clickContinue();
     $checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment);
     $checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder();
     \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $checkoutOnepage->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.');
     $checkoutOnepage->getAgreementReview()->setAgreement('Yes');
     $checkoutOnepage->getAgreementReview()->placeOrder();
     $assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess);
 }
 /**
  * Check that checkbox is present on the last checkout step - Order Review.
  * Check that after Place order without click on checkbox "Terms and Conditions" order was not successfully placed.
  * Check that after clicking on "Terms and Conditions" checkbox and "Place Order" button success place order message
  * appears.
  *
  * @param ObjectManager $objectManager
  * @param string $products
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
  * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage
  * @param array $shipping
  * @param array $payment
  * @param CheckoutAgreement $agreement
  * @return void
  */
 public function processAssert(ObjectManager $objectManager, $products, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, $shipping, $payment, CheckoutAgreement $agreement)
 {
     $paymentBlock = $checkoutOnepage->getPaymentBlock();
     $shippingAddressData = ['shippingAddress' => ['dataSet' => 'US_address_1']];
     $productsData = ['products' => $products];
     $shippingMethodData = ['shipping' => $shipping];
     $paymentData = ['payment' => $payment];
     $products = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', $productsData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $products)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\ProceedToCheckoutStep')->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingAddressStep', $shippingAddressData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingMethodStep', $shippingMethodData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', $paymentData)->run();
     $paymentBlock->getSelectedPaymentMethodBlock()->clickPlaceOrder();
     \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $checkoutOnepage->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.');
     $checkoutOnepage->getAgreementReview()->setAgreement('Yes', $agreement);
     $paymentBlock->getSelectedPaymentMethodBlock()->clickPlaceOrder();
     $assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess);
 }
 /**
  * Get sub step.
  *
  * @param string $subStepName
  * @return AbstractSubStep
  */
 protected function getSubStep($subStepName)
 {
     $class = 'Mage\\Catalog\\Test\\TestStep\\UpdateConfigurableProductStep\\' . ucfirst($subStepName) . 'SubStep';
     $arguments = ['product' => $this->product, 'configurableOptionsEditData' => $this->configurableOptionsEditData, 'currentAssignedProducts' => $this->currentAssignedProducts, 'currentAttributes' => $this->currentAttributes, 'currentConfigurableOptionsData' => $this->currentConfigurableOptionsData, 'checkoutData' => $this->checkoutData];
     return $this->objectManager->create($class, $arguments);
 }
示例#19
0
 /**
  * Prepare test suite and apply application state.
  *
  * @return AppState
  */
 public function prepareSuite()
 {
     $this->init();
     return $this->objectManager->create('Magento\\Mtf\\TestSuite\\AppState');
 }
示例#20
0
 /**
  * Create products.
  *
  * @param string $products
  * @return array
  */
 protected function createProducts($products)
 {
     return $this->objectManager->create('Mage\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $products])->run();
 }
 /**
  * Add products to wish list.
  *
  * @param array $products
  * @param bool $configure [optional]
  * @return void
  */
 protected function addToWishlist(array $products, $configure = false)
 {
     $this->objectManager->create('Magento\\Wishlist\\Test\\TestStep\\AddProductsToWishlistStep', ['products' => $products, 'configure' => $configure])->run();
 }
 /**
  * Add products to wish list.
  *
  * @param InjectableFixture|InjectableFixture[] $products
  * @param bool $configure [optional]
  * @return void
  */
 protected function addToWishlist($products, $configure = false)
 {
     $products = is_array($products) ? $products : [$products];
     $this->objectManager->create('Mage\\Wishlist\\Test\\TestStep\\AddProductsToWishlistStep', ['products' => $products, 'configure' => $configure])->run();
 }
 /**
  * Delete website.
  *
  * @return void
  */
 public function tearDown()
 {
     if (!empty($this->websiteName)) {
         $this->objectManager->create('Mage\\Adminhtml\\Test\\TestStep\\DeleteWebsiteStep', ['websitesNames' => [$this->websiteName]])->run();
     }
 }
 /**
  * Delete attribute after test.
  *
  * @return void
  */
 public function cleanup()
 {
     $this->objectManager->create('Magento\\Catalog\\Test\\TestStep\\DeleteAttributeStep', ['attribute' => $this->attribute])->run();
 }