/** * Assert that conformation message is present. * * @param Customer $customer * @param CustomerAccountEdit $customerAccountEdit * @return void */ public function processAssert(Customer $customer, CustomerAccountEdit $customerAccountEdit) { $validationMessages = $customerAccountEdit->getAccountInfoForm()->getValidationMessages($customer); if (isset($validationMessages['password_confirmation'])) { \PHPUnit_Framework_Assert::assertEquals(self::CONFIRMATION_MESSAGE, $validationMessages['password_confirmation'], 'Wrong password confirmation validation text message.'); } else { \PHPUnit_Framework_TestCase::fail('Password confirmation validation message is absent.'); } }
/** * 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.'); }
/** * 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 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(); }
/** * 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(); }
/** * 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(); } }
/** * Assert that fail message is present * * @param CustomerAccountEdit $customerAccountEdit * @return void */ public function processAssert(CustomerAccountEdit $customerAccountEdit) { \PHPUnit_Framework_Assert::assertEquals(self::FAIL_MESSAGE, $customerAccountEdit->getMessages()->getErrorMessages()); }