Ejemplo n.º 1
0
 /**
  * Create customer
  *
  * @return array
  */
 public function run()
 {
     if ($this->persistCustomer) {
         $this->customer->persist();
     }
     return ['customer' => $this->customer];
 }
 /**
  * Mass assign customer group
  *
  * @param Customer $customer
  * @param CustomerGroup $customerGroup
  * @return void
  */
 public function test(Customer $customer, CustomerGroup $customerGroup)
 {
     // Steps
     $customerGroup->persist();
     $this->customerIndex->open();
     $this->customerIndex->getCustomerGridBlock()->massaction([['email' => $customer->getEmail()]], [$this->customersGridActions => $customerGroup->getCustomerGroupCode()]);
 }
 /**
  * Assertion that tier prices are displayed correctly for specified customer
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param FixtureInterface $product
  * @param Customer $customer
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product, Customer $customer)
 {
     $customer->persist();
     $this->loginCustomer($customer);
     $productTierPriceAssert = $this->objectManager->get('Magento\\Catalog\\Test\\Constraint\\AssertProductTierPriceOnProductPage');
     $productTierPriceAssert->processAssert($browser, $catalogProductView, $product);
 }
 /**
  * Fill shipping information for each address and proceed to next step.
  *
  * @return void
  */
 public function run()
 {
     $shippingMethods = [];
     for ($i = 0; $i < count($this->customer->getAddress()); $i++) {
         $shippingMethods[] = $this->shippingMethod;
     }
     $this->shippingInformation->getShippingBlock()->selectShippingMethod($shippingMethods);
 }
 /**
  * Create customer.
  *
  * @param Customer $customer
  * @param CustomerAccountForgotPassword $forgotPassword
  * @return void
  */
 public function test(Customer $customer, CustomerAccountForgotPassword $forgotPassword)
 {
     // Precondition
     $customer->persist();
     // Steps
     $forgotPassword->open();
     $forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer);
 }
 /**
  * Prepare VAT ID confguration.
  *
  * @param ConfigData $vatConfig
  * @param string $customerGroup
  * @return void
  */
 protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup)
 {
     $groupConfig = ['customer/create_account/viv_domestic_group' => ['value' => $this->vatGroups['valid_domestic_group']->getCustomerGroupId()], 'customer/create_account/viv_intra_union_group' => ['value' => $this->vatGroups['valid_intra_union_group']->getCustomerGroupId()], 'customer/create_account/viv_invalid_group' => ['value' => $this->vatGroups['invalid_group']->getCustomerGroupId()], 'customer/create_account/viv_error_group' => ['value' => $this->vatGroups['error_group']->getCustomerGroupId()]];
     $vatConfig = $this->fixtureFactory->createByCode('configData', ['data' => array_replace_recursive($vatConfig->getSection(), $groupConfig)]);
     $vatConfig->persist();
     $customerData = array_merge($this->customer->getData(), ['group_id' => ['value' => $this->vatGroups[$customerGroup]->getCustomerGroupCode()]], ['address' => ['addresses' => $this->customer->getDataFieldConfig('address')['source']->getAddresses()]]);
     $this->customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]);
 }
 /**
  * Run reset customer password failed test.
  * @param Customer $customer
  * @param int $attempts
  * @return void
  */
 public function test(Customer $customer, $attempts)
 {
     // Steps
     $customer->persist();
     for ($i = 0; $i < $attempts; $i++) {
         $this->forgotPassword->open();
         $this->forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer);
     }
 }
 /**
  * Injection data
  *
  * @param CustomerAccountCreate $customerAccountCreate
  * @param CustomerAccountLogout $customerAccountLogout
  * @param CmsIndex $cmsIndex
  * @param Customer $customer
  * @return array
  */
 public function __inject(CustomerAccountCreate $customerAccountCreate, CustomerAccountLogout $customerAccountLogout, CmsIndex $cmsIndex, Customer $customer)
 {
     $this->customerAccountLogout = $customerAccountLogout;
     $this->customerAccountCreate = $customerAccountCreate;
     $this->cmsIndex = $cmsIndex;
     //Precondition
     $customer->persist();
     return ['customer' => $customer];
 }
