/**
  * Login customer and open Order page.
  *
  * @param Customer $customer
  * @return void
  */
 protected function loginCustomerAndOpenOrderPage(Customer $customer)
 {
     $this->cmsIndex->open();
     $loginCustomerOnFrontendStep = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]);
     $loginCustomerOnFrontendStep->run();
     $this->cmsIndex->getLinksBlock()->openLink('My Account');
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
 }
Пример #2
0
 /**
  * Create Customer account on Storefront.
  *
  * @param Customer $customer
  * @param CustomerAccountIndex $customerAccountIndex
  */
 public function test(Customer $customer, CustomerAccountIndex $customerAccountIndex)
 {
     // Steps
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Account Information');
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
 }
 /**
  * Runs Delete Customer Address test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     // Precondition:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
     // Steps:
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
 /**
  * Runs Delete Customer Address test.
  *
  * @param Customer $customer
  * @return array
  */
 public function test(Customer $customer)
 {
     $this->markTestIncomplete('Bug: MAGETWO-34634');
     // Precondition:
     $customer->persist();
     $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[1];
     // Steps:
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink("Log In");
     $this->customerAccountLogin->getLoginBlock()->login($customer);
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $this->customerAccountIndex->getAdditionalAddressBlock()->deleteAdditionalAddress($addressToDelete);
     return ['deletedAddress' => $addressToDelete];
 }
 /**
  * @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];
 }
 /**
  * Asserts that Asserts that 'Additional Address Entries' contains expected message
  *
  * @param CustomerAccountIndex $customerAccountIndex
  * @return void
  */
 public function processAssert(CustomerAccountIndex $customerAccountIndex)
 {
     $customerAccountIndex->open();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $actualText = $customerAccountIndex->getAdditionalAddressBlock()->getBlockText();
     \PHPUnit_Framework_Assert::assertTrue(self::EXPECTED_MESSAGE == $actualText, 'Expected text is absent in Additional Address block.');
 }
 /**
  * Asserts that Default Billing Address and Default Shipping Address equal to data from fixture.
  *
  * @param CustomerAccountIndex $customerAccountIndex
  * @param CustomerAccountAddress $customerAccountAddress
  * @param Address $address
  * @return void
  */
 public function processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAccountAddress $customerAccountAddress, Address $address)
 {
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $addressRenderer = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $address, 'type' => 'html']);
     $addressToVerify = $addressRenderer->render();
     \PHPUnit_Framework_Assert::assertTrue($addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultBillingAddress() && $addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultShippingAddress(), 'Customer default address on address book tab is not matching the fixture.');
 }
 /**
  * Assert order is not visible in customer account on frontend
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status)
 {
     $filter = ['id' => $order->getId(), 'status' => $status];
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     \PHPUnit_Framework_Assert::assertFalse($orderHistory->getOrderHistoryBlock()->isVisible() && $orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . implode(', ', $filter) . '\' is present in Orders block on frontend.');
 }
 /**
  * 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.');
 }
 /**
  * Asserts that Default Billing Address and Default Shipping Address equal to data from fixture
  *
  * @param CustomerAccountIndex $customerAccountIndex
  * @param AddressInjectable $address
  * @return void
  */
 public function processAssert(CustomerAccountIndex $customerAccountIndex, AddressInjectable $address)
 {
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Account Dashboard');
     $defaultBillingAddress = explode("\n", $customerAccountIndex->getDashboardAddress()->getDefaultBillingAddressText());
     $defaultShippingAddress = explode("\n", $customerAccountIndex->getDashboardAddress()->getDefaultShippingAddressText());
     $pattern = $this->makeAddressPattern($address);
     $billingDataDiff = $this->verifyForm($pattern, $defaultBillingAddress);
     $shippingDataDiff = $this->verifyForm($pattern, $defaultShippingAddress);
     $dataDiff = array_merge($billingDataDiff, $shippingDataDiff);
     \PHPUnit_Framework_Assert::assertEmpty($dataDiff, 'Billing or shipping form was filled incorrectly.' . "\nLog:\n" . implode(";\n", $dataDiff));
 }
 /**
  * Asserts that deleted address is not present on Frontend.
  *
  * @param CustomerAccountIndex $customerAccountIndex
  * @param CustomerAddressEdit $customerAddressEdit
  * @param Customer $customer
  * @param Address $addressToDelete
  * @return void
  */
 public function processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAddressEdit $customerAddressEdit, Customer $customer, Address $addressToDelete)
 {
     $this->objectManager->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book');
     $addressRenderer = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addressToDelete, 'type' => 'html']);
     $deletedAddress = $addressRenderer->render();
     $isAddressDeleted = false;
     if ($customerAddressEdit->getEditForm()->isVisible() || $customerAccountIndex->getAdditionalAddressBlock()->getBlockText() !== null && $deletedAddress != $customerAccountIndex->getAdditionalAddressBlock()->getBlockText() || $customerAccountIndex->getDefaultAddressBlock()->getBlockText() !== null && $deletedAddress != $customerAccountIndex->getAdditionalAddressBlock()->getBlockText()) {
         $isAddressDeleted = true;
     }
     \PHPUnit_Framework_Assert::assertTrue($isAddressDeleted, 'Customer address was not deleted.');
 }
 /**
  * Open Downloadable Link.
  *
  * @param OrderInjectable $order
  * @param int $downloads
  * @return void
  */
 protected function openDownloadableLink(OrderInjectable $order, $downloads)
 {
     $customerLogin = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()]);
     $customerLogin->run();
     $this->customerAccount->getAccountMenuBlock()->openMenuItem('My Downloadable Products');
     $downloadableProductsUrl = $this->browser->getUrl();
     foreach ($order->getEntityId()['products'] as $product) {
         foreach ($product->getDownloadableLinks()['downloadable']['link'] as $link) {
             for ($i = 0; $i < $downloads; $i++) {
                 $this->browser->open($this->customerProducts->getMainBlock()->getLinkUrl($link['title']));
                 $this->browser->open($downloadableProductsUrl);
             }
         }
     }
 }
 /**
  * Assert that product is present in default wishlist
  *
  * @param CmsIndex $cmsIndex
  * @param CustomerAccountIndex $customerAccountIndex
  * @param WishlistIndex $wishlistIndex
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CustomerAccountIndex $customerAccountIndex, WishlistIndex $wishlistIndex, InjectableFixture $product)
 {
     $cmsIndex->getLinksBlock()->openLink('My Account');
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
     \PHPUnit_Framework_Assert::assertTrue($wishlistIndex->getItemsBlock()->getItemProduct($product)->isVisible(), $product->getName() . ' is not visible on wishlist page.');
 }
 /**
  * Assert that login again to frontend with new password was success.
  *
  * @param FixtureFactory $fixtureFactory
  * @param CustomerAccountIndex $customerAccountIndex
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, CustomerAccountIndex $customerAccountIndex, Customer $initialCustomer, Customer $customer)
 {
     $customer = $fixtureFactory->createByCode('customer', ['dataset' => 'default', 'data' => ['email' => $initialCustomer->getEmail(), 'password' => $customer->getPassword(), 'password_confirmation' => $customer->getPassword()]]);
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     \PHPUnit_Framework_Assert::assertTrue($customerAccountIndex->getAccountMenuBlock()->isVisible(), 'Customer Account Dashboard is not visible.');
 }