/** * Runs Delete Customer Backend Entity test * * @param CustomerInjectable $customer * @return void */ public function testDeleteCustomerBackendEntity(CustomerInjectable $customer) { // Preconditions: $customer->persist(); // Steps: $filter = ['email' => $customer->getEmail()]; $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getPageActionsBlock()->delete(); }
/** * Assert that deleted customers address is not displayed on backend during order creation * * @param OrderIndex $orderIndex * @param OrderCreateIndex $orderCreateIndex * @param AddressInjectable $deletedAddress * @param CustomerInjectable $customer * @return void */ public function processAssert(OrderIndex $orderIndex, OrderCreateIndex $orderCreateIndex, AddressInjectable $deletedAddress, CustomerInjectable $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'); }
/** * @param CustomerInjectable $initialCustomer * @param CustomerInjectable $customer * @param AddressInjectable $address */ public function testUpdateCustomerBackendEntity(CustomerInjectable $initialCustomer, CustomerInjectable $customer, AddressInjectable $address) { // Prepare data $address = $address->hasData() ? $address : null; // Preconditions: $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(); }
/** * Authorize customer on frontend * * @param CustomerInjectable $customer * @throws \Exception * @return void */ protected function authorize(CustomerInjectable $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.0', ['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!'); } }
/** * Asserts all Product Review variables in the reviews grid on customer page * * @param CustomerInjectable $customer * @param ReviewInjectable $reviewInitial * @param ReviewInjectable $review * @param CustomerIndexEdit $customerIndexEdit * @param CustomerIndex $customerIndex * @param AssertProductReviewInGrid $assertProductReviewInGrid * @return void */ public function processAssert(CustomerInjectable $customer, ReviewInjectable $reviewInitial, ReviewInjectable $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()->getTabElement('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.'); }
/** * Assert that error message "Please correct this email address: "%email%"." is displayed * after customer with invalid email save * * @param CustomerInjectable $customer * @param CustomerIndexNew $pageCustomerIndexNew * @return void */ public function processAssert(CustomerInjectable $customer, CustomerIndexNew $pageCustomerIndexNew) { $expectMessage = str_replace('%email%', $customer->getEmail(), self::ERROR_EMAIL_MESSAGE); $actualMessage = $pageCustomerIndexNew->getMessagesBlock()->getErrorMessages(); \PHPUnit_Framework_Assert::assertEquals($expectMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $expectMessage . "\nActual: " . $actualMessage); }
/** * Assert customer is subscribed to newsletter * * @param CustomerInjectable $customer * @param SubscriberIndex $subscriberIndex * @return void */ public function processAssert(CustomerInjectable $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.'); }
/** * Asserts that customer is not in customer's grid * * @param CustomerInjectable $initialCustomer * @param CustomerIndex $pageCustomerIndex * @return void */ public function processAssert(CustomerInjectable $customer, CustomerIndex $customerIndexPage) { $filter = ['email' => $customer->getEmail()]; $customerIndexPage->open(); \PHPUnit_Framework_Assert::assertFalse($customerIndexPage->getCustomerGridBlock()->isRowVisible($filter), "Customer with email {$filter['email']} is present in Customer grid."); }
/** * Mass assign customer group * * @param CustomerInjectable $customer * @param CustomerGroupInjectable $customerGroup * @return void */ public function test(CustomerInjectable $customer, CustomerGroupInjectable $customerGroup) { // Steps $customerGroup->persist(); $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->massaction([['email' => $customer->getEmail()]], [$this->customersGridActions => $customerGroup->getCustomerGroupCode()]); }
/** * Asserts that customer is not in customer's grid * * @param CustomerInjectable $customer * @param CustomerIndex $customerIndexPage * @return void */ public function processAssert(CustomerInjectable $customer, CustomerIndex $customerIndexPage) { $customerIndexPage->open(); \PHPUnit_Framework_Assert::assertFalse($customerIndexPage->getCustomerGridBlock()->isRowVisible(['email' => $customer->getEmail()]), 'Customer with email ' . $customer->getEmail() . 'is present in Customer grid.'); }