Ejemplo n.º 9
0
 /**
  * Select customer if it is present in fixture or click create new customer button.
  *
  * @param CustomerFixture $customer
  * @return void
  */
 public function selectCustomer(CustomerFixture $customer)
 {
     if ($customer->hasData('id')) {
         $this->searchAndOpen(['email' => $customer->getEmail()]);
     } else {
         $this->_rootElement->find($this->createNewCustomer)->click();
     }
     $this->getTemplateBlock()->waitLoader();
 }
 /**
  * Assert that products added to wishlist are present on Customers account on backend.
  *
  * @param CustomerIndex $customerIndex
  * @param Customer $customer
  * @param CustomerIndexEdit $customerIndexEdit
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerIndexEdit $customerIndexEdit, InjectableFixture $product)
 {
     $customerIndex->open();
     $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $customerIndexEdit->getCustomerForm()->openTab('wishlist');
     /** @var \Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist\Grid $wishlistGrid */
     $wishlistGrid = $customerIndexEdit->getCustomerForm()->getTab('wishlist')->getSearchGridBlock();
     \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible(['product_name' => $product->getName()]), $product->getName() . " is not visible in customer wishlist on backend.");
 }
 /**
  * Create customer on backend.
  *
  * @param Customer $customer
  * @return void
  */
 public function test(Customer $customer)
 {
     // Precondition
     $customer->persist();
     // Steps
     $this->pageCustomerIndex->open();
     $this->pageCustomerIndex->getPageActionsBlock()->addNew();
     $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer);
     $this->pageCustomerIndexNew->getPageActionsBlock()->save();
 }
 /**
  * Create customer with customer group and apply customer group to catalog price rule.
  *
  * @param CatalogRule $catalogPriceRule
  * @param Customer|null $customer
  * @return CustomerGroup
  */
 public function applyCustomerGroup(CatalogRule $catalogPriceRule, Customer $customer = null)
 {
     if ($customer !== null) {
         $customer->persist();
         /** @var \Magento\Customer\Test\Fixture\CustomerGroup $customerGroup */
         $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
         $catalogPriceRule = $this->fixtureFactory->createByCode('catalogRule', ['data' => array_merge($catalogPriceRule->getData(), ['customer_group_ids' => $customerGroup->getCustomerGroupCode()])]);
     }
     return $catalogPriceRule;
 }
 /**
  * New Accounts Report.
  *
  * @param Customer $customer
  * @param array $customersReport
  * @return void
  */
 public function test(Customer $customer, array $customersReport)
 {
     // Preconditions
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->massaction([], 'Delete', true, 'Select All');
     $customer->persist();
     // Steps
     $this->customerAccounts->open();
     $this->customerAccounts->getGridBlock()->searchAccounts($customersReport);
 }
 /**
  * Runs Delete Customer Backend Entity test
  *
  * @param Customer $customer
  * @return void
  */
 public function testDeleteCustomerBackendEntity(Customer $customer)
 {
     // Preconditions:
     $customer->persist();
     // Steps:
     $filter = ['email' => $customer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getPageActionsBlock()->delete();
 }
 /**
  * Create product and add it to cart.
  *
  * @param string $products
  * @param Customer $customer
  * @return array
  */
 public function test($products, Customer $customer)
 {
     // Precondition
     $products = $this->createProducts($products);
     $customer->persist();
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->addProductsToCart($products);
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LogoutCustomerOnFrontendStep', ['customer' => $customer])->run();
     return ['products' => $products];
 }
 /**
  * Create Existing Customer account on frontend.
  *
  * @param Customer $customer
  * @return void
  */
 public function testCreateExistingCustomer(Customer $customer)
 {
     // Precondition
     $existingCustomer = clone $customer;
     $customer->persist();
     // Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink('Create an Account');
     $this->customerAccountCreate->getRegisterForm()->registerCustomer($existingCustomer);
 }
 /**
  * Run update customer test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address $address [optional]
  * @return void
  */
 public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null)
 {
     // Precondition
     $initialCustomer->persist();
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
 }
 /**
  * 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);
 }
 /**
  * Assert that deleted customers address is not displayed on backend during order creation
  *
  * @param OrderIndex $orderIndex
  * @param OrderCreateIndex $orderCreateIndex
  * @param Address $deletedAddress
  * @param Customer $customer
  * @return void
  */
 public function processAssert(OrderIndex $orderIndex, OrderCreateIndex $orderCreateIndex, Address $deletedAddress, Customer $customer)
 {
     $filter = ['email' => $customer->getEmail()];
     $orderIndex->open()->getGridPageActions()->addNew();
     $orderCreateIndex->getCustomerBlock()->searchAndOpen($filter);
     $orderCreateIndex->getStoreBlock()->selectStoreView();
     $actualAddresses = $orderCreateIndex->getCreateBlock()->getBillingAddressBlock()->getExistingAddresses();
     $addressRenderer = $this->objectManager->create('Magento\\Customer\\Test\\Block\\Address\\Renderer', ['address' => $deletedAddress]);
     $addressToSearch = $addressRenderer->render();
     \PHPUnit_Framework_Assert::assertFalse(in_array($addressToSearch, $actualAddresses), 'Deleted address is present on backend during order creation');
 }
