From 46e9bde49b3d2dc80761d54fd75de493c2d49416 Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Fri, 10 Mar 2017 13:13:31 +0300 Subject: [PATCH 01/21] MTO-115: [Variation] Setup Customer Cookie Lifetime - Test flow modified - Variation added --- .../AssertAdminLoginPageIsAvailable.php | 1 + .../Backend/Test/Repository/ConfigData.xml | 24 +++++ .../Test/TestCase/ExpireAdminSessionTest.php | 100 ----------------- .../Test/TestCase/ExpireAdminSessionTest.xml | 15 --- .../Test/TestCase/ExpireSessionTest.php | 101 ++++++++++++++++++ .../Test/TestCase/ExpireSessionTest.xml | 22 ++++ ...tAutorizationLinkIsVisibleOnStoreFront.php | 41 +++++++ 7 files changed, 189 insertions(+), 115 deletions(-) delete mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.php delete mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertAdminLoginPageIsAvailable.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertAdminLoginPageIsAvailable.php index 140873a90a2a8..5977d055770ab 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertAdminLoginPageIsAvailable.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertAdminLoginPageIsAvailable.php @@ -22,6 +22,7 @@ class AssertAdminLoginPageIsAvailable extends AbstractConstraint */ public function processAssert(AdminAuthLogin $adminAuthLogin) { + $adminAuthLogin->open(); \PHPUnit_Framework_Assert::assertTrue( $adminAuthLogin->getLoginBlock()->isVisible(), 'Admin session does not expire properly.' diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml index c3f6419b24bd0..d6b793230ae64 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Repository/ConfigData.xml @@ -124,6 +124,7 @@ 3600 + default @@ -133,6 +134,29 @@ + + + default + 0 + 3600 + 3600 + + + + + + + 60 + + + + + + + 3600 + + + default diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.php b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.php deleted file mode 100644 index 2d35a36e4de20..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.php +++ /dev/null @@ -1,100 +0,0 @@ - Configuration -> Advanced -> Admin. - * 3. Open "Security" group. - * 4. Save old session lifetime value for "Admin Session Lifetime (seconds)". - * 5. Set new session lifetime value for "Admin Session Lifetime (seconds)". - * 6. Wait for session to expire. - * 7. Go to Stores -> Configuration. - * 8. Perform asserts. - * 9. Restore old session lifetime value after test is done. - * - * @ZephyrId MAGETWO-47723 - */ -class ExpireAdminSessionTest extends Injectable -{ - /* tags */ - const MVP = 'no'; - /* end tags */ - - protected $systemConfigEdit; - - protected $sessionLifetimeConfig; - - protected $oldValue; - - /** - * Open backend system config. - * Save default configuration value. - * Set new configuration value. - * Reopen backend system config. - * - * @param SystemConfigEdit $systemConfigEdit - * @param ConfigData $sessionLifetimeConfig - * @param AdminAuthLogin $adminAuthLogin - * @return void - */ - public function test( - SystemConfigEdit $systemConfigEdit, - ConfigData $sessionLifetimeConfig, - AdminAuthLogin $adminAuthLogin - ) { - $this->systemConfigEdit = $systemConfigEdit; - $this->sessionLifetimeConfig = $sessionLifetimeConfig; - $this->systemConfigEdit->open(); - $section = $sessionLifetimeConfig->getSection(); - $keys = array_keys($section); - $parts = explode('/', $keys[0], 3); - $tabName = $parts[0]; - $groupName = $parts[1]; - $fieldName = $parts[2]; - $this->oldValue = $this->systemConfigEdit->getForm()->getGroup($tabName, $groupName) - ->getValue($tabName, $groupName, $fieldName); - $this->systemConfigEdit->getForm()->getGroup($tabName, $groupName) - ->setValue($tabName, $groupName, $fieldName, $section[$keys[0]]['label']); - $this->systemConfigEdit->getPageActions()->save(); - $this->systemConfigEdit->getMessagesBlock()->waitSuccessMessage(); - - /** - * Wait admin session to expire. - */ - sleep($section[$keys[0]]['label']); - - $adminAuthLogin->open(); - } - - /** - * Tear down after tests. - * - * @return void - */ - public function tearDown() - { - $this->systemConfigEdit->open(); - $section = $this->sessionLifetimeConfig->getSection(); - $keys = array_keys($section); - $parts = explode('/', $keys[0], 3); - $tabName = $parts[0]; - $groupName = $parts[1]; - $fieldName = $parts[2]; - $this->systemConfigEdit->getForm()->getGroup($tabName, $groupName) - ->setValue($tabName, $groupName, $fieldName, $this->oldValue); - $this->systemConfigEdit->getPageActions()->save(); - $this->systemConfigEdit->getMessagesBlock()->waitSuccessMessage(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.xml deleted file mode 100644 index 2d0205dae4b96..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireAdminSessionTest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - admin_session_lifetime_60_seconds - - - - diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php new file mode 100644 index 0000000000000..d7aaa016ad0cc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php @@ -0,0 +1,101 @@ +stepFactory = $stepFactory; + } + + /** + * Runs test. + * + * @param int $sessionLifetimeInSeconds + * @param string $configData + * @param Customer|null $customer + * @return void + */ + public function test( + $sessionLifetimeInSeconds, + $configData, + Customer $customer = null + ) { + $this->configData = $configData; + $this->stepFactory->create( + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, + ['configData' => $this->configData] + )->run(); + + if ($customer != null) { + $customer->persist(); + $this->stepFactory->create( + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, + ['customer' => $customer] + )->run(); + } + + /** + * Wait admin session to expire. + */ + sleep($sessionLifetimeInSeconds); + } + + /** + * Restore default configuration settings. + * + * @return void + */ + public function tearDown() + { + $this->stepFactory->create( + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml new file mode 100644 index 0000000000000..075fd947ed8aa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml @@ -0,0 +1,22 @@ + + + + + + default_cookie_lifetime_60_seconds + default + 60 + + + + admin_session_lifetime_60_seconds + 60 + + + + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php new file mode 100644 index 0000000000000..91f27aed25615 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php @@ -0,0 +1,41 @@ +open(); + \PHPUnit_Framework_Assert::assertTrue( + $cmsIndex->getLinksBlock()->isAuthorizationVisible(), + "Authorization link is not visible on the Store Front." + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return "Authorization link is visible on the Store Front."; + } +} From 480978ef77a2a67c674e81b577a696cbab3b2f2a Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Fri, 10 Mar 2017 14:44:06 +0300 Subject: [PATCH 02/21] MTO-115: [Variation] Setup Customer Cookie Lifetime - Defects fixed --- .../app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml | 2 +- ...ont.php => AssertAuthorizationLinkIsVisibleOnStoreFront.php} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/{AssertAutorizationLinkIsVisibleOnStoreFront.php => AssertAuthorizationLinkIsVisibleOnStoreFront.php} (92%) diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml index 075fd947ed8aa..259cc54f301b6 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml @@ -11,7 +11,7 @@ default_cookie_lifetime_60_seconds default 60 - + admin_session_lifetime_60_seconds diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAuthorizationLinkIsVisibleOnStoreFront.php similarity index 92% rename from dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php rename to dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAuthorizationLinkIsVisibleOnStoreFront.php index 91f27aed25615..2dd17917fdc8f 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAutorizationLinkIsVisibleOnStoreFront.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Constraint/AssertAuthorizationLinkIsVisibleOnStoreFront.php @@ -12,7 +12,7 @@ /** * Assert that authorization link is visible on the Store Front. */ -class AssertAutorizationLinkIsVisibleOnStoreFront extends AbstractConstraint +class AssertAuthorizationLinkIsVisibleOnStoreFront extends AbstractConstraint { /** * Assert that authorization link is visible on the Store Front. From 8badd929e58384a52d73c321ba7f28566f176cfe Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Fri, 10 Mar 2017 15:51:07 +0300 Subject: [PATCH 03/21] MTO-143: [Test] Captcha and lockout for Edit Account Settings page - Functional test implemented --- .../Captcha/Test/Block/Form/CustomerForm.xml | 14 ++ .../Captcha/Test/Repository/ConfigData.xml | 192 ++++++++++++++++-- .../Test/TestCase/CaptchaEditCustomerTest.php | 155 ++++++++++++++ .../Test/TestCase/CaptchaEditCustomerTest.xml | 21 ++ .../Block/Adminhtml/Edit/CustomerForm.php | 19 ++ .../Customer/Test/Block/Form/CustomerForm.xml | 20 +- .../AssertCustomerIsLockedOnBackend.php | 51 +++++ 7 files changed, 449 insertions(+), 23 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/CustomerForm.xml create mode 100644 dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerIsLockedOnBackend.php diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/CustomerForm.xml new file mode 100644 index 0000000000000..97cb89c68ae79 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/Block/Form/CustomerForm.xml @@ -0,0 +1,14 @@ + + + + + + [name='captcha[user_edit]'] + + + diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Captcha/Test/Repository/ConfigData.xml index 0bcf56e1bbe0e..9a5adf2efeda8 100644 --- a/dev/tests/functional/tests/app/Magento/Captcha/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/Repository/ConfigData.xml @@ -7,37 +7,37 @@ --> - - + + 0 Yes 1 - + 0 - Admin Login - backend_login + Login + user_login - + 0 Always always - + admin 1 3 - + admin 1 1 - - + + default 1 No @@ -45,7 +45,7 @@ - + 0 Yes @@ -53,8 +53,8 @@ 0 - Login - user_login + Create user + user_create 0 @@ -74,7 +74,133 @@ 1 - + + + default + 1 + No + 0 + + + + + + 0 + Yes + 1 + + + 0 + Contact Us + contact_us + + + 0 + Always + always + + + admin + 1 + + 3 + + + admin + 1 + + 1 + + + + + default + 1 + No + 0 + + + + + + 0 + Yes + 1 + + + 0 + Login + user_login + + + 0 + After number of attempts to login + after_fail + + + customer + 1 + + 3 + + + customer + 1 + + 3 + + + customer + 1 + + 1 + + + + + default + 1 + No + 0 + + + + + + 0 + Yes + 1 + + + 0 + Change password + user_edit + + + 0 + After number of attempts to login + after_fail + + + customer + 1 + + 3 + + + customer + 1 + + 3 + + + customer + 1 + + 1 + + + default 1 @@ -82,5 +208,43 @@ 0 + + + + 0 + Yes + 1 + + + 0 + Admin Login + backend_login + + + 0 + Always + always + + + admin + 1 + + 3 + + + admin + 1 + + 1 + + + + + default + 1 + No + 0 + + diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php new file mode 100644 index 0000000000000..dad85aa799501 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php @@ -0,0 +1,155 @@ +stepFactory = $stepFactory; + $this->fixtureFactory = $fixtureFactory; + $this->customerAccountEdit = $customerAccountEdit; + } + + /** + * Test creation for check captcha and lockout customer on the account edit page. + * + * @param Customer $customer + * @param Customer $initCustomer + * @param string $configData + * @param string $captcha + * @param int $attempts + * @return void + */ + public function test( + Customer $customer, + Customer $initCustomer, + $configData, + $captcha, + $attempts + ) { + $this->configData = $configData; + + // Preconditions + $customer->persist(); + $this->stepFactory->create( + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, + ['configData' => $this->configData] + )->run(); + $this->stepFactory->create( + \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, + ['customer' => $customer] + )->run(); + + // Steps + $this->customerAccountEdit->getAccountMenuBlock()->openMenuItem('Account Information'); + + // Update email with incorrect password $attempts times. + $this->customerEdit($initCustomer, $attempts); + + // Update email with incorrect password and captcha $attempts + 1 times. + $data = $initCustomer->getData(); + $data['captcha'] = $captcha; + $data['group_id'] = []; + + $initCustomer = $this->fixtureFactory->createByCode('customer', ['data' => $data]); + $this->customerEdit($initCustomer, $attempts + 1); + } + + /** + * Update email with incorrect password $attempts times. + * + * @param Customer $customer + * @param int $attempts + * @return void + */ + private function customerEdit(Customer $customer, $attempts) + { + $accountInfoForm = $this->customerAccountEdit->getAccountInfoForm(); + for ($i = 0; $i < $attempts; $i++) { + $accountInfoForm->setChangeEmail(true); + $accountInfoForm->fill($customer); + $accountInfoForm->submit(); + } + } + + /** + * Set default configuration. + * + * @return void + */ + public function tearDown() + { + $this->stepFactory->create( + \Magento\Config\Test\TestStep\SetupConfigurationStep::class, + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.xml b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.xml new file mode 100644 index 0000000000000..ff12c4d969560 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.xml @@ -0,0 +1,21 @@ + + + + + + default + JaneDoe_%isolation%@example.com + incorrect password + 3 + 111 + captcha_storefront_user_edit_failures_number, customer_max_login_failures_number + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php index 9f36c33c5d296..3f2dcc28c8d6b 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php @@ -7,6 +7,7 @@ namespace Magento\Customer\Test\Block\Adminhtml\Edit; use Magento\Backend\Test\Block\Widget\FormTabs; +use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\Fixture\InjectableFixture; use Magento\Customer\Test\Fixture\Address; @@ -51,6 +52,13 @@ class CustomerForm extends FormTabs */ protected $tabReadiness = '.admin__page-nav-item._active._loading'; + /** + * Personal information xpath selector. + * + * @var string + */ + protected $information = './/th[contains(text(), "%s")]/following-sibling::td[1]'; + /** * Fill Customer forms on tabs by customer, addresses data. * @@ -162,4 +170,15 @@ public function getJsErrors() } return $jsErrors; } + + /** + * Get personal information. + * + * @param string $title + * @return string + */ + public function getPersonalInformation($title) + { + return $this->_rootElement->find(sprintf($this->information, $title), Locator::SELECTOR_XPATH)->getText(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml index 753ea99c9ad1d..1c4c7722858ca 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml @@ -6,18 +6,20 @@ */ --> - + + - - checkbox - - - checkbox - - - + + + checkbox + + + checkbox + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerIsLockedOnBackend.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerIsLockedOnBackend.php new file mode 100644 index 0000000000000..44c68f61a91a2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerIsLockedOnBackend.php @@ -0,0 +1,51 @@ +open(['id' => $customer->getId()]); + \PHPUnit_Framework_Assert::assertEquals( + self::CUSTOMER_LOCKED_ACCOUNT, + $customerIndexEdit->getCustomerForm()->getPersonalInformation('Account Lock'), + 'Incorrect customer account status.' + ); + } + + /** + * Assert that displayed customer account status is correct. + * + * @return string + */ + public function toString() + { + return 'Customer account status is correct.'; + } +} From fd8bc8a339db2c87e1da422219f44d32ae3b556a Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Fri, 10 Mar 2017 17:34:42 +0300 Subject: [PATCH 04/21] MTO-104: [Test] Export Customer Addresses - Test implemented --- dev/tests/functional/etc/di.xml | 6 ++ .../AssertExportCustomerAddresses.php | 86 +++++++++++++++++++ .../TestCase/ExportCustomerAddressesTest.php | 80 +++++++++++++++++ .../TestCase/ExportCustomerAddressesTest.xml | 25 ++++++ .../CustomerImportExport/Test/etc/di.xml | 14 +++ .../Test/Block/Adminhtml/Export/Filter.php | 47 ++++++++++ .../Test/Repository/ExportData.xml | 5 ++ 7 files changed, 263 insertions(+) create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml diff --git a/dev/tests/functional/etc/di.xml b/dev/tests/functional/etc/di.xml index 575471d34f5ff..604fd62eca17a 100644 --- a/dev/tests/functional/etc/di.xml +++ b/dev/tests/functional/etc/di.xml @@ -110,6 +110,12 @@ + + + customer_address.*?\.csv + + + customer.*?\.csv diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php new file mode 100644 index 0000000000000..06a5e47c6f421 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php @@ -0,0 +1,86 @@ +getLatest(); + + foreach ($customer->getDataFieldConfig('address')['source']->getAddresses() as $address) { + \PHPUnit_Framework_Assert::assertTrue( + $this->isAddressDataInFile( + $exportedFields, + $customer, + $address, + $exportData + ), + 'Customer address was not found in exported file.' + ); + } + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Customer address exists in exported file.'; + } + + /** + * Get product data from exported file. + * + * @param array $fields + * @param Customer $customer + * @param Address $address + * @param Data $exportData + * @param string $quantifiers + * @return bool + */ + public function isAddressDataInFile( + array $fields, + Customer $customer, + Address $address, + Data $exportData, + $quantifiers = 'U' + ) { + $regexp = '/'; + foreach ($fields as $field) { + $fixture = ($field == 'email') ? $customer : $address; + $regexp .= '.*(' . $fixture->getData($field) . ')'; + } + $regexp .= '/' . $quantifiers; + preg_match($regexp, $exportData->getContent(), $matches); + if (empty($matches)) { + return false; + } + return true; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php new file mode 100644 index 0000000000000..8c5ffcd2a436a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php @@ -0,0 +1,80 @@ + Export. + * 3. Select Entity Type = Customer Addresses. + * 4. Fill Entity Attributes data. + * 5. Click "Continue". + * 6. Perform all assertions. + * + * @group ImportExport + * @ZephyrId MAGETWO-46181 + */ +class ExportCustomerAddressesTest extends Injectable +{ + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Admin export index page. + * + * @var AdminExportIndex + */ + private $adminExportIndex; + + /** + * Inject pages. + * + * @param FixtureFactory $fixtureFactory + * @param AdminExportIndex $adminExportIndex + * @return void + */ + public function __inject( + FixtureFactory $fixtureFactory, + AdminExportIndex $adminExportIndex + ) { + $this->fixtureFactory = $fixtureFactory; + $this->adminExportIndex = $adminExportIndex; + } + + /** + * Runs Export Customer Addresses test. + * + * @param array $exportData + * @param Customer $customer + * @return array + */ + public function test( + array $exportData, + Customer $customer + ) { + $customer->persist(); + $this->adminExportIndex->open(); + $exportData = $this->fixtureFactory->createByCode('exportData', ['dataset' => $exportData['dataset']]); + $this->adminExportIndex->getExportForm()->fill($exportData); + $this->adminExportIndex->getFilterExport()->clickContinue(); + + return [ + 'customer' => $customer + ]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml new file mode 100644 index 0000000000000..a653590178e59 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml @@ -0,0 +1,25 @@ + + + + + + csv_customer_addresses + johndoe_with_addresses + + email + city + company + firstname + lastname + postcode + telephone + + + + + diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml new file mode 100644 index 0000000000000..fef531c5035fb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml @@ -0,0 +1,14 @@ + + + + + + customerAddresses + + + diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php index ac96239af02d4..6ab437c290e80 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php @@ -27,4 +27,51 @@ class Filter extends Grid 'selector' => 'input[name="attribute_code"]', ], ]; + + /** + * Locator for export attribute. + * + * @var string + */ + private $attribute = '[name="export_filter[%s]"]'; + + /** + * Locator for "Continue" button. + * + * @var string + */ + private $continueButton = 'button.action-.scalable'; + + /** + * Return row with given attribute label. + * + * @param string $attributeLabel + * @return \Magento\Mtf\Client\Element\SimpleElement + */ + public function getGridRow($attributeLabel) + { + return $this->search(['frontend_label' => $attributeLabel]); + } + + /** + * Click on "Continue" button. + * + * @return void + */ + public function clickContinue() + { + $this->_rootElement->find($this->continueButton)->click(); + } + + /** + * Set attribute entity value. + * + * @param string $attribute + * @param string $value + * @return void + */ + public function setAttributeValue($attribute, $value) + { + $this->_rootElement->find(sprintf($this->attribute, $attribute))->setValue($value); + } } diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml index 29ab7c7d95976..d5efc99b8653c 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml @@ -11,5 +11,10 @@ Products CSV + + + Customer Addresses + CSV + From 3950015555823ba7a7f261c111fbd4995c947c65 Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Fri, 10 Mar 2017 17:56:09 +0300 Subject: [PATCH 05/21] MTO-104: [Test] Export Customer Addresses - Defects fixed --- .../Constraint/AssertExportCustomerAddresses.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php index 06a5e47c6f421..e59f14a583115 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php @@ -12,12 +12,12 @@ use Magento\Mtf\Util\Command\File\Export; /** - * Assert that exported file with advanced pricing options contains product data. + * Assert that exported file contains customer addresses data. */ class AssertExportCustomerAddresses extends AbstractConstraint { /** - * Assert that exported file with advanced pricing options contains product data. + * Assert that exported file contains customer addresses data. * * @param Export $export * @param array $exportedFields @@ -55,7 +55,7 @@ public function toString() } /** - * Get product data from exported file. + * Get customer address data from exported file. * * @param array $fields * @param Customer $customer @@ -64,7 +64,7 @@ public function toString() * @param string $quantifiers * @return bool */ - public function isAddressDataInFile( + private function isAddressDataInFile( array $fields, Customer $customer, Address $address, @@ -78,9 +78,6 @@ public function isAddressDataInFile( } $regexp .= '/' . $quantifiers; preg_match($regexp, $exportData->getContent(), $matches); - if (empty($matches)) { - return false; - } - return true; + return !empty($matches); } } From be2c1b616c294dfa88592e105c040dd57fa3fca6 Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Mon, 13 Mar 2017 14:46:34 +0300 Subject: [PATCH 06/21] MTO-143: [Test] Captcha and lockout for Edit Account Settings page - Defects fixed --- .../Captcha/Test/TestCase/CaptchaEditCustomerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php index dad85aa799501..2fcd9d8a0705d 100644 --- a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php @@ -21,11 +21,11 @@ * 3. Create customer. * * Test Flow: - * 1. Log in customer. + * 1. Log in to Store Front. * 2. Open customer account edit page. * 2. Update email with incorrect password 3 or more times. * 3. Update email with incorrect password and captcha(111) 3 or more times. - * 5. Perform asserts + * 5. Perform asserts. * * @group Captcha * @ZephyrId MAGETWO-49049 @@ -79,7 +79,7 @@ public function __inject( } /** - * Test creation for check captcha and lockout customer on the account edit page. + * Test for checking captcha on the customer account edit page and customer is locked. * * @param Customer $customer * @param Customer $initCustomer From 4c883121dd78a3d802e0df5829031967c10ea420 Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Mon, 13 Mar 2017 16:29:14 +0300 Subject: [PATCH 07/21] MTO-123: [Test] Import Customer Addresses - Functional test implemented --- .../Test/TestCase/ImportDataTest.xml | 8 +- .../Block/Adminhtml/Edit/Tab/Addresses.php | 12 +- .../Customer/Test/Repository/Customer.xml | 17 ++ .../AssertImportCustomerAddresses.php | 159 ++++++++++++++++++ .../TestCase/ImportCustomerAddressTest.php | 34 ++++ .../TestCase/ImportCustomerAddressTest.xml | 56 ++++++ .../TestStep/FillCustomImportFormStep.php | 49 ++++++ .../customer_addresses_variation_1.php | 27 +++ .../customer_addresses_variation_2.php | 44 +++++ .../Test/etc/testcase.xml | 15 ++ .../Adminhtml/Import/Edit/CustomForm.php | 14 ++ .../Adminhtml/Import/Edit/CustomForm.xml | 38 +++++ .../Constraint/AssertImportCheckData.php} | 4 +- .../Constraint/AssertImportSuccessMessage.php | 2 +- .../ImportExport/Test/Fixture/Import/File.php | 13 +- .../Test/Page/Adminhtml/AdminImportIndex.xml | 1 + .../Test/TestStep/ClickCheckDataStep.php | 2 +- .../Test/TestStep/FillImportFormStep.php | 6 +- 18 files changed, 480 insertions(+), 21 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/testcase.xml create mode 100644 dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php create mode 100644 dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.xml rename dev/tests/functional/tests/app/Magento/{AdvancedPricingImportExport/Test/Constraint/AssertImportAdvancedPricingCheckData.php => ImportExport/Test/Constraint/AssertImportCheckData.php} (91%) rename dev/tests/functional/tests/app/Magento/{AdvancedPricingImportExport => ImportExport}/Test/Constraint/AssertImportSuccessMessage.php (95%) diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml index a354f09204db4..04c17418e3d1d 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml +++ b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml @@ -25,7 +25,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -90,7 +90,7 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php index 76e40fee44ea7..c23b7f2bccfc2 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php @@ -59,7 +59,7 @@ class Addresses extends Tab * * @var string */ - protected $customerAddress = '//*[contains(@class, "address-list-item")][%d]'; + protected $customerAddress = '//*[contains(@class, "address-list-item")][%d + 1]'; /** * Magento loader. @@ -158,20 +158,24 @@ public function updateAddresses($address) * Get data from Customer addresses. * * @param FixtureInterface|FixtureInterface[]|null $address + * @param bool $throwException * @return array * @throws \Exception */ - public function getDataAddresses($address = null) + public function getDataAddresses($address = null, $throwException = true) { $data = []; - $addresses = is_array($address) ? $address : [1 => $address]; + $addresses = is_array($address) ? $address : [0 => $address]; foreach ($addresses as $addressNumber => $address) { $isHasData = (null === $address) || $address->hasData(); $isVisibleCustomerAddress = $this->isVisibleCustomerAddress($addressNumber); if ($isHasData && !$isVisibleCustomerAddress) { - throw new \Exception("Invalid argument: can't get data from customer address #{$addressNumber}"); + if ($throwException) { + throw new \Exception("Invalid argument: can't get data from customer address #{$addressNumber}"); + } + break; } if (!$isHasData && !$isVisibleCustomerAddress) { diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml index 6d3e1976d0b72..f6bb867d51076 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml @@ -21,6 +21,23 @@ + + John + Doe + + General + + JohnDoe_%isolation%@example.com + 123123^q + 123123^q + + US_address_1_without_email + + + default + + + John Doe diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php new file mode 100644 index 0000000000000..b419397c94820 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -0,0 +1,159 @@ + 'firstname', + 'lastname' => 'lastname', + 'postcode' => 'postcode', + 'region' => 'region_id', + 'city' => 'city', + 'company' => 'company', + 'country_id' => 'country_id', + 'street' => 'street', + 'telephone' => 'telephone', + ]; + + /** + * Array keys mapping for countries ids. + * + * @param array + */ + private $mappingCountries = [ + 'US' => 'United States' + ]; + + /** + * Customer edit page on backend. + * + * @var CustomerIndexEdit + */ + private $customerIndexEdit; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * Import fixture. + * + * @var ImportData + */ + private $import; + + /** + * Assert imported customer addresses are correct. + * + * @param CustomerIndexEdit $customerIndexEdit + * @param FixtureFactory $fixtureFactory + * @param ImportData $import + * @return void + */ + public function processAssert( + CustomerIndexEdit $customerIndexEdit, + FixtureFactory $fixtureFactory, + ImportData $import + ) { + $this->customerIndexEdit = $customerIndexEdit; + $this->fixtureFactory = $fixtureFactory; + $this->import = $import; + + $resultArrays = $this->getPrepareAddresses(); + + \PHPUnit_Framework_Assert::assertEquals( + $resultArrays['pageData'], + $resultArrays['csvData'], + 'Addresses from page and csv are not match.' + ); + } + + /** + * Prepare arrays for compare. + * + * @return array + */ + private function getPrepareAddresses() + { + $addressTemplate = $this->fixtureFactory->createByCode('address', ['dataset' => 'US_address_1_without_email']); + $customers = $this->import->getDataFieldConfig('import_file')['source']->getEntities(); + $customerForm = $this->customerIndexEdit->getCustomerForm(); + + // Prepare customer address data from page form. + $resultAddressesArray = []; + foreach ($customers as $customer) { + $this->customerIndexEdit->open(['id' => $customer->getId()]); + $customerForm->openTab('addresses'); + if (!empty($address = $customerForm->getTab('addresses')->getDataAddresses($addressTemplate, false))) { + $resultAddressesArray[] = $address[0]; + } + } + + // Prepare customer address data from csv file. + $resultCsvArray = []; + if ($this->import->getBehavior() !== 'Delete Entities') { + $resultCsvArray = $this->getResultCsv(); + } + return ['pageData' => $resultAddressesArray, 'csvData' => $resultCsvArray]; + } + + /** + * Prepare array from csv file. + * + * @return array + */ + private function getResultCsv() + { + $csvData = $this->import->getDataFieldConfig('import_file')['source']->getCsv(); + + $csvKeys = []; + foreach (array_shift($csvData) as $csvKey) { + $csvKeys[] = isset($this->mappingKeys[$csvKey]) ? $this->mappingKeys[$csvKey] : $csvKey; + } + + $resultCsvData = []; + foreach ($csvData as $csvRowData) { + $csvRowData = array_combine($csvKeys, $csvRowData); + foreach (array_keys(array_diff_key($csvRowData, array_flip($this->mappingKeys))) as $key) { + unset($csvRowData[$key]); + }; + + if (isset($this->mappingCountries[$csvRowData['country_id']])) { + $csvRowData['country_id'] = $this->mappingCountries[$csvRowData['country_id']]; + }; + $resultCsvData[] = $csvRowData; + } + return $resultCsvData; + } + + /** + * Return string representation of object. + * + * @return string + */ + public function toString() + { + return 'Imported advanced prices are correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php new file mode 100644 index 0000000000000..6171e9c08212f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php @@ -0,0 +1,34 @@ +executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml new file mode 100644 index 0000000000000..659595ab4550a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml @@ -0,0 +1,56 @@ + + + + + + + Customer Addresses + Delete Entities + Stop on Error + 10 + , + , + + + customer::default_customer_without_email + + + Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1 + 1 + + + + + + + + + Customer Addresses + Add/Update Complex Data + Stop on Error + 10 + , + , + + + customer::default + customer::default + + + Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2 + 2 + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php new file mode 100644 index 0000000000000..8ffd7b739761c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php @@ -0,0 +1,49 @@ +adminImportIndex->getCustomImportForm()->fill($this->import); + + /** @var File $file */ + $file = $this->import->getDataFieldConfig('import_file')['source']; + + return [ + 'entities' => $file->getEntities(), + 'import' => $this->import + ]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php new file mode 100644 index 0000000000000..7f7941e4627bc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php @@ -0,0 +1,27 @@ + + [ + 'data_0' => + [ + '_website' => 'base', + '_email' => "%email%", + '_entity_id' => '%id%', + 'city' => 'Culver City', + 'company' => 'Magento', + 'country_id' => 'US', + 'firstname' => 'John', + 'lastname' => 'Doe', + 'postcode' => '90230', + 'region' => 'California', + 'region_id' => '12', + 'street' => '6161 West Centinela Avenue', + 'telephone' => '555-55-555-55', + ], + ], +]; diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php new file mode 100644 index 0000000000000..ff8cb4af48792 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php @@ -0,0 +1,44 @@ + + [ + 'data_0' => + [ + '_website' => 'base', + '_email' => "%email%", + '_entity_id' => '%id%', + 'city' => 'Culver City', + 'company' => 'Magento', + 'country_id' => 'US', + 'firstname' => 'John', + 'lastname' => 'Doe', + 'postcode' => '90230', + 'region' => 'California', + 'street' => '6161 West Centinela Avenue', + 'telephone' => '555-55-555-55', + ], + ], + 'entity_1' => + [ + 'data_0' => + [ + '_website' => 'base', + '_email' => "%email%", + '_entity_id' => '%id%', + 'city' => 'New York', + 'company' => 'Magento', + 'country_id' => 'US', + 'firstname' => 'John', + 'lastname' => 'Doe', + 'postcode' => '23090', + 'region' => 'California', + 'street' => 'West Centinela Avenue', + 'telephone' => '111-11-111-11', + ], + ], +]; diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/testcase.xml new file mode 100644 index 0000000000000..cd4d8a42462d6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/testcase.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php new file mode 100644 index 0000000000000..6d12d4642e478 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php @@ -0,0 +1,14 @@ + + + + + + select + + + [id='custom_behavior'] + select + + + [id='custom_behaviorvalidation_strategy'] + select + + + [id='custom_behavior_allowed_error_count'] + + + [id='custom_behavior__import_field_separator'] + + + [id='custom_behavior_import_multiple_value_separator'] + + + checkbox + + + upload + + + + diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportAdvancedPricingCheckData.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportCheckData.php similarity index 91% rename from dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportAdvancedPricingCheckData.php rename to dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportCheckData.php index 9b0fd92bf24b5..73e2f959deb80 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportAdvancedPricingCheckData.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportCheckData.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\AdvancedPricingImportExport\Test\Constraint; +namespace Magento\ImportExport\Test\Constraint; use Magento\ImportExport\Test\Page\Adminhtml\AdminImportIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -13,7 +13,7 @@ /** * Check message after check data click. */ -class AssertImportAdvancedPricingCheckData extends AbstractConstraint +class AssertImportCheckData extends AbstractConstraint { /** * Success validation result message. diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportSuccessMessage.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportSuccessMessage.php similarity index 95% rename from dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportSuccessMessage.php rename to dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportSuccessMessage.php index 149bea72564eb..3ce41b5d8d874 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/Constraint/AssertImportSuccessMessage.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertImportSuccessMessage.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\AdvancedPricingImportExport\Test\Constraint; +namespace Magento\ImportExport\Test\Constraint; use Magento\ImportExport\Test\Page\Adminhtml\AdminImportIndex; use Magento\Mtf\Constraint\AbstractConstraint; diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php index 3e62ee99dc2fa..de60f12884544 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php @@ -19,8 +19,6 @@ class File extends DataSource { /** * Website code mapping. - * - * @var array */ private $codeMapping =[ 'base' => 'Main Website[USD]' @@ -210,18 +208,21 @@ private function preparePlaceHolders() $currency = (isset($this->value['template']['websiteCurrency'])) ? "[{$this->value['template']['websiteCurrency']}]" : '[USD]'; - $website = $entity->getDataFieldConfig('website_ids')['source']->getWebsites()[0]; $entityData = $entity->getData(); - $entityData['code'] = $website->getCode(); + if (isset($entityData['website_ids'])) { + $website = $entity->getDataFieldConfig('website_ids')['source']->getWebsites()[0]; + $entityData['code'] = $website->getCode(); + } foreach ($this->csvTemplate['entity_' . $key] as $tierKey => $tier) { $values = implode('', array_values($tier)); preg_match_all('/\%(.*)\%/U', $values, $indexes); - foreach ($indexes[1] as $index) { if (isset($entityData[$index])) { $placeholders['entity_' . $key][$tierKey]["%{$index}%"] = $entityData[$index]; } - $placeholders['entity_' . $key][$tierKey][$entityData['code']] = $website->getName() . $currency; + if (isset($website)) { + $placeholders['entity_' . $key][$tierKey][$entityData['code']] = $website->getName().$currency; + } } } diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Page/Adminhtml/AdminImportIndex.xml b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Page/Adminhtml/AdminImportIndex.xml index 0cd83fd7d4d10..628c70fd86d4b 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Page/Adminhtml/AdminImportIndex.xml +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Page/Adminhtml/AdminImportIndex.xml @@ -8,6 +8,7 @@ + diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/ClickCheckDataStep.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/ClickCheckDataStep.php index 497e332908a16..1527ddf3c1d85 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/ClickCheckDataStep.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/ClickCheckDataStep.php @@ -5,7 +5,7 @@ */ namespace Magento\ImportExport\Test\TestStep; -use Magento\AdvancedPricingImportExport\Test\Constraint\AssertImportAdvancedPricingCheckData as AssertImportCheckData; +use Magento\ImportExport\Test\Constraint\AssertImportCheckData; use Magento\ImportExport\Test\Page\Adminhtml\AdminImportIndex; use Magento\Mtf\TestStep\TestStepInterface; use Magento\ImportExport\Test\Fixture\ImportData; diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php index 0dd920990fa1b..113f4c5deed9f 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php @@ -21,20 +21,20 @@ class FillImportFormStep implements TestStepInterface * * @var AdminImportIndex */ - private $adminImportIndex; + protected $adminImportIndex; /** * Import fixture. * * @var ImportData */ - private $import; + protected $import; /** * @param AdminImportIndex $adminImportIndex * @param ImportData $import * @param TestStepFactory $stepFactory - * @param bool|null $changeCurrency + * @param bool $changeCurrency */ public function __construct( AdminImportIndex $adminImportIndex, From 6e31a88d2d51a5593b9ebff5632295c8c9b9d41e Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Tue, 14 Mar 2017 10:43:48 +0300 Subject: [PATCH 08/21] MTO-104: [Test] Export Customer Addresses - Defects fixed --- .../Constraint/AssertExportCustomerAddresses.php | 6 ++---- .../Test/Repository/ExportData.xml | 15 +++++++++++++++ .../Test/TestCase/ExportCustomerAddressesTest.php | 7 ++++--- .../Test/TestCase/ExportCustomerAddressesTest.xml | 4 ++-- .../Magento/CustomerImportExport/Test/etc/di.xml | 2 +- .../Test/Block/Adminhtml/Export/Filter.php | 11 ----------- .../ImportExport/Test/Repository/ExportData.xml | 5 ----- 7 files changed, 24 insertions(+), 26 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Repository/ExportData.xml diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php index e59f14a583115..2bf365492d49b 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php @@ -61,22 +61,20 @@ public function toString() * @param Customer $customer * @param Address $address * @param Data $exportData - * @param string $quantifiers * @return bool */ private function isAddressDataInFile( array $fields, Customer $customer, Address $address, - Data $exportData, - $quantifiers = 'U' + Data $exportData ) { $regexp = '/'; foreach ($fields as $field) { $fixture = ($field == 'email') ? $customer : $address; $regexp .= '.*(' . $fixture->getData($field) . ')'; } - $regexp .= '/' . $quantifiers; + $regexp .= '/U'; preg_match($regexp, $exportData->getContent(), $matches); return !empty($matches); } diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Repository/ExportData.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Repository/ExportData.xml new file mode 100644 index 0000000000000..05fc8091c1f84 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Repository/ExportData.xml @@ -0,0 +1,15 @@ + + + + + + Customer Addresses + CSV + + + diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php index 8c5ffcd2a436a..4e2257b16c4bf 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.php @@ -6,6 +6,7 @@ namespace Magento\CustomerImportExport\Test\TestCase; use Magento\ImportExport\Test\Page\Adminhtml\AdminExportIndex; +use Magento\ImportExport\Test\Fixture\ExportData; use Magento\Customer\Test\Fixture\Customer; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; @@ -59,17 +60,17 @@ public function __inject( /** * Runs Export Customer Addresses test. * - * @param array $exportData + * @param ExportData $exportData * @param Customer $customer * @return array */ public function test( - array $exportData, + ExportData $exportData, Customer $customer ) { $customer->persist(); $this->adminExportIndex->open(); - $exportData = $this->fixtureFactory->createByCode('exportData', ['dataset' => $exportData['dataset']]); + $exportData->persist(); $this->adminExportIndex->getExportForm()->fill($exportData); $this->adminExportIndex->getFilterExport()->clickContinue(); diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml index a653590178e59..d99b5cec9d7e0 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml @@ -16,8 +16,8 @@ company firstname lastname - postcode - telephone + postcode + telephone diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml index fef531c5035fb..8c6b0b5371623 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml @@ -6,7 +6,7 @@ */ --> - + customerAddresses diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php index 6ab437c290e80..1f3b4834f3903 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php @@ -42,17 +42,6 @@ class Filter extends Grid */ private $continueButton = 'button.action-.scalable'; - /** - * Return row with given attribute label. - * - * @param string $attributeLabel - * @return \Magento\Mtf\Client\Element\SimpleElement - */ - public function getGridRow($attributeLabel) - { - return $this->search(['frontend_label' => $attributeLabel]); - } - /** * Click on "Continue" button. * diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml index d5efc99b8653c..29ab7c7d95976 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Repository/ExportData.xml @@ -11,10 +11,5 @@ Products CSV - - - Customer Addresses - CSV - From d7a1cec0de7ae9b0758c2e2512a61771d3266d55 Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Tue, 14 Mar 2017 15:55:49 +0300 Subject: [PATCH 09/21] MTO-123: [Test] Import Customer Addresses - Defects fixed --- .../Test/TestCase/ImportDataTest.xml | 2 +- .../Block/Adminhtml/Edit/Tab/Addresses.php | 10 ++---- .../Customer/Test/Repository/Customer.xml | 17 ---------- .../AssertImportCustomerAddresses.php | 32 ++++++++++++++----- .../TestCase/ImportCustomerAddressTest.php | 1 + .../TestCase/ImportCustomerAddressTest.xml | 2 +- .../TestStep/FillCustomImportFormStep.php | 27 ++++++++++++---- .../Adminhtml/Import/Edit/CustomForm.php | 2 +- .../ImportExport/Test/Fixture/Import/File.php | 5 ++- .../Test/TestStep/FillImportFormStep.php | 4 +-- 10 files changed, 57 insertions(+), 45 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml index 04c17418e3d1d..75e3763dc0283 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml +++ b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ImportDataTest.xml @@ -17,7 +17,7 @@ , - catalogProductSimple::default + catalogProductSimple::johndoe_with_addresses Magento/AdvancedPricingImportExport/Test/_files/template/pricing/advanced_price_variation_1 diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php index c23b7f2bccfc2..63d4f8be38efc 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php @@ -158,24 +158,20 @@ public function updateAddresses($address) * Get data from Customer addresses. * * @param FixtureInterface|FixtureInterface[]|null $address - * @param bool $throwException * @return array * @throws \Exception */ - public function getDataAddresses($address = null, $throwException = true) + public function getDataAddresses($address = null) { $data = []; $addresses = is_array($address) ? $address : [0 => $address]; foreach ($addresses as $addressNumber => $address) { - $isHasData = (null === $address) || $address->hasData(); + $isHasData = (null === $address) ? false : $address->hasData(); $isVisibleCustomerAddress = $this->isVisibleCustomerAddress($addressNumber); if ($isHasData && !$isVisibleCustomerAddress) { - if ($throwException) { - throw new \Exception("Invalid argument: can't get data from customer address #{$addressNumber}"); - } - break; + throw new \Exception("Invalid argument: can't get data from customer address #{$addressNumber}"); } if (!$isHasData && !$isVisibleCustomerAddress) { diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml index f6bb867d51076..6d3e1976d0b72 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml @@ -21,23 +21,6 @@ - - John - Doe - - General - - JohnDoe_%isolation%@example.com - 123123^q - 123123^q - - US_address_1_without_email - - - default - - - John Doe diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php index b419397c94820..75e9506fee9f0 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -12,7 +12,7 @@ use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; /** - * Check imported customer addresses are correct. + * Assert addresses from csv import file and page are match. */ class AssertImportCustomerAddresses extends AbstractConstraint { @@ -96,7 +96,9 @@ public function processAssert( */ private function getPrepareAddresses() { - $addressTemplate = $this->fixtureFactory->createByCode('address', ['dataset' => 'US_address_1_without_email']); + $addressTemplate = ($this->import->getBehavior() !== 'Delete Entities') + ? $this->fixtureFactory->createByCode('address', ['dataset' => 'US_address_1_without_email']) + : null; $customers = $this->import->getDataFieldConfig('import_file')['source']->getEntities(); $customerForm = $this->customerIndexEdit->getCustomerForm(); @@ -105,8 +107,9 @@ private function getPrepareAddresses() foreach ($customers as $customer) { $this->customerIndexEdit->open(['id' => $customer->getId()]); $customerForm->openTab('addresses'); - if (!empty($address = $customerForm->getTab('addresses')->getDataAddresses($addressTemplate, false))) { - $resultAddressesArray[] = $address[0]; + $address = $customerForm->getTab('addresses')->getDataAddresses($addressTemplate)[0]; + if (!empty($address)) { + $resultAddressesArray[] = $address; } } @@ -135,10 +138,7 @@ private function getResultCsv() $resultCsvData = []; foreach ($csvData as $csvRowData) { $csvRowData = array_combine($csvKeys, $csvRowData); - foreach (array_keys(array_diff_key($csvRowData, array_flip($this->mappingKeys))) as $key) { - unset($csvRowData[$key]); - }; - + $csvRowData = $this->deleteDirtData($csvRowData); if (isset($this->mappingCountries[$csvRowData['country_id']])) { $csvRowData['country_id'] = $this->mappingCountries[$csvRowData['country_id']]; }; @@ -147,6 +147,22 @@ private function getResultCsv() return $resultCsvData; } + /** + * Delete waste data from array. + * + * @param array $csvData + * @return array + */ + private function deleteDirtData(array $csvData) + { + $necessaryData = array_flip($this->mappingKeys); + $wasteKeys = array_keys(array_diff_key($csvData, $necessaryData)); + foreach ($wasteKeys as $key) { + unset($csvData[$key]); + }; + return $csvData; + } + /** * Return string representation of object. * diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php index 6171e9c08212f..86fdd384544e7 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.php @@ -19,6 +19,7 @@ * 5. Perform assertions. * * @group ImportExport + * @ZephyrId MAGETWO-46175, MAGETWO-46176 */ class ImportCustomerAddressTest extends Scenario { diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml index 659595ab4550a..9486984c417fc 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml @@ -17,7 +17,7 @@ , - customer::default_customer_without_email + customer::johndoe_with_addresses adminImportIndex = $adminImportIndex; + $this->import = $import; } /** diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php index 6d12d4642e478..cb230a68edb1d 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php @@ -8,7 +8,7 @@ /** * Import form. */ -class CustomForm extends \Magento\Mtf\Block\Form +class CustomForm extends Form { // } diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php index de60f12884544..ecc43e8086545 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php @@ -19,6 +19,8 @@ class File extends DataSource { /** * Website code mapping. + * + * @var array */ private $codeMapping =[ 'base' => 'Main Website[USD]' @@ -221,7 +223,8 @@ private function preparePlaceHolders() $placeholders['entity_' . $key][$tierKey]["%{$index}%"] = $entityData[$index]; } if (isset($website)) { - $placeholders['entity_' . $key][$tierKey][$entityData['code']] = $website->getName().$currency; + $placeholders['entity_' . $key][$tierKey][$entityData['code']] = + $website->getName() . $currency; } } } diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php index 113f4c5deed9f..220b87bf9d23e 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/TestStep/FillImportFormStep.php @@ -21,14 +21,14 @@ class FillImportFormStep implements TestStepInterface * * @var AdminImportIndex */ - protected $adminImportIndex; + private $adminImportIndex; /** * Import fixture. * * @var ImportData */ - protected $import; + private $import; /** * @param AdminImportIndex $adminImportIndex From 26dd1ab74f74b5832e9d7ceefb353375cef14049 Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Tue, 14 Mar 2017 16:02:46 +0300 Subject: [PATCH 10/21] MTO-123: [Test] Import Customer Addresses - Defects fixed --- .../Test/Constraint/AssertImportCustomerAddresses.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php index 75e9506fee9f0..ac30bcfd0491a 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -138,7 +138,7 @@ private function getResultCsv() $resultCsvData = []; foreach ($csvData as $csvRowData) { $csvRowData = array_combine($csvKeys, $csvRowData); - $csvRowData = $this->deleteDirtData($csvRowData); + $csvRowData = $this->deleteWasteData($csvRowData); if (isset($this->mappingCountries[$csvRowData['country_id']])) { $csvRowData['country_id'] = $this->mappingCountries[$csvRowData['country_id']]; }; @@ -153,7 +153,7 @@ private function getResultCsv() * @param array $csvData * @return array */ - private function deleteDirtData(array $csvData) + private function deleteWasteData(array $csvData) { $necessaryData = array_flip($this->mappingKeys); $wasteKeys = array_keys(array_diff_key($csvData, $necessaryData)); From 0c4e66ffc6d5ab0742f4baeb830be9ef94da901c Mon Sep 17 00:00:00 2001 From: Andrei_Ziblitski Date: Tue, 14 Mar 2017 17:15:39 +0300 Subject: [PATCH 11/21] MTO-123: [Test] Import Customer Addresses - Defects fixed --- .../Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php | 2 +- .../Test/TestStep/FillCustomImportFormStep.php | 1 - .../Test/Block/Adminhtml/Import/Edit/CustomForm.php | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php index 63d4f8be38efc..43a126601f0c7 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php @@ -167,7 +167,7 @@ public function getDataAddresses($address = null) $addresses = is_array($address) ? $address : [0 => $address]; foreach ($addresses as $addressNumber => $address) { - $isHasData = (null === $address) ? false : $address->hasData(); + $isHasData = (null !== $address) && $address->hasData(); $isVisibleCustomerAddress = $this->isVisibleCustomerAddress($addressNumber); if ($isHasData && !$isVisibleCustomerAddress) { diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php index faabd20285430..1fbf805e79811 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestStep/FillCustomImportFormStep.php @@ -29,7 +29,6 @@ class FillCustomImportFormStep implements TestStepInterface */ private $import; - /** * @param AdminImportIndex $adminImportIndex * @param ImportData $import diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php index cb230a68edb1d..6d12d4642e478 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.php @@ -8,7 +8,7 @@ /** * Import form. */ -class CustomForm extends Form +class CustomForm extends \Magento\Mtf\Block\Form { // } From 7a8e8901573820a6bdaa7e59e85951896e5fd44c Mon Sep 17 00:00:00 2001 From: Vital Sery Date: Thu, 16 Mar 2017 15:30:28 +0300 Subject: [PATCH 12/21] MTO-104: [Test] Export Customer Addresses - Defects fixed --- .../CustomerImportExport/Test/etc/di.xml | 6 ++++++ .../Test/Block/Adminhtml/Export/Filter.php | 19 ------------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml index 8c6b0b5371623..526c50054d323 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml @@ -11,4 +11,10 @@ customerAddresses + + + + customer_address.*?\.csv + + diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php index 1f3b4834f3903..3e53fca98e8be 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Export/Filter.php @@ -28,13 +28,6 @@ class Filter extends Grid ], ]; - /** - * Locator for export attribute. - * - * @var string - */ - private $attribute = '[name="export_filter[%s]"]'; - /** * Locator for "Continue" button. * @@ -51,16 +44,4 @@ public function clickContinue() { $this->_rootElement->find($this->continueButton)->click(); } - - /** - * Set attribute entity value. - * - * @param string $attribute - * @param string $value - * @return void - */ - public function setAttributeValue($attribute, $value) - { - $this->_rootElement->find(sprintf($this->attribute, $attribute))->setValue($value); - } } From d4f822d5439a8d77b36d496547a5e48e2f259428 Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Thu, 16 Mar 2017 15:53:59 +0300 Subject: [PATCH 13/21] MTO-104: [Test] Export Customer Addresses - Remove unnecessary dependency. --- dev/tests/functional/etc/di.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dev/tests/functional/etc/di.xml b/dev/tests/functional/etc/di.xml index 259b16ded163a..9af1fd3ee8ba6 100644 --- a/dev/tests/functional/etc/di.xml +++ b/dev/tests/functional/etc/di.xml @@ -110,12 +110,6 @@ - - - customer_address.*?\.csv - - - customer.*?\.csv From 3714b7fbfbecc8c9982c001d80a4ffc62e8f68bd Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Thu, 16 Mar 2017 17:30:22 +0300 Subject: [PATCH 14/21] MTO-123: [Test] Import Customer Addresses - Stabilization --- .../ImportExport/Test/Fixture/Import/File.php | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php index 6193dad5d1c71..a59d8fc887576 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Fixture/Import/File.php @@ -239,17 +239,19 @@ public function prepareEntityData(FixtureInterface $entity) : '[USD]'; $entityData = $entity->getData(); - $websites = $entity->getDataFieldConfig('website_ids')['source']->getWebsites(); - foreach ($websites as $website) { - if ($website->getCode() === 'base') { - $currency = isset($this->value['template']['mainWebsiteCurrency']) - ? $this->value['template']['websiteCurrency'] - : '[USD]'; - $this->mainWebsiteMapping['base'] = $website->getName() . "[{$currency}]"; - break; + if (isset($entityData['website_ids'])) { + $websites = $entity->getDataFieldConfig('website_ids')['source']->getWebsites(); + foreach ($websites as $website) { + if ($website->getCode() === 'base') { + $currency = isset($this->value['template']['mainWebsiteCurrency']) + ? $this->value['template']['websiteCurrency'] + : '[USD]'; + $this->mainWebsiteMapping['base'] = $website->getName() . "[{$currency}]"; + break; + } + $entityData['code'] = $website->getCode(); + $entityData[$website->getCode()] = $website->getName() . $currency; } - $entityData['code'] = $website->getCode(); - $entityData[$website->getCode()] = $website->getName() . $currency; } return $entityData; } @@ -267,7 +269,9 @@ public function convertCsvToArray($csvContent) $csvContent = strtr($csvContent, $data); } } - $csvContent = strtr($csvContent, $this->mainWebsiteMapping); + if (is_array($this->mainWebsiteMapping)) { + $csvContent = strtr($csvContent, $this->mainWebsiteMapping); + } $this->csv = array_map( function ($value) { return explode(',', str_replace('"', '', $value)); From 823dd46f8e720a43bfaa7519b9decf41d6f5ecc0 Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Fri, 17 Mar 2017 17:17:11 +0300 Subject: [PATCH 15/21] MTO-104: [Test] Export Customer Addresses - Update dependencies. --- .../Magento/AdvancedPricingImportExport/Test/etc/di.xml | 8 +++++++- .../app/Magento/CustomerImportExport/Test/etc/di.xml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/etc/di.xml index 70f5200bfdb80..87851022b7cdd 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/etc/di.xml @@ -13,10 +13,16 @@ - + advancedPricing + + + + + Magento\Mtf\Util\Command\File\AdvancedPricingExport + diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml index 526c50054d323..7c3fb02de6c78 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/etc/di.xml @@ -6,10 +6,16 @@ */ --> - + customerAddresses + + + + + Magento\Mtf\Util\Command\File\CustomerAddressesExport + From 9ec007b6a0e34d1e8a83819450dd81a6180a05e9 Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Fri, 17 Mar 2017 17:43:20 +0300 Subject: [PATCH 16/21] MTO-104: [Test] Export Customer Addresses - Update selectors. --- .../Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php index 43a126601f0c7..156ce7d714950 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php @@ -59,7 +59,7 @@ class Addresses extends Tab * * @var string */ - protected $customerAddress = '//*[contains(@class, "address-list-item")][%d + 1]'; + protected $customerAddress = '//*[contains(@class, "address-list-item")][%d]'; /** * Magento loader. @@ -164,7 +164,7 @@ public function updateAddresses($address) public function getDataAddresses($address = null) { $data = []; - $addresses = is_array($address) ? $address : [0 => $address]; + $addresses = is_array($address) ? $address : [1 => $address]; foreach ($addresses as $addressNumber => $address) { $isHasData = (null !== $address) && $address->hasData(); From 688df4345171ce58e9a6147813bf91e27613ce0e Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Mon, 20 Mar 2017 13:45:36 +0300 Subject: [PATCH 17/21] MTO-104: [Test] Export Customer Addresses - Tests fixed. --- .../Customer/Test/Block/Form/CustomerForm.php | 15 +++++--------- .../Customer/Test/Block/Form/CustomerForm.xml | 20 ++++++++++++++----- .../AssertImportCustomerAddresses.php | 3 ++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php index 7fe217f25150b..49c5f8e500b78 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.php @@ -107,8 +107,7 @@ public function getFirstName() { $mapping = $this->dataMapping(); return $this->_rootElement->find( - $mapping['firstname']['selector'], - $mapping['firstname']['strategy'] + $mapping['customer']['value']['firstname']['selector'] )->getValue(); } @@ -121,8 +120,7 @@ public function getLastName() { $mapping = $this->dataMapping(); return $this->_rootElement->find( - $mapping['lastname']['selector'], - $mapping['lastname']['strategy'] + $mapping['customer']['value']['lastname']['selector'] )->getValue(); } @@ -167,8 +165,7 @@ public function isCurrentPasswordVisible() { $mapping = $this->dataMapping(); return $this->_rootElement->find( - $mapping['current_password']['selector'], - $mapping['current_password']['strategy'] + $mapping['customer']['value']['current_password']['selector'] )->isVisible(); } @@ -181,8 +178,7 @@ public function isPasswordVisible() { $mapping = $this->dataMapping(); return $this->_rootElement->find( - $mapping['password']['selector'], - $mapping['password']['strategy'] + $mapping['customer']['value']['password']['selector'] )->isVisible(); } @@ -209,8 +205,7 @@ public function isEmailVisible() { $mapping = $this->dataMapping(); return $this->_rootElement->find( - $mapping['email']['selector'], - $mapping['email']['strategy'] + $mapping['customer']['value']['email']['selector'] )->isVisible(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml index 1c4c7722858ca..91378449116af 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Form/CustomerForm.xml @@ -8,11 +8,21 @@ - - - - - + + input[name*=firstname] + + + input[name*=lastname] + + + input[id=email] + + + input[name*=current-password] + > + + input[name*=current-password] + checkbox diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php index ac30bcfd0491a..1534c75cb7757 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -107,7 +107,8 @@ private function getPrepareAddresses() foreach ($customers as $customer) { $this->customerIndexEdit->open(['id' => $customer->getId()]); $customerForm->openTab('addresses'); - $address = $customerForm->getTab('addresses')->getDataAddresses($addressTemplate)[0]; + $addresses = $customerForm->getTab('addresses')->getDataAddresses($addressTemplate); + $address = array_shift($addresses); if (!empty($address)) { $resultAddressesArray[] = $address; } From 6afe4b6a0b5ee5173e1b4335c9ff44b5188ae9f8 Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Tue, 21 Mar 2017 12:34:38 +0300 Subject: [PATCH 18/21] MTO-104: [Test] Export Customer Addresses - Tests fixed. --- .../AssertExportCustomerAddresses.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php index 2bf365492d49b..1497139438116 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertExportCustomerAddresses.php @@ -69,13 +69,23 @@ private function isAddressDataInFile( Address $address, Data $exportData ) { - $regexp = '/'; + $expectedFields = []; + $result = true; + foreach ($fields as $field) { $fixture = ($field == 'email') ? $customer : $address; - $regexp .= '.*(' . $fixture->getData($field) . ')'; + $expectedFields[] = $fixture->getData($field); } - $regexp .= '/U'; - preg_match($regexp, $exportData->getContent(), $matches); - return !empty($matches); + + $content = $exportData->getContent(); + + foreach ($expectedFields as $expectedField) { + if (strpos($content, $expectedField) === false) { + $result = false; + break; + } + } + + return $result; } } From 5374e817f9a31f48bd3f6e340ae9d5e5dccc97fc Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Wed, 22 Mar 2017 16:51:44 +0300 Subject: [PATCH 19/21] MTO-104: [Test] Export Customer Addresses - Tests fixed. --- .../Magento/Backend/Test/TestCase/ExpireSessionTest.php | 2 +- .../Magento/Backend/Test/TestCase/ExpireSessionTest.xml | 4 ++-- .../Captcha/Test/TestCase/CaptchaEditCustomerTest.php | 1 + .../Test/Constraint/AssertImportCustomerAddresses.php | 9 +++------ .../Test/TestCase/ExportCustomerAddressesTest.xml | 2 +- .../Test/TestCase/ImportCustomerAddressTest.xml | 4 ++-- .../customer_addresses_variation_1.php | 0 .../customer_addresses_variation_2.php | 0 8 files changed, 10 insertions(+), 12 deletions(-) rename dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/{pricing => address}/customer_addresses_variation_1.php (100%) rename dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/{pricing => address}/customer_addresses_variation_2.php (100%) diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php index d7aaa016ad0cc..f67ee268f9ba8 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.php @@ -13,7 +13,7 @@ /** * Steps: * - * 1. Login to backend. + * 1. Login to Admin. * 2. Create customer if needed. * 3. Apply configuration settings. * 4. Wait for session to expire. diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml index 259cc54f301b6..3a5167bb88e55 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml @@ -11,12 +11,12 @@ default_cookie_lifetime_60_seconds default 60 - + admin_session_lifetime_60_seconds 60 - + diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php index 2fcd9d8a0705d..bbe485f45bed5 100644 --- a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php @@ -119,6 +119,7 @@ public function test( $data['captcha'] = $captcha; $data['group_id'] = []; + /** @var Customer $initCustomer */ $initCustomer = $this->fixtureFactory->createByCode('customer', ['data' => $data]); $this->customerEdit($initCustomer, $attempts + 1); } diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php index 1534c75cb7757..c34d849fb3970 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -157,11 +157,8 @@ private function getResultCsv() private function deleteWasteData(array $csvData) { $necessaryData = array_flip($this->mappingKeys); - $wasteKeys = array_keys(array_diff_key($csvData, $necessaryData)); - foreach ($wasteKeys as $key) { - unset($csvData[$key]); - }; - return $csvData; + + return array_intersect_key($csvData, $necessaryData); } /** @@ -171,6 +168,6 @@ private function deleteWasteData(array $csvData) */ public function toString() { - return 'Imported advanced prices are correct.'; + return 'Imported customer addresses are correct.'; } } diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml index d99b5cec9d7e0..5be4815b4bbda 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ExportCustomerAddressesTest.xml @@ -19,7 +19,7 @@ postcode telephone - + diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml index 9486984c417fc..e2f59d4b4a59c 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml @@ -21,7 +21,7 @@ Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1 + xsi:type="string">Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_1 1 @@ -44,7 +44,7 @@ Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2 + xsi:type="string">Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_2 2 diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_1.php similarity index 100% rename from dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_1.php rename to dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_1.php diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_2.php similarity index 100% rename from dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/pricing/customer_addresses_variation_2.php rename to dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_2.php From 808f0e0047222d1db337dcb52142ce4d331ab101 Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Wed, 22 Mar 2017 19:21:02 +0300 Subject: [PATCH 20/21] MTO-104: [Test] Export Customer Addresses - Tests fixed. --- .../Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php index 156ce7d714950..3da239cd701d2 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php @@ -167,14 +167,14 @@ public function getDataAddresses($address = null) $addresses = is_array($address) ? $address : [1 => $address]; foreach ($addresses as $addressNumber => $address) { - $isHasData = (null !== $address) && $address->hasData(); + $hasData = (null !== $address) && $address->hasData(); $isVisibleCustomerAddress = $this->isVisibleCustomerAddress($addressNumber); - if ($isHasData && !$isVisibleCustomerAddress) { + if ($hasData && !$isVisibleCustomerAddress) { throw new \Exception("Invalid argument: can't get data from customer address #{$addressNumber}"); } - if (!$isHasData && !$isVisibleCustomerAddress) { + if (!$hasData && !$isVisibleCustomerAddress) { $data[$addressNumber] = []; } else { $this->openCustomerAddress($addressNumber); From fadf793d37c1b34e6af0dd968dbf938e3591870b Mon Sep 17 00:00:00 2001 From: Siarhei Andreyeu Date: Thu, 23 Mar 2017 13:53:58 +0300 Subject: [PATCH 21/21] MTO-104: [Test] Export Customer Addresses - Tests fixed. --- .../Test/TestCase/CaptchaEditCustomerTest.php | 1 + .../AssertImportCustomerAddresses.php | 29 ++++++++++++------- .../TestCase/ImportCustomerAddressTest.xml | 6 ++-- .../Adminhtml/Import/Edit/CustomForm.xml | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php index bbe485f45bed5..d146ab04f5828 100644 --- a/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php +++ b/dev/tests/functional/tests/app/Magento/Captcha/Test/TestCase/CaptchaEditCustomerTest.php @@ -121,6 +121,7 @@ public function test( /** @var Customer $initCustomer */ $initCustomer = $this->fixtureFactory->createByCode('customer', ['data' => $data]); + //Add + 1 to attempts to get over maximum attempts count. $this->customerEdit($initCustomer, $attempts + 1); } diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php index c34d849fb3970..1fd6d52ec2357 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/Constraint/AssertImportCustomerAddresses.php @@ -22,15 +22,24 @@ class AssertImportCustomerAddresses extends AbstractConstraint * @var array */ private $mappingKeys = [ - 'firstname' => 'firstname', - 'lastname' => 'lastname', - 'postcode' => 'postcode', - 'region' => 'region_id', - 'city' => 'city', - 'company' => 'company', - 'country_id' => 'country_id', - 'street' => 'street', - 'telephone' => 'telephone', + 'region' => 'region_id' + ]; + + /** + * Imported fields keys. + * + * @var array + */ + private $importedFieldsKeys = [ + 'firstname', + 'lastname', + 'postcode', + 'region_id', + 'city', + 'company', + 'country_id', + 'street', + 'telephone' ]; /** @@ -156,7 +165,7 @@ private function getResultCsv() */ private function deleteWasteData(array $csvData) { - $necessaryData = array_flip($this->mappingKeys); + $necessaryData = array_flip($this->importedFieldsKeys); return array_intersect_key($csvData, $necessaryData); } diff --git a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml index e2f59d4b4a59c..0e96955690db9 100644 --- a/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml +++ b/dev/tests/functional/tests/app/Magento/CustomerImportExport/Test/TestCase/ImportCustomerAddressTest.xml @@ -20,8 +20,7 @@ customer::johndoe_with_addresses - Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_1 + Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_1 1 @@ -43,8 +42,7 @@ customer::default - Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_2 + Magento/CustomerImportExport/Test/_files/template/address/customer_addresses_variation_2 2 diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.xml b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.xml index d05da0699c71d..4269478ce6a85 100644 --- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.xml +++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Block/Adminhtml/Import/Edit/CustomForm.xml @@ -33,6 +33,6 @@ upload - +