/** * Assert required fields on customer form. * * @param CustomerIndexNew $customerNewPage * @param array $expectedRequiredFields * @return void */ public function processAssert(CustomerIndexNew $customerNewPage, array $expectedRequiredFields) { $actualRequiredFields = $customerNewPage->getCustomerForm()->getJsErrors(); foreach ($expectedRequiredFields as $field) { \PHPUnit_Framework_Assert::assertTrue(isset($actualRequiredFields[$field]), "Field '{$field}' is not highlighted with an JS error."); \PHPUnit_Framework_Assert::assertEquals(self::REQUIRE_MESSAGE, $actualRequiredFields[$field], "Field '{$field}' is not highlighted as required."); } }
/** * Create customer on backend. * * @param Customer $customer * @param string $customerAction * @param Address $address * @return void */ public function test(Customer $customer, $customerAction, Address $address = null) { // Steps $this->pageCustomerIndex->open(); $this->pageCustomerIndex->getPageActionsBlock()->addNew(); $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer, $address); $this->pageCustomerIndexNew->getPageActionsBlock()->{$customerAction}(); }
/** * Create customer on backend. * * @param Customer $customer * @param Address $address * @param string $customerAction * @return void */ public function test(Customer $customer, Address $address, $customerAction) { // Prepare data $address = $address->hasData() ? $address : null; // Steps $this->pageCustomerIndex->open(); $this->pageCustomerIndex->getPageActionsBlock()->addNew(); $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer, $address); $this->pageCustomerIndexNew->getPageActionsBlock()->{$customerAction}(); }
/** * 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(); }
/** * @param CustomerInjectable $customer * @param AddressInjectable $address */ public function testCreateCustomerBackendEntity(CustomerInjectable $customer, AddressInjectable $address) { // Prepare data $address = $address->hasData() ? $address : null; // Steps $this->pageCustomerIndex->open(); $this->pageCustomerIndex->getPageActionsBlock()->addNew(); $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer, $address); $this->pageCustomerIndexNew->getPageActionsBlock()->save(); }
/** * Assert that customer group find on account information page. * * @param FixtureFactory $fixtureFactory * @param CustomerGroup $customerGroup * @param CustomerIndexNew $customerIndexNew * @param CustomerIndex $customerIndex * @return void */ public function processAssert(FixtureFactory $fixtureFactory, CustomerGroup $customerGroup, CustomerIndexNew $customerIndexNew, CustomerIndex $customerIndex) { /** @var Customer $customer */ $customer = $fixtureFactory->createByCode('customer', ['dataset' => 'defaultBackend', 'data' => ['group_id' => ['customerGroup' => $customerGroup]]]); $filter = ['email' => $customer->getEmail()]; $customerIndexNew->open(); $customerIndexNew->getCustomerForm()->fillCustomer($customer); $customerIndexNew->getPageActionsBlock()->save(); $customerIndex->getCustomerGridBlock()->searchAndOpen($filter); $customerFormData = $customerIndexNew->getCustomerForm()->getData($customer); $customerFixtureData = $customer->getData(); $diff = array_diff($customerFixtureData, $customerFormData); \PHPUnit_Framework_Assert::assertTrue(empty($diff), "Customer group {$customerGroup->getCustomerGroupCode()} not in account information page."); }
/** * Assert that error message "Please correct this email address: "%email%"." is displayed * after customer with invalid email save * * @param Customer $customer * @param CustomerIndexNew $pageCustomerIndexNew * @return void */ public function processAssert(Customer $customer, CustomerIndexNew $pageCustomerIndexNew) { $expectMessage = str_replace('%email%', $customer->getEmail(), self::ERROR_EMAIL_MESSAGE); $actualMessage = $pageCustomerIndexNew->getMessagesBlock()->getErrorMessage(); \PHPUnit_Framework_Assert::assertEquals($expectMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $expectMessage . "\nActual: " . $actualMessage); }
/** * Assert that customer group is set to default on customer form. * * @param Customer $customer * @param CustomerGroup $defaultCustomerGroup * @param CustomerIndexNew $customerIndexNew * @param CustomerIndexNew $customerIndexEdit * @return void */ public function processAssert(Customer $customer, CustomerGroup $defaultCustomerGroup, CustomerIndexNew $customerIndexNew, CustomerIndexNew $customerIndexEdit) { $customerIndexEdit->open(['id' => $customer->getId()]); $customerFormData = $customerIndexNew->getCustomerForm()->getData(); \PHPUnit_Framework_Assert::assertTrue($customerFormData['group_id'] == $defaultCustomerGroup->getCustomerGroupCode(), "Customer group not set to default after group was deleted."); }