Ejemplo n.º 20
0
 /**
  * Get all error validation messages for fields.
  *
  * @param Customer $customer
  * @return array
  */
 public function getValidationMessages(Customer $customer)
 {
     $messages = [];
     foreach (array_keys($customer->getData()) as $field) {
         $element = $this->_rootElement->find(sprintf($this->validationText, str_replace('_', '-', $field)));
         if ($element->isVisible()) {
             $messages[$field] = $element->getText();
         }
     }
     return $messages;
 }
 /**
  * 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];
 }
 /**
  * Asserts that customer name in Contact information block and Account info tab matches name in fixture.
  *
  * @param CustomerAccountIndex $customerAccountIndex
  * @param CustomerAccountEdit $customerAccountEdit
  * @param Customer $customer
  * @return void
  */
 public function processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAccountEdit $customerAccountEdit, Customer $customer)
 {
     $customerName = $customer->getFirstname() . " " . $customer->getLastname();
     $customerAccountIndex->open();
     $infoBlock = $customerAccountIndex->getInfoBlock()->getContactInfoContent();
     $infoBlock = explode(PHP_EOL, $infoBlock);
     $nameInDashboard = $infoBlock[0];
     \PHPUnit_Framework_Assert::assertTrue($nameInDashboard == $customerName, 'Customer name in Contact info block is not matching the fixture.');
     $customerAccountIndex->getInfoBlock()->openEditContactInfo();
     $nameInEdit = $customerAccountEdit->getAccountInfoForm()->getFirstName() . " " . $customerAccountEdit->getAccountInfoForm()->getLastName();
     \PHPUnit_Framework_Assert::assertTrue($nameInEdit == $customerName, 'Customer name on Account info tab is not matching the fixture.');
 }
 /**
  * Assert customer availability in Customer Grid
  *
  * @param Customer $customer
  * @param CustomerIndex $pageCustomerIndex
  * @param Customer $initialCustomer [optional]
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, Customer $initialCustomer = null)
 {
     if ($initialCustomer) {
         $customer = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData();
     } else {
         $customer = $customer->getData();
     }
     $name = (isset($customer['prefix']) ? $customer['prefix'] . ' ' : '') . $customer['firstname'] . (isset($customer['middlename']) ? ' ' . $customer['middlename'] : '') . ' ' . $customer['lastname'] . (isset($customer['suffix']) ? ' ' . $customer['suffix'] : '');
     $filter = ['name' => $name, 'email' => $customer['email']];
     $pageCustomerIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($pageCustomerIndex->getCustomerGridBlock()->isRowVisible($filter), 'Customer with ' . 'name \'' . $filter['name'] . '\', ' . 'email \'' . $filter['email'] . '\' ' . 'is absent in Customer grid.');
 }
 /**
  * Delete products form default wish list.
  *
  * @param Customer $customer
  * @param string $products
  * @param array $removedProductsIndex
  * @return array
  */
 public function test(Customer $customer, $products, array $removedProductsIndex)
 {
     // Preconditions
     $customer->persist();
     $this->loginCustomer($customer);
     $products = $this->createProducts($products);
     $this->addToWishlist($products);
     // Steps
     $this->cmsIndex->getLinksBlock()->openLink("My Wish List");
     $removeProducts = $this->removeProducts($products, $removedProductsIndex);
     return ['products' => $removeProducts, 'customer' => $customer];
 }
