/** * Create customer. * * @return array */ public function run() { if ($this->persistCustomer == 'yes') { $this->customer->persist(); } return ['customer' => $this->customer]; }
/** * Prepare data. * * @param FixtureFactory $fixtureFactory * @param Customer $customer * @return array */ public function __prepare(FixtureFactory $fixtureFactory, Customer $customer) { $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product']); $product->persist(); $customer->persist(); return ['product' => $product, 'customer' => $customer]; }
/** * Assert that error message is displayed after customer with invalid email save. * * @param Customer $customer * @param CustomerNew $pageCustomerNew * @return void */ public function processAssert(Customer $customer, CustomerNew $pageCustomerNew) { $expectMessage = str_replace('%email%', $customer->getEmail(), self::ERROR_EMAIL_MESSAGE); $message = $pageCustomerNew->getMessagesBlock()->getErrorMessages(); $actualMessage = explode("\n", $message[0]); \PHPUnit_Framework_Assert::assertEquals($expectMessage, $actualMessage[0], 'Wrong error message is displayed.'); }
/** * Search wish list by customer. * * @param Customer $customer * @return void */ public function searchByCustomer(Customer $customer) { if ($this->_rootElement->find($this->searchType, Locator::SELECTOR_CSS, 'select')->isVisible()) { $this->selectSearchType('Wish List Owner Email Search'); } $this->_rootElement->find($this->emailInput)->setValue($customer->getEmail()); $this->clickSearchButton(); }
/** * Select customer if it is specified or click create new customer button. * * @param Customer $customer * @return void */ public function selectCustomer(Customer $customer) { if ($customer === null) { $this->_rootElement->find($this->createNewCustomer)->click(); } else { $this->searchAndOpen(['email' => $customer->getEmail()]); } }
/** * Assert that products added to wishlist are present on Customers account on backend. * * @param CustomerIndex $customerIndex * @param Customer $customer * @param CustomerEdit $customerEdit * @param InjectableFixture $product * @return void */ public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerEdit $customerEdit, InjectableFixture $product) { $customerIndex->open(); $customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $customerEdit->getCustomerForm()->openTab('wishlist'); /** @var Grid $wishlistGrid */ $wishlistGrid = $customerEdit->getCustomerForm()->getTabElement('wishlist')->getSearchGridBlock(); \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible(['product_name' => $product->getName()], true, false), $product->getName() . " is not visible in customer wishlist on backend."); }
/** * Assert that customer balance amount is changed. * * @param CustomerIndex $customerIndex * @param Customer $customer * @param CustomerBalance $customerBalance * @param CustomerEdit $customerEdit * @return void */ public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerBalance $customerBalance, CustomerEdit $customerEdit) { $customerIndex->open(); $filter = ['email' => $customer->getEmail()]; $customerIndex->getCustomerGridBlock()->searchAndOpen($filter); $customerForm = $customerEdit->getCustomerBalanceForm(); $customerForm->openTab('store_credit'); \PHPUnit_Framework_Assert::assertTrue($customerForm->getStoreCreditTab()->isStoreCreditBalanceVisible($customerBalance->getAmountDelta()), '"Store Credit Balance" grid not displays total amount of store credit balance.'); }
/** * Assert that customer balance history is changed. * * @param CustomerIndex $customerIndex * @param Customer $customer * @param CustomerBalance $customerBalance * @param CustomerEdit $customerEdit * @return void */ public function processAssert(CustomerIndex $customerIndex, Customer $customer, CustomerBalance $customerBalance, CustomerEdit $customerEdit) { $customerIndex->open(); $filter = ['email' => $customer->getEmail()]; $customerIndex->getCustomerGridBlock()->searchAndOpen($filter); $customerForm = $customerEdit->getCustomerBalanceForm(); $customerForm->openTab('store_credit'); \PHPUnit_Framework_Assert::assertTrue($customerEdit->getBalanceHistoryGrid()->verifyCustomerBalanceGrid($customerBalance), '"Balance History" grid not contains correct information.'); }
/** * Get data of Customer information, addresses on tabs. * * @param Customer $customer * @param Address|Address[]|null $address * @return array */ public function getDataCustomer(Customer $customer, $address = null) { $data = ['customer' => $customer->hasData() ? parent::getData($customer) : parent::getData()]; if (null !== $address) { $this->openTab('addresses'); $data['addresses'] = $this->getTabElement('addresses')->getDataAddresses($address); } return $data; }
/** * Prepare data. * * @param Customer $customer * @param Customer $initialCustomer [optional] * @return string */ protected function prepareData(Customer $customer, 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'] : ''); return [$name, $customer]; }
/** * 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, 'advice-validate-c' . str_replace('_', '-', $field))); if ($element->isVisible()) { $messages[$field] = $element->getText(); } } return $messages; }
/** * Run delete customer address entity test. * * @param Customer $customer * @return array */ public function test(Customer $customer) { // Preconditions: $customer->persist(); $addressToDelete = $customer->getDataFieldConfig('address')['source']->getAddresses()[0]; // Steps: $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); $this->customerAccountIndex->getAccountNavigationBlock()->openNavigationItem('Address Book'); $this->customerAddress->getBookBlock()->getAdditionalAddressBlock()->deleteAddress($addressToDelete); return ['deletedAddress' => $addressToDelete]; }
/** * 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(CurlInterface::POST, $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(CurlInterface::POST, $url, '1.1', ['Set-Cookie:' . $this->cookies], $data); $response = $this->read(); if (strpos($response, 'customer/account/login')) { throw new \Exception($customer->getFirstname() . ', cannot be logged in by curl handler!'); } }
/** * Check that clicking "Place order" without setting checkbox for agreement will result in error message displayed * under condition. * * @param CheckoutMultishippingOverview $checkoutMultishippingOverview * @param TestStepFactory $stepFactory * @param Customer $customer * @param CheckoutAgreement $checkoutAgreement * @param string $products * @param array $payment * @param array $shippingData * @param array $fillItemsData * @param string $newAddresses * @return void */ public function processAssert(CheckoutMultishippingOverview $checkoutMultishippingOverview, TestStepFactory $stepFactory, Customer $customer, CheckoutAgreement $checkoutAgreement, $products, array $payment, array $shippingData, array $fillItemsData, $newAddresses) { $this->stepFactory = $stepFactory; $customer->persist(); $products = $this->createProducts($products); $this->login($customer); $this->addToCart($products); $this->startCheckout(); $this->processCheckoutWithMultishipping($customer, $products, $fillItemsData, $shippingData, $payment, $newAddresses); $alertText = $checkoutMultishippingOverview->getOverviewBlock()->clickContinue(); \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $alertText, 'Notification required message of Terms and Conditions is absent.'); $checkoutMultishippingOverview->getOverviewBlock()->setAgreement($checkoutAgreement, 'Yes'); $checkoutMultishippingOverview->getOverviewBlock()->clickContinue(); }
/** * Assert that grid on 'Matched Customer' tab contains customer according to conditions. * * @param Customer $customer * @param CustomerSegment $customerSegment * @param CustomerSegmentIndex $customerSegmentIndex * @param CustomerSegmentNew $customerSegmentNew * @return void */ public function processAssert(Customer $customer, CustomerSegment $customerSegment, CustomerSegmentIndex $customerSegmentIndex, CustomerSegmentNew $customerSegmentNew) { $customerSegmentIndex->open(); /** @var CustomerSegmentForm $formTabs */ $formTabs = $customerSegmentNew->getCustomerSegmentForm(); $customerSegmentIndex->getGrid()->searchAndOpen(['grid_segment_name' => $customerSegment->getName()]); $customerSegmentGrid = $formTabs->getMatchedCustomers()->getCustomersGrid(); $formTabs->openTab('matched_customers'); \PHPUnit_Framework_Assert::assertTrue($customerSegmentGrid->isRowVisible(['grid_email' => $customer->getEmail()]), 'Customer is absent in grid.'); $customerSegmentGrid->resetFilter(); $totalOnTab = $formTabs->getNumberOfCustomersOnTabs(); $totalInGrid = $customerSegmentGrid->getTotalRecords(); \PHPUnit_Framework_Assert::assertEquals($totalInGrid, $totalOnTab, 'Wrong count of records is displayed.'); }
/** * Prepare data. * * @param Customer $customer * @param Customer $initialCustomer [optional] * @param Address $address [optional] * @return array */ protected function prepareData(Customer $customer, Customer $initialCustomer = null, Address $address = null) { if ($initialCustomer) { $data['customer'] = $customer->hasData() ? array_merge($initialCustomer->getData(), $customer->getData()) : $initialCustomer->getData(); } else { $data['customer'] = $customer->getData(); } if ($address) { $data['addresses'][1] = $address->hasData() ? $address->getData() : []; } else { $data['addresses'] = []; } return $data; }
/** * Assert that Gift Wrapping can be found during one page checkout on frontend. * * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param BrowserInterface $browser * @param CheckoutOnepage $checkoutOnepage * @param GiftWrapping $giftWrapping * @param Address $billingAddress * @param CatalogProductSimple $product * @param Customer $customer * @param CustomerAccountLogout $customerAccountLogout * @return void */ public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, BrowserInterface $browser, CheckoutOnepage $checkoutOnepage, GiftWrapping $giftWrapping, Address $billingAddress, CatalogProductSimple $product, Customer $customer, CustomerAccountLogout $customerAccountLogout) { // Preconditions $customer->persist(); $product->persist(); // Steps $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $checkoutCart->open()->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout(); $checkoutOnepage->getLoginBlock()->loginCustomer($customer); $checkoutOnepage->getBillingBlock()->fillBilling($billingAddress); $checkoutOnepage->getBillingBlock()->clickContinue(); \PHPUnit_Framework_Assert::assertContains($giftWrapping->getDesign(), $checkoutOnepage->getGiftOptionsBlock()->getGiftWrappingsAvailable(), "Gift Wrapping '{$giftWrapping->getDesign()}' is not present in one page checkout on frontend."); $customerAccountLogout->open(); }
/** * Prepare billing address data. * * @param array $data * @return array */ protected function prepareBillingAddress(array $data) { $result = $data; $result['firstname'] = $this->customer->getFirstname(); $result['lastname'] = $this->customer->getLastname(); return $result; }
/** * Get addresses. * * @return array */ protected function getAddresses() { $addresses = []; if ($this->customer->hasData('address')) { $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses(); } return array_merge($addresses, $this->addresses); }
/** * Injection data. * * @param CmsIndex $cmsIndex * @param CatalogProductView $catalogProductView * @param FixtureFactory $fixtureFactory * @param WishlistIndex $wishlistIndex * @param ObjectManager $objectManager * @param Customer $customer * @return array */ public function __inject(CmsIndex $cmsIndex, CatalogProductView $catalogProductView, FixtureFactory $fixtureFactory, WishlistIndex $wishlistIndex, ObjectManager $objectManager, Customer $customer) { $this->cmsIndex = $cmsIndex; $this->catalogProductView = $catalogProductView; $this->fixtureFactory = $fixtureFactory; $this->wishlistIndex = $wishlistIndex; $this->objectManager = $objectManager; $customer->persist(); return ['customer' => $customer]; }
/** * Assert that product is displayed in cross-sell section for customer segment. * * @param Browser $browser * @param Customer $customer * @param CheckoutCart $checkoutCart * @param CatalogProductSimple $product * @param CatalogProductView $catalogProductView * @param CustomerAccountLogout $customerAccountLogout * @param InjectableFixture[] $promotedProducts * @return void */ public function processAssert(Browser $browser, Customer $customer, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, CustomerAccountLogout $customerAccountLogout, array $promotedProducts) { // Create customer, logout and login to frontend $customer->persist(); $customerAccountLogout->open(); $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); // Clear cart $checkoutCart->open(); $checkoutCart->getCartBlock()->clearShoppingCart(); // Check display cross sell products $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->addToCart($product); $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $errors = []; foreach ($promotedProducts as $promotedProduct) { if (!$checkoutCart->getCrosssellBlock()->getItemBlock($promotedProduct)->isVisible()) { $errors[] = "Product '{$promotedProduct->getName()}' is absent in cross-sell section."; } } \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors)); }
/** * Assert customer is subscribed to newsletter. * * @param Customer $customer * @param SubscriberIndex $subscriberIndex * @return void */ public function processAssert(Customer $customer, SubscriberIndex $subscriberIndex) { $filter = ['email' => $customer->getEmail(), 'firstname' => $customer->getFirstname(), 'lastname' => $customer->getLastname(), 'status' => 'Subscribed']; $subscriberIndex->open(); \PHPUnit_Framework_Assert::assertTrue($subscriberIndex->getSubscriberGrid()->isRowVisible($filter), "Customer with email " . $customer->getEmail() . " is absent in Newsletter Subscribers grid."); }
/** * Open customer account. * * @return void */ public function run() { $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $this->customer->getEmail()]); }
/** * Create customer and 2 simple products with categories before run test. * * @param FixtureFactory $fixtureFactory * @param Customer $customer * @return array */ public function __prepare(FixtureFactory $fixtureFactory, Customer $customer) { $this->fixtureFactory = $fixtureFactory; $customer->persist(); $products = $this->createProducts(['simple_for_salesrule_1', 'simple_for_salesrule_2']); return ['customer' => $customer, 'productForSalesRule1' => $products[0], 'productForSalesRule2' => $products[1]]; }
/** * Get billing address for asserts. * * @param Customer $customer * @return null|Address */ protected function getBillingAddress(Customer $customer) { return $customer->hasData('address') ? $customer->getDataFieldConfig('address')['source']->getAddresses()[0] : null; }
/** * 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('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $initialCustomer])->run(); $this->cmsIndex->getTopLinksBlock()->openAccount(); $this->cmsIndex->getLinksBlock()->openLink('My Account'); $this->customerAccountIndex->getInfoBlock()->openChangePassword(); $this->customerAccountEdit->getAccountInfoForm()->fill($customer); $this->customerAccountEdit->getAccountInfoForm()->submit(); }
/** * Prepare configuration and create customer. * * @param Customer $customer * @param CatalogCategory $category * @return array */ public function __prepare(Customer $customer, CatalogCategory $category) { $customer->persist(); $category->persist(); return ['customer' => $customer, 'category' => $category]; }
/** * Create customer. * * @param Customer $customer * @return array */ public function __prepare(Customer $customer) { $customer->persist(); return ['customer' => $customer]; }
/** * Prepare data. * * @param FixtureFactory $fixtureFactory * @param Customer $customer * @param Browser $browser * @param AssertProductCompareSuccessAddMessage $assertProductCompareSuccessAddMessage * @return void */ public function __prepare(FixtureFactory $fixtureFactory, Customer $customer, Browser $browser, AssertProductCompareSuccessAddMessage $assertProductCompareSuccessAddMessage) { $this->fixtureFactory = $fixtureFactory; $this->browser = $browser; $this->assertProductCompareSuccessAddMessage = $assertProductCompareSuccessAddMessage; $customer->persist(); $this->customer = $customer; }
/** * 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', ['data' => ['email' => $initialCustomer->getEmail(), 'password' => $customer->getPassword(), 'password_confirmation' => $customer->getPassword()]]); $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); \PHPUnit_Framework_Assert::assertTrue($customerAccountIndex->getAccountNavigationBlock()->isVisible(), 'Customer Account Dashboard is not visible.'); }