/**
  * Run step that selecting checkout method.
  *
  * @return void
  * @throws \Exception
  */
 public function run()
 {
     $checkoutMethodBlock = $this->checkoutOnepage->getLoginBlock();
     switch ($this->checkoutMethod) {
         case 'guest':
             $checkoutMethodBlock->clickContinue();
             break;
         case 'login':
             $checkoutMethodBlock->loginCustomer($this->customer);
             break;
         default:
             throw new \Exception("Undefined checkout method.");
             break;
     }
 }
 /**
  * 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()->guestCheckout();
     $checkoutOnepage->getLoginBlock()->clickContinue();
     $checkoutOnepage->getBillingBlock()->fill($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
     $checkoutOnepage->getShippingMethodBlock()->clickContinue();
     $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod($payment);
     $checkoutOnepage->getPaymentMethodsBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
 }
 /**
  * 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()->guestCheckout();
     $checkoutOnepage->getLoginBlock()->clickContinue();
     $checkoutOnepage->getBillingBlock()->fill($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
     $checkoutOnepage->getShippingMethodBlock()->clickContinue();
     $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod($payment);
     $checkoutOnepage->getPaymentMethodsBlock()->clickContinue();
     $checkoutOnepage->getAgreementReview()->placeOrder();
     \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);
 }
 /**
  * Run step that selecting checkout method.
  *
  * @return void
  */
 public function run()
 {
     if ($this->checkoutMethod === 'login') {
         $this->checkoutOnepage->getLoginBlock()->loginCustomer($this->customer);
     }
 }