Ejemplo n.º 25
0
 /**
  * Authorize customer on frontend.
  *
  * @param Customer $customer
  * @throws \Exception
  * @return void
  */
 protected function authorize(Customer $customer)
 {
     $url = $_ENV['app_frontend_url'] . 'customer/account/login/';
     $this->transport->write($url);
     $this->read();
     $url = $_ENV['app_frontend_url'] . 'customer/account/loginPost/';
     $data = ['login[username]' => $customer->getEmail(), 'login[password]' => $customer->getPassword(), 'form_key' => $this->formKey];
     $this->transport->write($url, $data, CurlInterface::POST, ['Set-Cookie:' . $this->cookies]);
     $response = $this->read();
     if (strpos($response, 'customer/account/login')) {
         throw new \Exception($customer->getFirstname() . ', cannot be logged in by curl handler!');
     }
 }
 /**
  * Run suggest searching result test.
  *
  * @param Customer $customer
  * @param string $products
  * @param int $qty
  * @return array
  */
 public function test(Customer $customer, $products, $qty)
 {
     // Preconditions
     $customer->persist();
     $this->loginCustomer($customer);
     $products = $this->createProducts($products);
     $this->addToWishlist($products);
     // Steps
     $this->addToCart($products, $qty);
     // Prepare data for asserts
     $cart = $this->createCart($products);
     return ['products' => $products, 'customer' => $customer, 'cart' => $cart];
 }
 /**
  * Assert customer info in Abandoned Carts report (Reports > Abandoned carts):
  * – name and email
  * – products and qty
  * – created and updated date
  *
  * @param AbandonedCarts $abandonedCarts
  * @param array $products
  * @param Customer $customer
  * @return void
  */
 public function processAssert(AbandonedCarts $abandonedCarts, $products, Customer $customer)
 {
     $abandonedCarts->open();
     $qty = 0;
     foreach ($products as $product) {
         $qty += $product->getCheckoutData()['qty'];
     }
     $filter = ['customer_name' => $customer->getFirstname() . " " . $customer->getLastname(), 'email' => $customer->getEmail(), 'items_count' => count($products), 'items_qty' => $qty, 'created_at' => date('m/j/Y'), 'updated_at' => date('m/j/Y')];
     $abandonedCarts->getGridBlock()->search($filter);
     $filter['created_at'] = date('M j, Y');
     $filter['updated_at'] = date('M j, Y');
     \PHPUnit_Framework_Assert::assertTrue($abandonedCarts->getGridBlock()->isRowVisible($filter, false, false), 'Expected customer info is absent in Abandoned Carts report grid.');
 }
 /**
  * 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];
 }
 /**
  * Run Lock customer on login page test.
  *
  * @param Customer $initialCustomer
  * @param int $attempts
  * @param FixtureFactory $fixtureFactory
  * @param $incorrectPassword
  * @param string $configData
  * @return void
  */
 public function test(Customer $initialCustomer, $attempts, FixtureFactory $fixtureFactory, $incorrectPassword, $configData = null)
 {
     $this->configData = $configData;
     // Preconditions
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $initialCustomer->persist();
     $incorrectCustomer = $fixtureFactory->createByCode('customer', ['data' => ['email' => $initialCustomer->getEmail(), 'password' => $incorrectPassword]]);
     // Steps
     for ($i = 0; $i < $attempts; $i++) {
         $this->customerAccountLogin->open();
         $this->customerAccountLogin->getLoginBlock()->fill($incorrectCustomer);
         $this->customerAccountLogin->getLoginBlock()->submit();
     }
 }
 /**
  * Asserts all Product Review variables in the reviews grid on customer page
  *
  * @param Customer $customer
  * @param Review $reviewInitial
  * @param Review $review
  * @param CustomerIndexEdit $customerIndexEdit
  * @param CustomerIndex $customerIndex
  * @param AssertProductReviewInGrid $assertProductReviewInGrid
  * @return void
  */
 public function processAssert(Customer $customer, Review $reviewInitial, Review $review, CustomerIndexEdit $customerIndexEdit, CustomerIndex $customerIndex, AssertProductReviewInGrid $assertProductReviewInGrid)
 {
     /** var CatalogProductSimple $product */
     $product = $reviewInitial->getDataFieldConfig('entity_id')['source']->getEntity();
     $customerIndex->open();
     $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]);
     $customerIndexEdit->getCustomerForm()->openTab('product_reviews');
     $filter = $assertProductReviewInGrid->prepareFilter($product, $this->prepareData($review, $reviewInitial));
     /** @var ReviewsGrid $reviewsGrid */
     $reviewsGrid = $customerIndexEdit->getCustomerForm()->getTab('product_reviews')->getReviewsGrid();
     $reviewsGrid->search($filter);
     unset($filter['visible_in']);
     \PHPUnit_Framework_Assert::assertTrue($reviewsGrid->isRowVisible($filter, false), 'Review is absent in Review grid on customer page.');
 }