/**
  * Create customer
  *
  * @return array
  */
 public function run()
 {
     if ($this->persistCustomer) {
         $this->customer->persist();
     }
     return ['customer' => $this->customer];
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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];
 }
 /**
  * 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];
 }
 /**
  * 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 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;
 }
 /**
  * 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);
 }
 /**
  * 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();
 }
 /**
  * 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 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];
 }
 /**
  * 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();
 }
 /**
  * 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];
 }
 /**
  * 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];
 }
 /**
  * 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();
     }
 }
 /**
  * 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];
 }
 /**
  * Order count report view
  *
  * @param Customer $customer
  * @param string $orders
  * @param array $report
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function test(Customer $customer, $orders, array $report, FixtureFactory $fixtureFactory)
 {
     // Precondition
     $customer->persist();
     $orders = explode(',', $orders);
     foreach ($orders as $order) {
         $order = $fixtureFactory->createByCode('orderInjectable', ['dataSet' => $order, 'data' => ['customer_id' => ['customer' => $customer]]]);
         $order->persist();
     }
     // Steps
     $this->customerOrdersReport->open();
     $this->customerOrdersReport->getFilterBlock()->viewsReport($report);
     $this->customerOrdersReport->getFilterBlock()->refreshFilter();
     return ['customer' => $customer];
 }
 /**
  * Delete Customer Group.
  *
  * @param CustomerGroup $customerGroup
  * @param Customer $customer [optional]
  * @return array
  */
 public function test(CustomerGroup $customerGroup, Customer $customer = null)
 {
     // Precondition
     if ($customer !== null) {
         $customer->persist();
         $customerGroup = $customer->getDataFieldConfig('group_id')['source']->getCustomerGroup();
     } else {
         $customerGroup->persist();
     }
     // Steps
     $filter = ['code' => $customerGroup->getCustomerGroupCode()];
     $this->customerGroupIndex->open();
     $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter);
     $this->customerGroupNew->getPageMainActions()->delete();
     $this->customerGroupNew->getModalBlock()->acceptAlert();
     return ['customer' => $customer, 'customerGroup' => $customerGroup];
 }
 /**
  * Assert that widget with type Recently Viewed Products is present on category page
  *
  * @param CmsIndex $cmsIndex
  * @param AdminCache $adminCache
  * @param CatalogCategoryView $catalogCategoryView
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $productSimple
  * @param Category $category
  * @param Customer $customer
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, AdminCache $adminCache, CatalogCategoryView $catalogCategoryView, BrowserInterface $browser, CatalogProductSimple $productSimple, Category $category, Customer $customer)
 {
     $this->browser = $browser;
     $this->cmsIndex = $cmsIndex;
     $this->catalogCategoryView = $catalogCategoryView;
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     // Log in customer
     $customer->persist();
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     // Open products
     $productSimple->persist();
     $category->persist();
     $this->browser->open($_ENV['app_frontend_url'] . $productSimple->getUrlKey() . '.html');
     $this->checkRecentlyViewedBlockOnCategory($productSimple, $category);
 }
 /**
  * Create customer.
  *
  * @param Customer $customer
  * @param BrowserInterface $browser
  * @return array
  */
 public function __prepare(Customer $customer, BrowserInterface $browser)
 {
     $customer->persist();
     // Login under customer
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $this->browser = $browser;
     return ['customer' => $customer];
 }
 /**
  * Run Lock customer on edit page test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param int $attempts
  * @param string $configData
  * @return void
  */
 public function test(Customer $initialCustomer, Customer $customer, $attempts, $configData = null)
 {
     $this->configData = $configData;
     // Preconditions
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $initialCustomer->persist();
     // Steps
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run();
     $this->cmsIndex->getLinksBlock()->openLink('My Account');
     $this->customerAccountIndex->getInfoBlock()->openChangePassword();
     for ($i = 0; $i < $attempts; $i++) {
         if ($i > 0) {
             $this->customerAccountIndex->getInfoBlock()->checkChangePassword();
         }
         $this->customerAccountEdit->getAccountInfoForm()->fill($customer);
         $this->customerAccountEdit->getAccountInfoForm()->submit();
     }
 }
Exemplo n.º 23
0
 /**
  * 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('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run();
     $this->cmsIndex->getLinksBlock()->openLink('My Account');
     $this->customerAccountIndex->getInfoBlock()->openChangePassword();
     $this->customerAccountEdit->getAccountInfoForm()->fill($customer);
     $this->customerAccountEdit->getAccountInfoForm()->submit();
 }
 /**
  * Run update customer test.
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address|null $address
  * @param int|null $addressIndexToDelete
  * @throws \Exception
  * @return array
  */
 public function testUpdateCustomerBackendEntity(Customer $initialCustomer, Customer $customer, Address $address = null, $addressIndexToDelete = null)
 {
     // Precondition
     $initialCustomer->persist();
     $addressToDelete = null;
     if ($addressIndexToDelete !== null) {
         $addressToDelete = $initialCustomer->getDataFieldConfig('address')['source']->getAddresses()[$addressIndexToDelete];
     }
     // Steps
     $filter = ['email' => $initialCustomer->getEmail()];
     $this->customerIndexPage->open();
     $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter);
     $this->customerIndexEditPage->getCustomerForm()->updateCustomer($customer, $address, $addressToDelete);
     $this->customerIndexEditPage->getPageActionsBlock()->save();
     return ['customer' => $this->prepareCustomer($customer, $initialCustomer, $address, $addressToDelete), 'addressToDelete' => $addressToDelete];
 }
 /**
  * Create customer.
  *
  * @param Customer $customer
  * @return array
  */
 public function __prepare(Customer $customer)
 {
     $customer->persist();
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     return ['customer' => $customer];
 }
 /**
  * Run Update Customer Entity test
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address $address
  * @param AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage
  * @return void
  */
 public function test(Customer $initialCustomer, Customer $customer, Address $address, AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage)
 {
     // Preconditions
     $initialCustomer->persist();
     // Steps
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run();
     $this->customerAccountIndex->getInfoBlock()->openEditContactInfo();
     $this->customerAccountEdit->getAccountInfoForm()->fill($customer);
     $this->customerAccountEdit->getAccountInfoForm()->submit();
     \PHPUnit_Framework_Assert::assertThat($this->getName(), $assertCustomerInfoSuccessSavedMessage);
     $this->cmsIndex->getCmsPageBlock()->waitPageInit();
     $this->customerAccountIndex->getDashboardAddress()->editBillingAddress();
     $this->customerAddressEdit->getEditForm()->fill($address);
     $this->customerAddressEdit->getEditForm()->saveAddress();
 }
 /**
  * Prepare customer for test.
  *
  * @param Customer $customer
  * @return array
  */
 public function __prepare(Customer $customer)
 {
     $customer->persist();
     return ['customer' => $customer];
 }
 /**
  * Prepare data.
  *
  * @param Customer $customer
  * @param CatalogProductSimple $product
  * @return array
  */
 public function __prepare(Customer $customer, CatalogProductSimple $product)
 {
     $customer->persist();
     $product->persist();
     return ['customer' => $customer, 'product' => $product];
 }
 /**
  * Run Update Customer Entity test
  *
  * @param Customer $initialCustomer
  * @param Customer $customer
  * @param Address $address
  * @param AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage
  * @return void
  */
 public function test(Customer $initialCustomer, Customer $customer, Address $address, AssertCustomerInfoSuccessSavedMessage $assertCustomerInfoSuccessSavedMessage)
 {
     // Preconditions
     $initialCustomer->persist();
     // Steps
     $this->cmsIndex->open();
     $this->cmsIndex->getLinksBlock()->openLink('Log In');
     sleep(3);
     $this->customerAccountLogin->getLoginBlock()->fill($initialCustomer);
     $this->customerAccountLogin->getLoginBlock()->submit();
     $this->customerAccountIndex->getInfoBlock()->openEditContactInfo();
     $this->customerAccountEdit->getAccountInfoForm()->fill($customer);
     $this->customerAccountEdit->getAccountInfoForm()->submit();
     \PHPUnit_Framework_Assert::assertThat($this->getName(), $assertCustomerInfoSuccessSavedMessage);
     $this->customerAccountIndex->getDashboardAddress()->editBillingAddress();
     $this->customerAddressEdit->getEditForm()->fill($address);
     $this->customerAddressEdit->getEditForm()->saveAddress();
 }
 /**
  * Prepare data.
  *
  * @param FixtureFactory $fixtureFactory
  * @param Customer $customer
  * @return void
  */
 public function __prepare(FixtureFactory $fixtureFactory, Customer $customer)
 {
     $this->fixtureFactory = $fixtureFactory;
     $customer->persist();
     $this->customer = $customer;
 }