From 61a952e2fa0f1edbd2eef7f5dc1fa40e432aa878 Mon Sep 17 00:00:00 2001 From: Oleksandr Manchenko Date: Thu, 23 Apr 2015 11:15:03 +0300 Subject: [PATCH 01/16] MTA-2056: Fix filling condition element --- .../Mtf/Client/Element/ConditionsElement.php | 268 +++++++++++------- .../Customer/Test/Handler/Customer/Curl.php | 10 +- 2 files changed, 180 insertions(+), 98 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index 8b04e6bd56c84..7aea81e922b4a 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -11,8 +11,7 @@ use Magento\Mtf\Client\ElementInterface; /** - * Class ConditionsElement - * Typified element class for conditions + * Typified element class for conditions. * * Format value. * Add slash to symbols: "{", "}", "[", "]", ":". @@ -39,77 +38,82 @@ class ConditionsElement extends SimpleElement { /** - * Main condition + * Count for trying fill condition element. + */ + const TRY_COUNT = 3; + + /** + * Main condition. * * @var string */ protected $mainCondition = './/ul[contains(@id,"__1__children")]/..'; /** - * Identification for chooser grid + * Identification for chooser grid. * * @var string */ protected $chooserLocator = '.rule-chooser-trigger'; /** - * Button add condition + * Button add condition. * * @var string */ protected $addNew = './/*[contains(@class,"rule-param-new-child")]/a'; /** - * Button remove condition + * Button remove condition. * * @var string */ protected $remove = './/*/a[@class="rule-param-remove"]'; /** - * New condition + * New condition. * * @var string */ protected $newCondition = './ul/li/span[contains(@class,"rule-param-new-child")]/..'; /** - * Type of new condition + * Type of new condition. * * @var string */ protected $typeNew = './/*[@class="element"]/select'; /** - * Created condition + * Created condition. * * @var string */ protected $created = './ul/li[span[contains(@class,"rule-param-new-child")]]/preceding-sibling::li[1]'; /** - * Children condition + * Children condition. * * @var string */ protected $children = './/ul[contains(@id,"conditions__")]'; /** - * Parameter of condition + * Parameter of condition. * * @var string */ protected $param = './span[span[*[substring(@id,(string-length(@id)-%d+1))="%s"]]]'; /** - * Key of last find param + * Key of last find param. * * @var int */ protected $findKeyParam = 0; /** - * Map of parameters + * Map of parameters. * * @var array */ @@ -122,7 +126,7 @@ class ConditionsElement extends SimpleElement ]; /** - * Map encode special chars + * Map encode special chars. * * @var array */ @@ -135,7 +139,7 @@ class ConditionsElement extends SimpleElement ]; /** - * Map decode special chars + * Map decode special chars. * * @var array */ @@ -148,14 +152,14 @@ class ConditionsElement extends SimpleElement ]; /** - * Rule param wait locator + * Rule param wait locator. * * @var string */ protected $ruleParamWait = './/*[@class="rule-param-wait"]'; /** - * Chooser grid locator + * Chooser grid locator. * * @var string */ @@ -169,7 +173,7 @@ class ConditionsElement extends SimpleElement protected $ruleParamInput = '.element [name^="rule"]'; /** - * Set value to conditions + * Set value to conditions. * * @param string $value * @return void @@ -183,7 +187,7 @@ public function setValue($value) } /** - * Add condition combination + * Add conditions combination. * * @param string $condition * @param ElementInterface $context @@ -192,15 +196,7 @@ public function setValue($value) protected function addConditionsCombination($condition, ElementInterface $context) { $condition = $this->parseCondition($condition); - - $this->driver->selectWindow(); - $newCondition = $context->find($this->newCondition, Locator::SELECTOR_XPATH); - $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); - - $this->driver->selectWindow(); - $typeNewCondition = $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select'); - $typeNewCondition->setValue($condition['type']); - + $this->addCondition($condition['type'], $context); $createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH); $this->waitForCondition($createdCondition); if (!empty($condition['rules'])) { @@ -210,7 +206,7 @@ protected function addConditionsCombination($condition, ElementInterface $contex } /** - * Add conditions + * Add conditions. * * @param array $conditions * @param ElementInterface $context @@ -229,7 +225,7 @@ protected function addMultipleCondition(array $conditions, ElementInterface $con } /** - * Add single Condition + * Add single Condition. * * @param string $condition * @param ElementInterface $context @@ -238,31 +234,47 @@ protected function addMultipleCondition(array $conditions, ElementInterface $con protected function addSingleCondition($condition, ElementInterface $context) { $condition = $this->parseCondition($condition); + $this->addCondition($condition['type'], $context); + $createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH); + $this->waitForCondition($createdCondition); + $this->fillCondition($condition['rules'], $createdCondition); + } - $this->driver->selectWindow(); + /** + * Click to add condition button and set type. + * + * @param string $type + * @param ElementInterface $context + * @return void + * @throws \Exception + */ + protected function addCondition($type, ElementInterface $context) + { $newCondition = $context->find($this->newCondition, Locator::SELECTOR_XPATH); - $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); - - $typeNew = $this->typeNew; - $newCondition->waitUntil( - function () use ($newCondition, $typeNew) { - $element = $newCondition->find($typeNew, Locator::SELECTOR_XPATH, 'select'); - if ($element->isVisible()) { - return true; - } + $count = 0; + + do { + if (!$this->driver->find('*:focus')->isVisible()) { $this->driver->selectWindow(); - return null; } - ); - $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($condition['type']); + $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); - $createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH); - $this->waitForCondition($createdCondition); - $this->fillCondition($condition['rules'], $createdCondition); - } + try { + $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($type); + $isSetType = true; + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + $isSetType = false; + } + $count++; + } while (!$isSetType && $count < self::TRY_COUNT); + if (!$isSetType) { + throw new \Exception("Can not add condition: {$type}"); + } + } + /** - * Fill single condition + * Fill single condition. * * @param array $rules * @param ElementInterface $element @@ -275,52 +287,122 @@ protected function fillCondition(array $rules, ElementInterface $element) foreach ($rules as $rule) { /** @var ElementInterface $param */ $param = $this->findNextParam($element); + $count = 0; + + do { + try { + $this->openParam($param); + + if ($this->fillGrid($rule, $param)) { + $isSet = true; + } elseif ($this->fillSelect($rule, $param)) { + $isSet = true; + } else { + $this->fillText($rule, $param); + $isSet = true; + } + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + $isSet = false; + } + $count++; + } while (!$isSet && $count < self::TRY_COUNT); - $this->driver->selectWindow(); - $param->find('a')->click(); - - if (preg_match('`%(.*?)%`', $rule, $chooserGrid)) { - $chooserConfig = explode('#', $chooserGrid[1]); - $param->find($this->chooserLocator)->click(); - $rule = preg_replace('`%(.*?)%`', '', $rule); - $grid = ObjectManager::getInstance()->create( - str_replace('/', '\\', $chooserConfig[0]), - [ - 'element' => $this->find($this->chooserGridLocator) - ] - ); - $grid->searchAndSelect([$chooserConfig[1] => $rule]); - continue; + if (!$isSet) { + throw new \Exception('Can not set value: ' . $rule); } - $input = $this->ruleParamInput; - $param->waitUntil( - function () use ($param, $input) { - $element = $param->find($input); - return $element->isVisible() ? true : null; - } + } + } + + /** + * Open param of condition before filling. + * + * @param ElementInterface $param + * @return void + */ + protected function openParam(ElementInterface $param) + { + if (!$this->driver->find('*:focus')->isVisible()) { + $this->driver->selectWindow(); + } + $param->find('a')->click(); + } + + /** + * Fill grid element. + * + * @param string $rule + * @param ElementInterface $param + * @return bool + */ + protected function fillGrid($rule, ElementInterface $param) + { + if (preg_match('`%(.*?)%`', $rule, $chooserGrid)) { + $chooserConfig = explode('#', $chooserGrid[1]); + $rule = preg_replace('`%(.*?)%`', '', $rule); + + $param->find($this->chooserLocator)->click(); + $grid = ObjectManager::getInstance()->create( + str_replace('/', '\\', $chooserConfig[0]), + [ + 'element' => $this->find($this->chooserGridLocator) + ] ); - $value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select'); - if ($value->isVisible()) { - $value->setValue($rule); - $this->click(); - continue; + $grid->searchAndSelect([$chooserConfig[1] => $rule]); + + $apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH); + if ($apply->isVisible()) { + $apply->click(); } - $value = $param->find('input', Locator::SELECTOR_TAG_NAME); - if ($value->isVisible()) { - $value->setValue($rule); - $apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH); - if ($apply->isVisible()) { - $apply->click(); - } - continue; + return true; + } + return false; + } + + /** + * Fill select element. + * + * @param string $rule + * @param ElementInterface $param + * @return bool + */ + protected function fillSelect($rule, ElementInterface $param) + { + $value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select'); + if ($value->isVisible()) { + $value->setValue($rule); + $this->click(); + + return true; + } + return false; + } + + /** + * Fill text element. + * + * @param string $rule + * @param ElementInterface $param + * @return bool + */ + protected function fillText($rule, ElementInterface $param) + { + $value = $param->find('input', Locator::SELECTOR_TAG_NAME); + if ($value->isVisible()) { + $value->setValue($rule); + + $apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH); + if ($apply->isVisible()) { + $apply->click(); } - throw new \Exception('Undefined type of value '); + + return true; } + return false; } /** - * Decode value + * Decode value. * * @param string $value * @return array @@ -344,7 +426,7 @@ protected function decodeValue($value) } /** - * Parse condition + * Parse condition. * * @param string $condition * @return array @@ -366,7 +448,7 @@ protected function parseCondition($condition) } /** - * Find next param of condition for fill + * Find next param of condition for fill. * * @param ElementInterface $context * @return ElementInterface @@ -387,7 +469,7 @@ protected function findNextParam(ElementInterface $context) } /** - * Reset key of last find param + * Reset key of last find param. * * @return void */ @@ -397,7 +479,7 @@ protected function resetKeyParam() } /** - * Param wait loader + * Param wait loader. * * @return void */ @@ -405,17 +487,13 @@ protected function waitForCondition(ElementInterface $element) { $this->waitUntil( function () use ($element) { - if ($element->getAttribute('class') == 'rule-param-wait') { - $this->driver->selectWindow(); - return null; - } - return true; + return $element->getAttribute('class') == 'rule-param-wait' ? null : true; } ); } /** - * Clear conditions + * Clear conditions. * * @return void */ @@ -429,7 +507,7 @@ protected function clear() } /** - * Get value from conditions + * Get value from conditions. * * @return null */ diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index 67d98b313afe2..d579b29e2b002 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -34,6 +34,10 @@ class Curl extends AbstractCurl implements CustomerInterface 'United States' => 'US', 'United Kingdom' => 'GB' ], + 'gender' => [ + 'Male' => 1, + 'Female' => 2, + ], 'region_id' => [ 'California' => 12, 'New York' => 43, @@ -77,12 +81,12 @@ class Curl extends AbstractCurl implements CustomerInterface */ public function persist(FixtureInterface $customer = null) { - $address = []; - $result = []; /** @var Customer $customer */ - $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; $data = $customer->getData(); $data['group_id'] = $this->getCustomerGroup($customer); + $address = []; + $result = []; + $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; if ($customer->hasData('address')) { $address = $customer->getAddress(); From 1309487014eb8e54bd97ed169af30634ee04946d Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Fri, 24 Apr 2015 18:51:09 +0300 Subject: [PATCH 02/16] MTA-2081: Analyse functional test failures - Sprint 11 --- .../AbstractCatalogRuleEntityTest.php | 15 +- ...ApplySeveralCatalogPriceRuleEntityTest.php | 14 +- .../CreateCatalogPriceRuleEntityTest.php | 7 +- .../Test/TestCase/CreateCatalogRuleTest.php | 9 +- .../UpdateCatalogPriceRuleEntityTest.php | 25 +- .../Customer/Test/Handler/Customer/Curl.php | 2 +- .../Test/Page/CustomerAccountCreate.xml | 8 +- .../Magento/GiftMessage/Test/etc/testcase.xml | 10 +- .../Test/Constraint/AssertTaxRuleApplying.php | 16 +- .../Tax/Test/TestCase/TaxCalculationTest.php | 75 +++++ .../Tax/Test/TestCase/TaxCalculationTest.xml | 301 ++++++++++++++++++ .../Test/TestCase/TaxWithCrossBorderTest.php | 160 ++++++++++ .../Test/TestCase/TaxWithCrossBorderTest.xml | 38 +++ .../app/Magento/Tax/Test/etc/testcase.xml | 18 ++ ...roductInCustomerWishlistOnFrontendTest.xml | 2 +- .../Test/TestCase/ShareWishlistEntityTest.php | 81 ++--- .../Test/TestCase/ShareWishlistEntityTest.xml | 14 +- 17 files changed, 652 insertions(+), 143 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/etc/testcase.xml diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php index 8c2ab9474a2c0..8cc2bbcd11900 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/AbstractCatalogRuleEntityTest.php @@ -38,13 +38,6 @@ abstract class AbstractCatalogRuleEntityTest extends Injectable */ protected $adminCache; - /** - * Fixture CatalogRule. - * - * @var array - */ - protected $catalogRules = []; - /** * Fixture factory. * @@ -80,12 +73,6 @@ public function __inject( */ public function tearDown() { - foreach ($this->catalogRules as $catalogRule) { - $filter = ['name' => $catalogRule->getName()]; - $this->catalogRuleIndex->open(); - $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); - $this->catalogRuleNew->getFormPageActions()->delete(); - } - $this->catalogRules = []; + $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php index 84f9cd923b6ef..b3f823578cf07 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php @@ -9,13 +9,11 @@ use Magento\Catalog\Test\Fixture\CatalogProductSimple; /** - * Test Creation for Apply several CatalogPriceRuleEntity - * - * Test Flow: * Preconditions: * 1. Execute before each variation: * - Delete all active catalog price rules * - Create catalog price rule from dataSet using Curl + * * Steps: * 1. Apply all created rules * 2. Create simple product @@ -32,7 +30,7 @@ class ApplySeveralCatalogPriceRuleEntityTest extends AbstractCatalogRuleEntityTe /* end tags */ /** - * Apply several catalog price rules + * Apply several catalog price rules. * * @param array $catalogRulesOriginal * @return array @@ -44,15 +42,15 @@ public function testApplySeveralCatalogPriceRules(array $catalogRulesOriginal) if ($catalogPriceRule == '-') { continue; } - $this->catalogRules[$key] = $this->fixtureFactory->createByCode( + $catalogRules[$key] = $this->fixtureFactory->createByCode( 'catalogRule', ['dataSet' => $catalogPriceRule] ); - $this->catalogRules[$key]->persist(); + $catalogRules[$key]->persist(); $filter = [ - 'name' => $this->catalogRules[$key]->getName(), - 'rule_id' => $this->catalogRules[$key]->getId(), + 'name' => $catalogRules[$key]->getName(), + 'rule_id' => $catalogRules[$key]->getId(), ]; $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $this->catalogRuleNew->getFormPageActions()->saveAndApply(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php index 20ddb3397e1a5..7da0460e3da1e 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php @@ -9,9 +9,7 @@ use Magento\CatalogRule\Test\Fixture\CatalogRule; /** - * Test Creation for Create CatalogPriceRuleEntity - * - * Test Flow: + * Steps: * 1. Log in as default admin user. * 2. Go to Marketing > Catalog Price Rules * 3. Press "+" button to start create new catalog price rule @@ -42,8 +40,5 @@ public function testCreateCatalogPriceRule(CatalogRule $catalogPriceRule) $this->catalogRuleIndex->getGridPageActions()->addNew(); $this->catalogRuleNew->getEditForm()->fill($catalogPriceRule); $this->catalogRuleNew->getFormPageActions()->save(); - - // Prepare data for tear down - $this->catalogRules[] = $catalogPriceRule; } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php index 6649d45ba0e63..acb29b8168ec6 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php @@ -12,9 +12,7 @@ use Magento\Customer\Test\Fixture\CustomerGroupInjectable; /** - * Test Coverage for Create Catalog Rule - * - * Test Flow: + * Steps: * 1. Log in as default admin user. * 2. Go to Marketing > Catalog Price Rules * 3. Press "+" button to start create new catalog price rule @@ -37,7 +35,7 @@ class CreateCatalogRuleTest extends AbstractCatalogRuleEntityTest /* end tags */ /** - * Create Catalog Price Rule + * Create Catalog Price Rule. * * @param CatalogRule $catalogPriceRule * @param Customer $customer @@ -70,9 +68,6 @@ public function testCreate( $this->catalogRuleNew->getEditForm()->fill($catalogPriceRule, null, $replace); $this->catalogRuleNew->getFormPageActions()->save(); - // Prepare data for tear down - $this->catalogRules[] = $catalogPriceRule; - // Apply Catalog Price Rule $this->catalogRuleIndex->getGridPageActions()->applyRules(); diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.php index 29339f794b995..fd30614dd24ab 100755 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.php @@ -11,19 +11,17 @@ use Magento\CatalogRule\Test\Fixture\CatalogRule; /** - * Test Creation for UpdateCatalogPriceRuleEntity - * - * Test Flow: * Preconditions: - * 1. Catalog Price Rule is created + * 1. Catalog Price Rule is created. + * * Steps: - * 1. Login to backend - * 2. Navigate to MARKETING > Catalog Price Rules - * 3. Click Catalog Price Rule from grid - * 4. Edit test value(s) according to dataSet - * 5. Click 'Save'/ 'Apply' button - * 6. Create simple product with category - * 7. Perform all asserts + * 1. Login to backend. + * 2. Navigate to MARKETING > Catalog Price Rules. + * 3. Click Catalog Price Rule from grid. + * 4. Edit test value(s) according to dataSet. + * 5. Click 'Save'/ 'Apply' button. + * 6. Create simple product with category. + * 7. Perform all asserts. * * @group Catalog_Price_Rules_(MX) * @ZephyrId MAGETWO-25187 @@ -37,7 +35,7 @@ class UpdateCatalogPriceRuleEntityTest extends AbstractCatalogRuleEntityTest /* end tags */ /** - * Update catalog price rule + * Update catalog price rule. * * @param CatalogRule $catalogPriceRule * @param CatalogRule $catalogPriceRuleOriginal @@ -81,9 +79,6 @@ public function testUpdateCatalogPriceRule( $this->catalogRuleNew->getEditForm()->fill($catalogPriceRule, null, $replace); $this->catalogRuleNew->getFormPageActions()->$saveAction(); - // Prepare data for tear down - $this->catalogRules[] = $catalogPriceRule; - // Create simple product with category $productSimple->persist(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index 67d98b313afe2..197914eccbedc 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -179,7 +179,7 @@ protected function updateCustomer(array $data) $curl->close(); if (!strpos($response, 'data-ui-id="messages-message-success"')) { - $this->_eventManager->dispatchEvent(['curl_failed', [$response]]); + $this->_eventManager->dispatchEvent(['curl_failed'], [$response]); throw new \Exception('Failed to update customer!'); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountCreate.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountCreate.xml index 783fa1ad4e1b4..57cf9a355142c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountCreate.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountCreate.xml @@ -6,8 +6,8 @@ */ --> - - - - + + + + diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/testcase.xml index 3ce7af8e5be7e..de5469059a9b8 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/etc/testcase.xml @@ -22,15 +22,9 @@ - - - + - - - - - + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php index b5631910c0d44..51476690a8897 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php @@ -11,15 +11,12 @@ use Magento\Checkout\Test\Page\CheckoutCart; use Magento\Customer\Test\Fixture\Address; use Magento\Customer\Test\Fixture\Customer; -use Magento\Customer\Test\Page\CustomerAccountLogin; -use Magento\Customer\Test\Page\CustomerAccountLogout; use Magento\Tax\Test\Fixture\TaxRule; use Magento\Mtf\Client\BrowserInterface; use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\Fixture\FixtureFactory; /** - * Class AssertTaxRuleApplying * Abstract class for implementing assert applying */ abstract class AssertTaxRuleApplying extends AbstractConstraint @@ -82,8 +79,6 @@ abstract protected function assert(); * * @param FixtureFactory $fixtureFactory * @param TaxRule $taxRule - * @param CustomerAccountLogin $customerAccountLogin - * @param CustomerAccountLogout $customerAccountLogout * @param Customer $customer * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart @@ -92,14 +87,10 @@ abstract protected function assert(); * @param BrowserInterface $browser * @param TaxRule $initialTaxRule * @return void - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function processAssert( FixtureFactory $fixtureFactory, TaxRule $taxRule, - CustomerAccountLogin $customerAccountLogin, - CustomerAccountLogout $customerAccountLogout, Customer $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, @@ -134,9 +125,10 @@ public function processAssert( ); $this->productSimple->persist(); // Customer login - $customerAccountLogout->open(); - $customerAccountLogin->open(); - $customerAccountLogin->getLoginBlock()->login($customer); + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $customer] + )->run(); // Clearing shopping cart and adding product to shopping cart $checkoutCart->open()->getCartBlock()->clearShoppingCart(); $browser->open($_ENV['app_frontend_url'] . $this->productSimple->getUrlKey() . '.html'); diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php new file mode 100644 index 0000000000000..ddfd3ab0508cc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.php @@ -0,0 +1,75 @@ + Taxes > Tax Rules. + * 3. Click 'Add New Tax Rule' button. + * 4. Assign default rates to rule. + * 5. Save Tax Rate. + * 6. Go to Products > Catalog. + * 7. Add new product. + * 8. Fill data according to dataset. + * 9. Save product. + * 10. Go to Stores > Configuration. + * 11. Fill Tax configuration according to data set. + * 12. Save tax configuration. + * 13. Perform all assertions. + * + * @group Tax_(CS) + * @ZephyrId MAGETWO-27809 + */ +class TaxCalculationTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Skip failed tests. + * + * @return void + */ + public static function setUpBeforeClass() + { + self::markTestIncomplete("Epic: MAGETWO-30073"); + } + + /** + * Runs tax calculation test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } + + /** + * Tear down after each test. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create('\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create('\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); + + // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'default_tax_configuration'] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.xml new file mode 100644 index 0000000000000..9891afcdf2d0f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxCalculationTest.xml @@ -0,0 +1,301 @@ + + + + + + Simple product tier price with sales rule, customer tax equals store tax and catalog price including tax + row_cat_incl_ship_excl_after_disc_on_excl, display_excluding_including_tax + catalogProductSimple::simple_with_tier_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_equals_store_rate + johndoe_unique + 3 + 277.14 + 300.00 + 277.14 + 300.00 + 13.86 + 15.00 + 41.57 + 45.00 + 41.57 + 45.00 + 20.79 + 15.00 + 16.24 + 3.09 + 37.36 + 40.45 + + + + + + Simple product group price with sales rule, customer tax greater than store tax and catalog price excluding tax + row_cat_excl_ship_incl_before_disc_on_incl, display_excluding_including_tax + catalogProductSimple::simple_with_group_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_greater_store_rate + johndoe_unique + 3 + 90.99 + 98.61 + 90.99 + 98.61 + 90.99 + 98.61 + 272.97 + 295.83 + 272.97 + 295.83 + 147.92 + 13.86 + 15.02 + 24.02 + 138.91 + 162.93 + + + + + + Simple product group price with sales rule, customer tax less than store tax and catalog price excluding tax + total_cat_excl_ship_incl_after_disc_on_excl, display_excluding_including_tax + catalogProductSimple::simple_with_group_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_less_store_rate + johndoe_unique + 3 + 90.99 + 98.50 + 90.99 + 98.50 + 90.99 + 98.50 + 272.97 + 295.49 + 272.97 + 295.49 + 136.49 + 13.84 + 14.98 + 12.40 + 150.32 + 162.72 + + + + + + Simple product special price with sales rule, customer tax less than store tax and catalog price including tax + row_cat_incl_ship_excl_before_disc_on_incl, display_excluding_including_tax + catalogProductSimple::product_with_special_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_less_store_rate + johndoe_unique + 3 + 83.05 + 89.90 + 83.05 + 89.90 + 83.05 + 89.90 + 249.15 + 269.70 + 249.15 + 269.70 + 134.85 + 15.00 + 16.24 + 21.79 + 129.30 + 151.09 + + + + + + Simple product tier price with sales rule, customer tax less than store tax and catalog price including tax + unit_cat_incl_ship_incl_before_disc_on_incl, display_excluding_including_tax + catalogProductSimple::simple_with_tier_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_less_store_rate + johndoe_unique + 3 + 276.81 + 299.65 + 276.81 + 299.65 + 13.84 + 14.98 + 41.52 + 44.94 + 41.52 + 44.94 + 22.47 + 13.84 + 14.98 + 4.56 + 32.89 + 37.45 + + + + + + Simple product special price with sales rule, customer tax equals store tax and catalog price excluding tax + total_cat_excl_ship_incl_before_disc_on_incl, display_excluding_including_tax + catalogProductSimple::product_with_special_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_equals_store_rate + johndoe_unique + 3 + 90.00 + 97.43 + 90.00 + 97.43 + 90.00 + 97.43 + 270.00 + 292.28 + 270.00 + 292.28 + 146.15 + 13.86 + 15.00 + 23.42 + 137.71 + 161.13 + + + + + + Simple product group price with sales rule, customer tax equals store tax and catalog price excluding tax + unit_cat_excl_ship_excl_after_disc_on_excl, display_excluding_including_tax + catalogProductSimple::simple_with_group_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_equals_store_rate + johndoe_unique + 3 + 90.99 + 98.50 + 90.99 + 98.50 + 90.99 + 98.50 + 272.97 + 295.50 + 272.97 + 295.50 + 136.49 + 15.00 + 16.24 + 12.49 + 151.48 + 163.97 + + + + + + Simple product special price with sales rule, customer tax greater than store tax and catalog price including tax + total_cat_incl_ship_excl_before_disc_on_excl, display_excluding_including_tax + catalogProductSimple::simple_with_group_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_greater_store_rate + johndoe_unique + 3 + 84.06 + 91.10 + 84.06 + 91.10 + 84.06 + 91.10 + 252.18 + 273.30 + 252.18 + 273.30 + 126.09 + 15.00 + 16.26 + 22.38 + 141.09 + 163.47 + + + + + + Simple product tier price with sales rule, customer tax greater than store tax and catalog price excluding tax + total_cat_excl_ship_incl_after_disc_on_incl, display_excluding_including_tax + catalogProductSimple::simple_with_tier_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_greater_store_rate + johndoe_unique + 3 + 300.00 + 325.13 + 300.00 + 325.13 + 15.00 + 16.26 + 45.00 + 48.77 + 45.00 + 48.77 + 24.39 + 13.86 + 15.02 + 2.89 + 34.47 + 37.36 + + + + + + Simple product special price with sales rule, customer tax greater than store tax and catalog price excluding tax + unit_cat_excl_ship_incl_after_disc_on_excl, display_excluding_including_tax + catalogProductSimple::product_with_special_price_and_category + active_sales_rule_for_all_groups_no_coupon + - + customer_greater_store_rate + johndoe_unique + 3 + 90.00 + 97.54 + 90.00 + 97.54 + 90.00 + 97.54 + 270.00 + 292.62 + 270.00 + 292.62 + 135.00 + 13.86 + 15.02 + 12.47 + 148.86 + 161.33 + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php new file mode 100644 index 0000000000000..5256125cd6230 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php @@ -0,0 +1,160 @@ + Taxes > Tax Rules. + * 3. Click 'Add New Tax Rule' button. + * 4. Assign 3 different rates for different addresses + * 5. Save Tax Rate. + * 6. Go to Products > Catalog. + * 7. Add new product. + * 8. Fill data according to dataset. + * 9. Save product. + * 10. Go to Stores > Configuration. + * 11. Fill Tax configuration according to data set. + * 12. Save tax configuration. + * 13. Register two customers on front end that will match two different rates + * 14. Login with each customer and verify prices + * + * @group Tax_(CS) + * @ZephyrId MAGETWO-29052 + */ +class TaxWithCrossBorderTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Fixture SalesRule. + * + * @var SalesRuleInjectable + */ + protected $salesRule; + + /** + * Fixture CatalogRule. + * + * @var CatalogRule + */ + protected $catalogRule; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Prepare data. + * + * @param FixtureFactory $fixtureFactory + * @return array + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->fixtureFactory = $fixtureFactory; + + return ['customers' => $this->createCustomers()]; + } + + /** + * Injection data. + * + * @return void + */ + public function __inject() + { + // TODO: Move test set up to "__prepare" method after fix bug MAGETWO-29331 + $taxRule = $this->fixtureFactory->createByCode('taxRule', ['dataSet' => 'cross_border_tax_rule']); + $taxRule->persist(); + } + + /** + * Create customers. + * + * @return array $customers + */ + protected function createCustomers() + { + $customersData = ['johndoe_unique_TX', 'johndoe_unique']; + $customers = []; + foreach ($customersData as $customerData) { + $customer = $this->fixtureFactory->createByCode('customer', ['dataSet' => $customerData]); + $customer->persist(); + $customers[] = $customer; + } + return $customers; + } + + /** + * Test product prices with tax. + * + * @param CatalogProductSimple $product + * @param string $configData + * @param SalesRuleInjectable $salesRule [optional] + * @param CatalogRule $catalogRule [optional] + * @return void + */ + public function test( + CatalogProductSimple $product, + $configData, + SalesRuleInjectable $salesRule = null, + CatalogRule $catalogRule = null + ) { + //Preconditions + if ($salesRule !== null) { + $salesRule->persist(); + $this->salesRule = $salesRule; + } + if ($catalogRule !== null) { + $catalogRule->persist(); + $this->catalogRule = $catalogRule; + } + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $configData] + )->run(); + $product->persist(); + } + + /** + * Tear down after test. + * + * @return void + */ + public function tearDown() + { + if (isset($this->salesRule)) { + $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->salesRule = null; + } + if (isset($this->catalogRule)) { + $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); + $this->catalogRule = null; + } + + // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 + $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'default_tax_configuration'] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.xml new file mode 100644 index 0000000000000..82218491cf409 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.xml @@ -0,0 +1,38 @@ + + + + + + with_one_custom_option_and_category + cross_border_enabled_price_incl_tax, display_excluding_including_tax + + + + product_with_category + cart_rule + cross_border_enabled_price_incl_tax, display_excluding_including_tax + + + + product_with_category + catalog_price_rule_priority_0 + cross_border_enabled_price_incl_tax, display_excluding_including_tax + + + + product_with_special_price_and_category + cross_border_enabled_price_incl_tax, display_excluding_including_tax + + + + product_with_category + cross_border_enabled_price_excl_tax, display_excluding_including_tax + + + + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/testcase.xml new file mode 100644 index 0000000000000..c47afe1a6a889 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/testcase.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml index 835509955c51d..28bf95af27ad8 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml @@ -28,7 +28,7 @@ - groupedProduct::three_simple_products + groupedProduct::three_simple_products_default_qty diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php index cce7949f993f6..2b96619bcae14 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.php @@ -11,34 +11,26 @@ use Magento\Cms\Test\Page\CmsIndex; use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\CustomerAccountIndex; -use Magento\Customer\Test\Page\CustomerAccountLogin; -use Magento\Customer\Test\Page\CustomerAccountLogout; use Magento\Wishlist\Test\Page\WishlistIndex; use Magento\Wishlist\Test\Page\WishlistShare; use Magento\Mtf\Client\BrowserInterface; use Magento\Mtf\TestCase\Injectable; /** - * Test Creation for ShareWishlistEntity - * - * Test Flow: - * * Preconditions: - * 1. Create Customer Account - * 2. Create product + * 1. Create Customer Account. + * 2. Create product. * * Steps: - * 1. Login to frontend as a Customer - * 2. Add product to Wish List - * 3. Click "Share Wish List" button - * 4. Fill in all data according to data set - * 5. Click "Share Wishlist" button - * 6. Perform all assertions + * 1. Login to frontend as a Customer. + * 2. Add product to Wish List. + * 3. Click "Share Wish List" button. + * 4. Fill in all data according to data set. + * 5. Click "Share Wishlist" button. + * 6. Perform all assertions. * * @group Wishlist_(CS) * @ZephyrId MAGETWO-23394 - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ShareWishlistEntityTest extends Injectable { @@ -49,56 +41,42 @@ class ShareWishlistEntityTest extends Injectable /* end tags */ /** - * Cms index page + * Cms index page. * * @var CmsIndex */ protected $cmsIndex; /** - * Customer login page - * - * @var CustomerAccountLogin - */ - protected $customerAccountLogin; - - /** - * Customer account index page + * Customer account index page. * * @var CustomerAccountIndex */ protected $customerAccountIndex; /** - * Product view page + * Product view page. * * @var CatalogProductView */ protected $catalogProductView; /** - * Page CustomerAccountLogout - * - * @var CustomerAccountLogout - */ - protected $customerAccountLogout; - - /** - * Wishlist index page + * Wishlist index page. * * @var WishlistIndex */ protected $wishlistIndex; /** - * Wishlist share page + * Wishlist share page. * * @var WishlistShare */ protected $wishlistShare; /** - * Prepare data + * Prepare data. * * @param Customer $customer * @param CatalogProductSimple $product @@ -118,12 +96,10 @@ public function __prepare( } /** - * Injection data + * Inject pages. * * @param CmsIndex $cmsIndex - * @param CustomerAccountLogin $customerAccountLogin * @param CustomerAccountIndex $customerAccountIndex - * @param CustomerAccountLogout $customerAccountLogout * @param CatalogProductView $catalogProductView * @param WishlistIndex $wishlistIndex * @param WishlistShare $wishlistShare @@ -131,24 +107,20 @@ public function __prepare( */ public function __inject( CmsIndex $cmsIndex, - CustomerAccountLogin $customerAccountLogin, CustomerAccountIndex $customerAccountIndex, - CustomerAccountLogout $customerAccountLogout, CatalogProductView $catalogProductView, WishlistIndex $wishlistIndex, WishlistShare $wishlistShare ) { $this->cmsIndex = $cmsIndex; - $this->customerAccountLogin = $customerAccountLogin; $this->customerAccountIndex = $customerAccountIndex; - $this->customerAccountLogout = $customerAccountLogout; $this->catalogProductView = $catalogProductView; $this->wishlistIndex = $wishlistIndex; $this->wishlistShare = $wishlistShare; } /** - * Share wish list + * Share wish list. * * @param BrowserInterface $browser * @param Customer $customer @@ -174,27 +146,16 @@ public function test( } /** - * Login customer + * Login customer. * * @param Customer $customer * @return void */ protected function loginCustomer(Customer $customer) { - $this->cmsIndex->open(); - if (!$this->cmsIndex->getLinksBlock()->isLinkVisible('Log Out')) { - $this->cmsIndex->getLinksBlock()->openLink("Log In"); - $this->customerAccountLogin->getLoginBlock()->login($customer); - } - } - - /** - * Log out after test - * - * @return void - */ - public function tearDown() - { - $this->customerAccountLogout->open(); + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $customer] + )->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.xml index 59dccc42d293c..8dd654cf89bbd 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ShareWishlistEntityTest.xml @@ -6,11 +6,11 @@ */ --> - - - JohnDoe123456789@example.com,JohnDoe987654321@example.com,JohnDoe123456abc@example.com - Sharing message. - - - + + + JohnDoe123456789@example.com,JohnDoe987654321@example.com,JohnDoe123456abc@example.com + Sharing message. + + + From 24b5cca87db39373eb8040c9076279554bebaf90 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Mon, 27 Apr 2015 14:58:23 +0300 Subject: [PATCH 03/16] MTA-2081: Analyse functional test failures - Sprint 11 --- .../ApplySeveralCatalogPriceRuleEntityTest.php | 12 ++++++------ .../CreateCatalogPriceRuleEntityTest.php | 10 +++++----- .../Test/TestCase/CreateCatalogRuleTest.php | 16 ++++++++-------- .../Test/TestStep/DeleteAllCatalogRulesStep.php | 1 + .../Test/TestStep/DeleteAllTermsEntityStep.php | 1 + .../Adminhtml/Order/Create/Items/ItemProduct.php | 11 ++++++----- .../Test/TestStep/DeleteAllSalesRuleStep.php | 1 + .../Tax/Test/TestStep/DeleteAllTaxRulesStep.php | 1 + 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php index b3f823578cf07..1ef4e30a3e542 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/ApplySeveralCatalogPriceRuleEntityTest.php @@ -10,14 +10,14 @@ /** * Preconditions: - * 1. Execute before each variation: - * - Delete all active catalog price rules - * - Create catalog price rule from dataSet using Curl + * 1. Execute before each variation: + * - Delete all active catalog price rules + * - Create catalog price rule from dataSet using Curl * * Steps: - * 1. Apply all created rules - * 2. Create simple product - * 3. Perform all assertions + * 1. Apply all created rules. + * 2. Create simple product. + * 3. Perform all assertions. * * @group Catalog_Price_Rules_(MX) * @ZephyrId MAGETWO-24780 diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php index 7da0460e3da1e..be62cb21448e5 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.php @@ -11,11 +11,11 @@ /** * Steps: * 1. Log in as default admin user. - * 2. Go to Marketing > Catalog Price Rules - * 3. Press "+" button to start create new catalog price rule - * 4. Fill in all data according to data set - * 5. Save rule - * 6. Perform appropriate assertions + * 2. Go to Marketing > Catalog Price Rules. + * 3. Press "+" button to start create new catalog price rule. + * 4. Fill in all data according to data set. + * 5. Save rule. + * 6. Perform appropriate assertions. * * @group Catalog_Price_Rules_(MX) * @ZephyrId MAGETWO-24341 diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php index acb29b8168ec6..18815f160fa7f 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogRuleTest.php @@ -14,14 +14,14 @@ /** * Steps: * 1. Log in as default admin user. - * 2. Go to Marketing > Catalog Price Rules - * 3. Press "+" button to start create new catalog price rule - * 4. Fill in all data according to data set - * 5. Save rule - * 6. Apply newly created catalog rule - * 7. Create simple product - * 8. Clear cache - * 9. Perform all assertions + * 2. Go to Marketing > Catalog Price Rules. + * 3. Press "+" button to start create new catalog price rule. + * 4. Fill in all data according to data set. + * 5. Save rule. + * 6. Apply newly created catalog rule. + * 7. Create simple product. + * 8. Clear cache. + * 9. Perform all assertions. * * @ticketId MAGETWO-23036 */ diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php index a30825ebf60af..dcc06c224c0ba 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php @@ -51,6 +51,7 @@ public function __construct( public function run() { $this->catalogRuleIndex->open(); + $this->catalogRuleIndex->getCatalogRuleGrid()->resetFilter(); while ($this->catalogRuleIndex->getCatalogRuleGrid()->isFirstRowVisible()) { $this->catalogRuleIndex->getCatalogRuleGrid()->openFirstRow(); $this->catalogRuleNew->getFormPageActions()->delete(); diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php index f57baf78acc59..3599882b174c1 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php @@ -52,6 +52,7 @@ public function __construct( public function run() { $this->agreementIndex->open(); + $this->agreementIndex->getAgreementGridBlock()->resetFilter(); while ($this->agreementIndex->getAgreementGridBlock()->isFirstRowVisible()) { $this->agreementIndex->getAgreementGridBlock()->openFirstRow(); $this->agreementNew->getPageActionsBlock()->delete(); diff --git a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php index 3627d161b35ab..77d38c0eb9774 100644 --- a/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php +++ b/dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Adminhtml/Order/Create/Items/ItemProduct.php @@ -29,11 +29,11 @@ class ItemProduct extends \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items protected $giftMessageForm = './/*[@role="dialog"][*[@id="gift_options_configure"]]'; /** - * Magento varienLoader.js loader. + * Magento loader. * * @var string */ - protected $loadingMask = '//*[@id="loading-mask"]/*[@id="loading_mask_loader"]'; + protected $loader = '[data-role="loader"]'; /** * Fill GiftMessage form. @@ -58,10 +58,11 @@ function () use ($giftMessageFormSelector, $browser) { ['element' => $this->browser->find($this->giftMessageForm, Locator::SELECTOR_XPATH)] ); $giftMessageForm->fill($giftMessage); - $loadingMask = $this->browser->find($this->loadingMask, Locator::SELECTOR_XPATH); + $loader = $this->loader; $this->browser->waitUntil( - function () use ($loadingMask) { - return !$loadingMask->isVisible() ? true : null; + function () use ($browser, $loader) { + $element = $this->browser->find($loader); + return $element->isVisible() == false ? true : null; } ); } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php index 0141a0506fd6e..98bf51e84f7c3 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php @@ -50,6 +50,7 @@ public function __construct( public function run() { $this->promoQuoteIndex->open(); + $this->promoQuoteIndex->getPromoQuoteGrid()->resetFilter(); while ($this->promoQuoteIndex->getPromoQuoteGrid()->isFirstRowVisible()) { $this->promoQuoteIndex->getPromoQuoteGrid()->openFirstRow(); $this->promoQuoteEdit->getFormPageActions()->delete(); diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php index 69b0cb8e48754..d24b2ca4c4de8 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php @@ -51,6 +51,7 @@ public function __construct( public function run() { $this->taxRuleIndexPage->open(); + $this->taxRuleIndexPage->getTaxRuleGrid()->resetFilter(); while ($this->taxRuleIndexPage->getTaxRuleGrid()->isFirstRowVisible()) { $this->taxRuleIndexPage->getTaxRuleGrid()->openFirstRow(); $this->taxRuleNewPage->getFormPageActions()->delete(); From c439fe01fa6786af992db0282ea94d8b38d397ed Mon Sep 17 00:00:00 2001 From: Oleksii Kolesnyk Date: Tue, 28 Apr 2015 19:38:03 +0300 Subject: [PATCH 04/16] MTA-587: Re-factor Test for Switch Currency --- .../System/Currency/MainPageActions.php | 33 ------- .../System/Currency/Rate/CurrencyRateForm.php | 40 ++++++++ .../System/Currency/Rate/FormPageActions.php | 22 +++++ .../Currency/{ => Rate}/GridPageActions.php | 19 +--- .../Page/Adminhtml/SystemCurrencyIndex.xml | 8 +- .../Test/Repository/ConfigData.xml | 11 +++ .../TestCase/EditCurrencySymbolEntityTest.php | 8 +- .../ResetCurrencySymbolEntityTest.php | 6 +- ...AssertCurrencyRateAppliedOnCatalogPage.php | 70 ++++++++++++++ .../AssertCurrencyRateSuccessSaveMessage.php | 46 ++++++++++ .../Directory/Test/Fixture/CurrencyRate.xml | 26 ++++++ .../Test/TestCase/CreateCurrencyRateTest.php | 92 +++++++++++++++++++ .../Test/TestCase/CreateCurrencyRateTest.xml | 21 +++++ 13 files changed, 345 insertions(+), 57 deletions(-) delete mode 100644 dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/MainPageActions.php create mode 100644 dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php create mode 100644 dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/FormPageActions.php rename dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/{ => Rate}/GridPageActions.php (68%) create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateSuccessSaveMessage.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/MainPageActions.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/MainPageActions.php deleted file mode 100644 index 14f7bf7af1bbe..0000000000000 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/MainPageActions.php +++ /dev/null @@ -1,33 +0,0 @@ -_rootElement->find($this->saveCurrentRate)->click(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php new file mode 100644 index 0000000000000..2ca45f1a233dc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php @@ -0,0 +1,40 @@ +getData(); + $inputRateSelector = sprintf($this->inputRateSelector, $data['currency_from'], $data['currency_to']); + $this->_rootElement->find($inputRateSelector)->setValue($data['rate']); + + return $this; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/FormPageActions.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/FormPageActions.php new file mode 100644 index 0000000000000..3c911026ad68c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/FormPageActions.php @@ -0,0 +1,22 @@ +isVisible() ? true : null; } ); - if ($this->getMessageBlock()->isVisibleMessage('warning')) { - throw new \Exception($this->getMessageBlock()->getWarningMessages()); - } - } - - /** - * Get message block. - * - * @return Messages - */ - protected function getMessageBlock() - { - return $this->blockFactory->create( - 'Magento\Backend\Test\Block\Messages', - ['element' => $this->_rootElement->find($this->message)] - ); } } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml index 2ab90fb8688eb..efcc314043ecb 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Page/Adminhtml/SystemCurrencyIndex.xml @@ -7,7 +7,9 @@ --> - - + + + + - \ No newline at end of file + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml index 1d7fabcdeb20a..3a87b180f8e9e 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml @@ -137,5 +137,16 @@ USD + + + + currency + 1 + + USD + EUR + + + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php index 5d2cc6badaa78..e95f6fa58f896 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php @@ -52,7 +52,7 @@ class EditCurrencySymbolEntityTest extends Injectable * Create simple product and inject pages. * * @param SystemCurrencySymbolIndex $currencySymbolIndex - * @param SystemCurrencyIndex $currencyIndex, + * @param SystemCurrencyIndex $currencyIndex , * @param FixtureFactory $fixtureFactory * @return array */ @@ -97,6 +97,7 @@ public function test(CurrencySymbolEntity $currencySymbol, $configData) * * @param string $configData * @return void + * @throws \Exception */ protected function importCurrencyRate($configData) { @@ -108,7 +109,10 @@ protected function importCurrencyRate($configData) // Import Exchange Rates for currencies $this->currencyIndex->open(); $this->currencyIndex->getGridPageActions()->clickImportButton(); - $this->currencyIndex->getMainPageActions()->saveCurrentRate(); + if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { + throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); + } + $this->currencyIndex->getFormPageActions()->save(); } /** diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php index f64c407f6aeff..c566775b4ff25 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php @@ -141,6 +141,7 @@ public function test( * * @param string $configData * @return void + * @throws \Exception */ protected function importCurrencyRate($configData) { @@ -152,7 +153,10 @@ protected function importCurrencyRate($configData) // Import Exchange Rates for currencies $this->currencyIndex->open(); $this->currencyIndex->getGridPageActions()->clickImportButton(); - $this->currencyIndex->getMainPageActions()->saveCurrentRate(); + if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { + throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); + } + $this->currencyIndex->getFormPageActions()->save(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php new file mode 100644 index 0000000000000..78208ee09cd4c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php @@ -0,0 +1,70 @@ +getCategoryIds()[0]; + $cmsIndex->open(); + $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + $actualPrice = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock()->getPrice(''); + + \PHPUnit_Framework_Assert::assertEquals( + $basePrice, + $actualPrice, + 'Wrong price is displayed on Category page.' + ); + + $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol); + $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + $actualPrice = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock()->getPrice(''); + + \PHPUnit_Framework_Assert::assertEquals( + $convertedPrice, + $actualPrice, + 'Wrong price is displayed on Category page.' + ); + } + + /** + * Returns a string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return "Currency rate has been applied correctly on Catalog page."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateSuccessSaveMessage.php new file mode 100644 index 0000000000000..3a9f7e82a3943 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateSuccessSaveMessage.php @@ -0,0 +1,46 @@ +getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $actualMessage, + 'Wrong success message is displayed.' + . "\nExpected: " . self::SUCCESS_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return 'Currency rate success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml new file mode 100644 index 0000000000000..54456743c0813 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml @@ -0,0 +1,26 @@ + + + + + + USD + EUR + 0.8 + + + + USD + + + EUR + + + 0.8 + + + diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php new file mode 100644 index 0000000000000..21864e1a4f1fa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -0,0 +1,92 @@ + Currency > Currency Rates; + * 3. Fill currency rate according to dataSet; + * 4. Click on 'Save Currency Rates' button; + * 5. Perform assertions. + * + * @group Directory_(CS) + * @ZephyrId MAGETWO-12427 + */ +class CreateCurrencyRateTest extends Injectable +{ + /* tags */ + const TEST_TYPE = 'acceptance_test'; + /* end tags */ + + /** + * Currency rate index page. + * + * @var SystemCurrencyIndex + */ + protected $currencyIndexPage; + + /** + * Inject data. + * + * @param SystemCurrencyIndex $currencyIndexPage + * @return array + */ + public function __inject(SystemCurrencyIndex $currencyIndexPage) + { + $this->currencyIndexPage = $currencyIndexPage; + + /** @var CatalogProductSimple $product */ + $product = $this->objectManager->create( + 'Magento\Catalog\Test\Fixture\CatalogProductSimple', + ['dataSet' => 'simple_10_dollar'] + ); + $product->persist(); + + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'config_currency_symbols_usd_and_eur'] + )->run(); + + return ['product' => $product]; + } + + /** + * Create currency rate test. + * + * @param CurrencyRate $currencyRate + * @return void + */ + public function test(CurrencyRate $currencyRate) + { + $this->currencyIndexPage->open(); + $this->currencyIndexPage->getCurrencyRateForm()->fill($currencyRate); + $this->currencyIndexPage->getFormPageActions()->save(); + } + + /** + * Reset currency config to default values. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'config_currency_symbols_usd'] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml new file mode 100644 index 0000000000000..1f12c47b0178a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml @@ -0,0 +1,21 @@ + + + + + + USD + EUR + 0.8 + currency_symbols_eur + $10.00 + €8.00 + + + + + From d5572d92a6a4baaa3b3b12777269f75feccf3489 Mon Sep 17 00:00:00 2001 From: Oleksii Kolesnyk Date: Wed, 29 Apr 2015 16:31:00 +0300 Subject: [PATCH 05/16] MTA-587: Re-factor Test for Switch Currency - Replace old fixtures, repos and handler by creating new ones with current approach --- .../System/Currency/Rate/CurrencyRateForm.php | 16 +-- .../System/Currency/Rate/CurrencyRateForm.xml | 15 +++ .../Test/Repository/ConfigData.xml | 11 ++ .../TestCase/CurrencySymbolEntityTest.php | 109 ++++++++++++++++++ .../TestCase/EditCurrencySymbolEntityTest.php | 82 +------------ .../ResetCurrencySymbolEntityTest.php | 106 +---------------- ...AssertCurrencyRateAppliedOnCatalogPage.php | 5 +- .../Directory/Test/Fixture/CurrencyRate.xml | 14 +-- .../Test/Handler/CurrencyRate/Curl.php | 56 +++++++++ .../CurrencyRate/CurrencyRateInterface.php | 17 +++ .../Test/Repository/CurrencyRate.xml | 22 ++++ .../Test/TestCase/CreateCurrencyRateTest.php | 39 +++---- .../Test/TestCase/CreateCurrencyRateTest.xml | 3 + .../Magento/Directory/Test/etc/curl/di.xml | 10 ++ 14 files changed, 276 insertions(+), 229 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml create mode 100644 dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/Curl.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/CurrencyRateInterface.php create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/Repository/CurrencyRate.xml create mode 100644 dev/tests/functional/tests/app/Magento/Directory/Test/etc/curl/di.xml diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php index 2ca45f1a233dc..64e4c5220adfc 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php @@ -15,13 +15,6 @@ */ class CurrencyRateForm extends Form { - /** - * Selector for input. - * - * @var string - */ - protected $inputRateSelector = 'input[name="rate[%s][%s]"]'; - /** * Fill currency rate form. * @@ -31,9 +24,12 @@ class CurrencyRateForm extends Form */ public function fill(FixtureInterface $fixture, SimpleElement $element = null) { - $data = $fixture->getData(); - $inputRateSelector = sprintf($this->inputRateSelector, $data['currency_from'], $data['currency_to']); - $this->_rootElement->find($inputRateSelector)->setValue($data['rate']); + $fixtureData = $fixture->getData(); + $this->placeholders['currency_from'] = $fixtureData['currency_from']; + $this->placeholders['currency_to'] = $fixtureData['currency_to']; + $this->applyPlaceholders(); + $mapping = $this->dataMapping(['rate' => $fixtureData['rate']]); + $this->_fill($mapping, $element); return $this; } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml new file mode 100644 index 0000000000000..4ffc8f05740d4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.xml @@ -0,0 +1,15 @@ + + + + rate + + + input[name="rate[%currency_from%][%currency_to%]"] + + + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml index 3a87b180f8e9e..17373832ad976 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Repository/ConfigData.xml @@ -148,5 +148,16 @@ + + + + currency + 1 + + USD + GBP + + + diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php new file mode 100644 index 0000000000000..3f98754bb744c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php @@ -0,0 +1,109 @@ +fixtureFactory = $fixtureFactory; + $product = $this->fixtureFactory->createByCode( + 'catalogProductSimple', + ['dataSet' => 'product_with_category'] + ); + $product->persist(); + + return ['product' => $product]; + } + + /** + * Create simple product and inject pages. + * + * @param SystemCurrencySymbolIndex $currencySymbolIndex + * @param SystemCurrencyIndex $currencyIndex + * @return void + */ + public function __inject( + SystemCurrencySymbolIndex $currencySymbolIndex, + SystemCurrencyIndex $currencyIndex + ) { + $this->currencySymbolIndex = $currencySymbolIndex; + $this->currencyIndex = $currencyIndex; + } + + /** + * Import currency rates. + * + * @param string $configData + * @return void + * @throws \Exception + */ + protected function importCurrencyRate($configData) + { + $this->objectManager->getInstance()->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $configData] + )->run(); + + // Import Exchange Rates for currencies + $this->currencyIndex->open(); + $this->currencyIndex->getGridPageActions()->clickImportButton(); + if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { + throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); + } + $this->currencyIndex->getFormPageActions()->save(); + } + + /** + * Disabling currency which has been added. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->getInstance()->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'config_currency_symbols_usd'] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php index e95f6fa58f896..bdf2cbf9897af 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php @@ -6,12 +6,8 @@ namespace Magento\CurrencySymbol\Test\TestCase; -use Magento\Mtf\TestCase\Injectable; -use Magento\Mtf\Fixture\FixtureFactory; use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\CurrencySymbol\Test\Fixture\CurrencySymbolEntity; -use Magento\CurrencySymbol\Test\Page\Adminhtml\SystemCurrencyIndex; -use Magento\CurrencySymbol\Test\Page\Adminhtml\SystemCurrencySymbolIndex; /** * Preconditions: @@ -27,53 +23,13 @@ * @group Currency_(PS) * @ZephyrId MAGETWO-26600 */ -class EditCurrencySymbolEntityTest extends Injectable +class EditCurrencySymbolEntityTest extends CurrencySymbolEntityTest { /* tags */ const MVP = 'no'; const DOMAIN = 'PS'; /* end tags */ - /** - * System Currency Symbol grid page. - * - * @var SystemCurrencySymbolIndex - */ - protected $currencySymbolIndex; - - /** - * System currency index page. - * - * @var SystemCurrencyIndex - */ - protected $currencyIndex; - - /** - * Create simple product and inject pages. - * - * @param SystemCurrencySymbolIndex $currencySymbolIndex - * @param SystemCurrencyIndex $currencyIndex , - * @param FixtureFactory $fixtureFactory - * @return array - */ - public function __inject( - SystemCurrencySymbolIndex $currencySymbolIndex, - SystemCurrencyIndex $currencyIndex, - FixtureFactory $fixtureFactory - ) { - $this->currencySymbolIndex = $currencySymbolIndex; - $this->currencyIndex = $currencyIndex; - - /**@var CatalogProductSimple $catalogProductSimple */ - $product = $fixtureFactory->createByCode( - 'catalogProductSimple', - ['dataSet' => 'product_with_category'] - ); - $product->persist(); - - return ['product' => $product]; - } - /** * Edit Currency Symbol Entity test. * @@ -91,40 +47,4 @@ public function test(CurrencySymbolEntity $currencySymbol, $configData) $this->currencySymbolIndex->getCurrencySymbolForm()->fill($currencySymbol); $this->currencySymbolIndex->getPageActions()->save(); } - - /** - * Import currency rates. - * - * @param string $configData - * @return void - * @throws \Exception - */ - protected function importCurrencyRate($configData) - { - $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => $configData] - )->run(); - - // Import Exchange Rates for currencies - $this->currencyIndex->open(); - $this->currencyIndex->getGridPageActions()->clickImportButton(); - if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { - throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); - } - $this->currencyIndex->getFormPageActions()->save(); - } - - /** - * Disabling currency which has been added. - * - * @return void - */ - public function tearDown() - { - $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => 'config_currency_symbols_usd'] - )->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php index c566775b4ff25..767ae80be8a44 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php @@ -6,12 +6,8 @@ namespace Magento\CurrencySymbol\Test\TestCase; -use Magento\Mtf\TestCase\Injectable; -use Magento\Mtf\Fixture\FixtureFactory; use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\CurrencySymbol\Test\Fixture\CurrencySymbolEntity; -use Magento\CurrencySymbol\Test\Page\Adminhtml\SystemCurrencyIndex; -use Magento\CurrencySymbol\Test\Page\Adminhtml\SystemCurrencySymbolIndex; /** * Preconditions: @@ -28,77 +24,13 @@ * @group Currency_(PS) * @ZephyrId MAGETWO-26638 */ -class ResetCurrencySymbolEntityTest extends Injectable +class ResetCurrencySymbolEntityTest extends CurrencySymbolEntityTest { /* tags */ const MVP = 'no'; const DOMAIN = 'PS'; /* end tags */ - /** - * System currency symbol grid page. - * - * @var SystemCurrencySymbolIndex - */ - protected $currencySymbolIndex; - - /** - * System currency index page. - * - * @var SystemCurrencyIndex - */ - protected $currencyIndex; - - /** - * Currency symbol entity fixture. - * - * @var CurrencySymbolEntity - */ - protected $currencySymbolDefault; - - /** - * Fixture Factory. - * - * @var FixtureFactory - */ - protected $fixtureFactory; - - /** - * Prepare data. Create simple product. - * - * @param FixtureFactory $fixtureFactory - * @return array - */ - public function __prepare(FixtureFactory $fixtureFactory) - { - $this->fixtureFactory = $fixtureFactory; - $product = $this->fixtureFactory->createByCode( - 'catalogProductSimple', - ['dataSet' => 'product_with_category'] - ); - $product->persist(); - - return ['product' => $product]; - } - - /** - * Injection data. - * - * @param SystemCurrencySymbolIndex $currencySymbolIndex - * @param SystemCurrencyIndex $currencyIndex - * @param CurrencySymbolEntity $currencySymbolDefault - * @return array - */ - public function __inject( - SystemCurrencySymbolIndex $currencySymbolIndex, - SystemCurrencyIndex $currencyIndex, - CurrencySymbolEntity $currencySymbolDefault - ) { - $this->currencySymbolIndex = $currencySymbolIndex; - $this->currencyIndex = $currencyIndex; - $this->currencySymbolDefault = $currencySymbolDefault; - } - /** * Reset Currency Symbol Entity test. * @@ -135,40 +67,4 @@ public function test( ) ]; } - - /** - * Import currency rates. - * - * @param string $configData - * @return void - * @throws \Exception - */ - protected function importCurrencyRate($configData) - { - $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => $configData] - )->run(); - - // Import Exchange Rates for currencies - $this->currencyIndex->open(); - $this->currencyIndex->getGridPageActions()->clickImportButton(); - if ($this->currencyIndex->getMessagesBlock()->isVisibleMessage('warning')) { - throw new \Exception($this->currencyIndex->getMessagesBlock()->getWarningMessages()); - } - $this->currencyIndex->getFormPageActions()->save(); - } - - /** - * Disabling currency which has been added. - * - * @return void - */ - public function tearDown() - { - $this->objectManager->getInstance()->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => 'config_currency_symbols_usd'] - )->run(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php index 78208ee09cd4c..05cd0245e1a75 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php @@ -39,7 +39,8 @@ public function processAssert( $categoryName = $product->getCategoryIds()[0]; $cmsIndex->open(); $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); - $actualPrice = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock()->getPrice(''); + $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock(); + $actualPrice = $priceBlock->getPrice(''); \PHPUnit_Framework_Assert::assertEquals( $basePrice, @@ -49,7 +50,7 @@ public function processAssert( $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol); $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); - $actualPrice = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock()->getPrice(''); + $actualPrice = $priceBlock->getPrice(''); \PHPUnit_Framework_Assert::assertEquals( $convertedPrice, diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml index 54456743c0813..70fcf15c96298 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml @@ -6,21 +6,15 @@ */ --> - + USD EUR 0.8 - - USD - - - EUR - - - 0.8 - + + + diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/Curl.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/Curl.php new file mode 100644 index 0000000000000..cc6fbf9895588 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/Curl.php @@ -0,0 +1,56 @@ +prepareData($fixture); + + $url = $_ENV['app_backend_url'] . 'admin/system_currency/saveRates/'; + $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); + $curl->write(CurlInterface::POST, $url, '1.0', [], $data); + $response = $curl->read(); + $curl->close(); + + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception("Currency rates setting by curl handler was not successful! Response:\n" . $response); + } + } + + /** + * Prepare data for POST request. + * + * @param FixtureInterface $fixture + * @return array + */ + protected function prepareData(FixtureInterface $fixture) + { + $result = []; + $data = $fixture->getData(); + $result['rate'][$data['currency_from']][$data['currency_to']] = $data['rate']; + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/CurrencyRateInterface.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/CurrencyRateInterface.php new file mode 100644 index 0000000000000..99cc0f552b190 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Handler/CurrencyRate/CurrencyRateInterface.php @@ -0,0 +1,17 @@ + + + + + + USD + CHF + 0.9 + + + + USD + GBP + 0.6 + + + diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php index 21864e1a4f1fa..e7331e676de7f 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -13,23 +13,24 @@ /** * Preconditions: - * 1. Create Simple product and assign it to the category; + * 1. Create Simple product and assign it to the category. * 2. Configure allowed Currencies Options. * * Steps: * 1. Login to backend. - * 2. Go to Stores > Currency > Currency Rates; - * 3. Fill currency rate according to dataSet; - * 4. Click on 'Save Currency Rates' button; + * 2. Go to Stores > Currency > Currency Rates. + * 3. Fill currency rate according to dataSet. + * 4. Click on 'Save Currency Rates' button. * 5. Perform assertions. * - * @group Directory_(CS) + * @group Localization_(PS) * @ZephyrId MAGETWO-12427 */ class CreateCurrencyRateTest extends Injectable { /* tags */ const TEST_TYPE = 'acceptance_test'; + const DOMAIN = 'PS'; /* end tags */ /** @@ -43,35 +44,31 @@ class CreateCurrencyRateTest extends Injectable * Inject data. * * @param SystemCurrencyIndex $currencyIndexPage - * @return array + * @return void */ public function __inject(SystemCurrencyIndex $currencyIndexPage) { $this->currencyIndexPage = $currencyIndexPage; - - /** @var CatalogProductSimple $product */ - $product = $this->objectManager->create( - 'Magento\Catalog\Test\Fixture\CatalogProductSimple', - ['dataSet' => 'simple_10_dollar'] - ); - $product->persist(); - - $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => 'config_currency_symbols_usd_and_eur'] - )->run(); - - return ['product' => $product]; } /** * Create currency rate test. * * @param CurrencyRate $currencyRate + * @param CatalogProductSimple $product + * @param $config * @return void */ - public function test(CurrencyRate $currencyRate) + public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, $config) { + // Preconditions: + $product->persist(); + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $config] + )->run(); + + // Steps: $this->currencyIndexPage->open(); $this->currencyIndexPage->getCurrencyRateForm()->fill($currencyRate); $this->currencyIndexPage->getFormPageActions()->save(); diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml index 1f12c47b0178a..0167104dd192e 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml @@ -12,8 +12,11 @@ EUR 0.8 currency_symbols_eur + simple_10_dollar + config_currency_symbols_usd_and_eur $10.00 €8.00 + test_type:acceptance_test diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/etc/curl/di.xml new file mode 100644 index 0000000000000..0962d9ed807d9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/etc/curl/di.xml @@ -0,0 +1,10 @@ + + + + + From 07de6086096fb70596923ae198d39d4a105e9eb5 Mon Sep 17 00:00:00 2001 From: Oleksandr Manchenko Date: Wed, 29 Apr 2015 18:18:17 +0300 Subject: [PATCH 06/16] MTA-584: Re-factor Test for Layered Navigation --- .../Test/Block/Product/ListProduct.php | 24 ++++ .../Page/Category/CatalogCategoryView.xml | 1 - .../Test/Repository/CatalogProductSimple.xml | 26 ++++ .../Test/Block/Navigation.php | 64 ++++----- .../Constraint/AssertFilterProductList.php | 91 +++++++++++++ .../Page/Category/CatalogCategoryView.xml | 12 ++ .../Test/Repository/ConfigData.xml | 45 +++++++ .../Test/TestCase/FilterProductListTest.php | 125 ++++++++++++++++++ .../Test/TestCase/FilterProductListTest.xml | 30 +++++ 9 files changed, 378 insertions(+), 40 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php create mode 100644 dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Page/Category/CatalogCategoryView.xml create mode 100644 dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml create mode 100644 dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php create mode 100644 dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php index 535cc6ef859ea..c4a1925081da6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/ListProduct.php @@ -23,6 +23,13 @@ class ListProduct extends Block */ protected $productItem = './/*[contains(@class,"product-item-link") and normalize-space(text())="%s"]/ancestor::li'; + /** + * Locator for product item link. + * + * @var string + */ + protected $productItemLink = '.product-item-link'; + /** * Sorter dropdown selector. * @@ -46,6 +53,23 @@ public function getProductItem(FixtureInterface $product) ); } + /** + * Get product names list. + * + * @return array + */ + public function getProductNames() + { + $itemLinks = $this->_rootElement->getElements($this->productItemLink); + $productNames = []; + + foreach ($itemLinks as $itemLink) { + $productNames[] = trim($itemLink->getText()); + } + + return $productNames; + } + /** * Get all terms used in sort. * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index 392a1ff131e7f..45839712e35c6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -8,7 +8,6 @@ - diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index 4998c9d960474..b919ad39c1045 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -65,6 +65,32 @@ + + + default + + product_20_dollar %isolation% + sku_product_20_dollar_%isolation% + No + 1 + + 1000 + In Stock + + + 20 + - + + + taxable_goods + + + Main Website + + Catalog, Search + product-20-dollar-%isolation% + + Simple Product %isolation% sku_simple_product_%isolation% diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php index 41376ef7a3735..1b0ff0a55ce03 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php @@ -3,13 +3,14 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\LayeredNavigation\Test\Block; use Magento\Mtf\Block\Block; use Magento\Mtf\Client\Locator; /** - * Catalog layered navigation view block + * Catalog layered navigation view block. */ class Navigation extends Block { @@ -20,20 +21,6 @@ class Navigation extends Block */ protected $clearAll = '.action.clear'; - /** - * Price range. - * - * @var string - */ - protected $priceRange = "[href$='?price=%s']"; - - /** - * Attribute option. - * - * @var string - */ - protected $attributeOption = "//a[contains(text(), '%s')]"; - /** * Attribute option title selector. * @@ -42,11 +29,11 @@ class Navigation extends Block protected $optionTitle = '.filter-options-title'; /** - * Attribute option content selector. + * Filter link locator. * * @var string */ - protected $optionContent = '.filter-options-content'; + protected $filterLink = './/dt[contains(text(),"%s")]/following-sibling::dd//a'; /** * Click on 'Clear All' link. @@ -58,28 +45,6 @@ public function clearAll() $this->_rootElement->find($this->clearAll, locator::SELECTOR_CSS)->click(); } - /** - * Select product price range. - * - * @param string $range - * @return void - */ - public function selectPriceRange($range) - { - $this->_rootElement->find(sprintf($this->priceRange, $range))->click(); - } - - /** - * Select attribute option. - * - * @param string $optionName - * @return void - */ - public function selectAttributeOption($optionName) - { - $this->_rootElement->find(sprintf($this->attributeOption, $optionName), Locator::SELECTOR_XPATH)->click(); - } - /** * Get array of available filters. * @@ -94,4 +59,25 @@ public function getFilters() } return $data; } + + /** + * Open filter link. + * + * @param string $filter + * @param string $linkPattern + * @return void + * @throws \Exception + */ + public function openFilterLink($filter, $linkPattern) + { + $links = $this->_rootElement->getElements(sprintf($this->filterLink, $filter), Locator::SELECTOR_XPATH); + + foreach ($links as $link) { + if (preg_match($linkPattern, trim($link->getText()))) { + $link->click(); + return; + } + } + throw new \Exception("Can't find {$filter} filter link by pattern: {$linkPattern}"); + } } diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php new file mode 100644 index 0000000000000..02b67de95a6d6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php @@ -0,0 +1,91 @@ +products = $products; + $cmsIndex->open(); + $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); + + foreach ($asserts as $assert) { + $catalogCategoryView->getLayeredNavigationBlock()->openFilterLink( + $assert['filter'], + $assert['linkPattern'] + ); + + $productNames = $this->getProductNames($assert['products']); + sort($productNames); + $pageProductNames = $catalogCategoryView->getListProductBlock()->getProductNames(); + sort($pageProductNames); + \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames); + + $catalogCategoryView->getLayeredNavigationBlock()->clearAll(); + } + } + + /** + * Get product names list by keys. + * + * @param string $productKeys + * @return array + */ + protected function getProductNames($productKeys) + { + $keys = array_map('trim', explode(',', $productKeys)); + $productNames = []; + + foreach ($keys as $key) { + $key = str_replace('product_', '', $key); + $productNames[] = $this->products[$key]->getName(); + } + + return $productNames; + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Filtered product list via layered navigation are displayed correctly.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Page/Category/CatalogCategoryView.xml new file mode 100644 index 0000000000000..c3b68e9dd74cc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Page/Category/CatalogCategoryView.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml new file mode 100644 index 0000000000000..5540779491e99 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml @@ -0,0 +1,45 @@ + + + + + + + default + 0 + 1 + + + default + 0 + manual + + + default + 0 + 10 + + + default + 0 + 10 + + + + + default + 0 + 1 + + + default + 0 + auto + + + + diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php new file mode 100644 index 0000000000000..98c741c3d1baa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php @@ -0,0 +1,125 @@ +fixtureFactory = $fixtureFactory; + $this->configData = $configData; + $this->category = $category; + + // Preconditions + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData] + )->run(); + + // Steps + $this->category->persist(); + $products = $this->prepareProducts($products); + + return ['products' => $products]; + } + + /** + * Create products and assign to category. + * + * @param string $products + * @return FixtureInterface[] + */ + public function prepareProducts($products) + { + $products = array_map('trim', explode(',', $products)); + $result = []; + + foreach ($products as $productData) { + list($productCode, $dataSet) = explode('::', $productData); + $product = $this->fixtureFactory->createByCode( + $productCode, + [ + 'dataSet' => $dataSet, + 'data' => [ + 'category_ids' => [ + 'presets' => null, + 'category' => $this->category + ] + ] + ] + ); + + $product->persist(); + $result[] = $product; + } + + return $result; + } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData, 'rollback' => true] + )->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml new file mode 100644 index 0000000000000..094ab8506cad7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml @@ -0,0 +1,30 @@ + + + + + + layered_navigation_manual + default_anchor_subcategory + catalogProductSimple::product_20_dollar, configurableProduct::filterable_two_options_with_zero_price + + + Price + `^.+10\.00 - .+19\.99 1$`m + product_1 + + + attribute_dropdown + `^option_0_[0-9]+ 1$`m + product_1 + + + test_type:acceptance_test + + + + From a3ddd7813ebd0c031f3fe423abc4ada15690af36 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Wed, 29 Apr 2015 19:00:34 +0300 Subject: [PATCH 07/16] MTA-578: Re-factor Test for Shopping Cart Price Rule --- .../Block/Adminhtml/Order/Create/Coupons.php | 6 +++--- .../Test/Fixture/OrderInjectable/CouponCode.php | 6 +++--- .../Sales/Test/Handler/OrderInjectable/Curl.php | 6 +++--- .../Constraint/AssertCartPriceRuleApplying.php | 10 +++++----- .../Test/Constraint/AssertCartPriceRuleForm.php | 10 +++++----- .../AssertCartPriceRuleIsNotPresentedInGrid.php | 6 +++--- .../{SalesRuleInjectable.xml => SalesRule.xml} | 4 ++-- .../ConditionsSerialized.php | 2 +- .../{SalesRuleInjectable => SalesRule}/Curl.php | 4 ++-- .../SalesRuleInterface.php} | 4 ++-- .../{SalesRuleInjectable.xml => SalesRule.xml} | 2 +- .../Test/TestCase/CreateSalesRuleEntityTest.php | 6 +++--- .../Test/TestCase/DeleteSalesRuleEntityTest.php | 6 +++--- .../Test/TestCase/UpdateSalesRuleEntityTest.php | 10 +++++----- .../TestStep/ApplySalesRuleOnBackendStep.php | 8 ++++---- .../TestStep/ApplySalesRuleOnFrontendStep.php | 8 ++++---- .../Test/TestStep/CreateSalesRuleStep.php | 2 +- .../app/Magento/SalesRule/Test/etc/curl/di.xml | 2 +- .../functional/utils/config/ee_modules.yml.dist | 5 ----- .../utils/config/generator_config.yml.dist | 16 ---------------- 20 files changed, 51 insertions(+), 72 deletions(-) rename dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/{SalesRuleInjectable.xml => SalesRule.xml} (90%) rename dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/{SalesRuleInjectable => SalesRule}/ConditionsSerialized.php (94%) rename dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/{SalesRuleInjectable => SalesRule}/Curl.php (97%) rename dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/{SalesRuleInjectable/SalesRuleInjectableInterface.php => SalesRule/SalesRuleInterface.php} (61%) rename dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/{SalesRuleInjectable.xml => SalesRule.xml} (99%) delete mode 100644 dev/tests/functional/utils/config/ee_modules.yml.dist delete mode 100644 dev/tests/functional/utils/config/generator_config.yml.dist diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php index e118bac1958fb..0a350725839b9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php @@ -7,7 +7,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Create; use Magento\Backend\Test\Block\Widget\Form; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Client\Locator; /** @@ -32,10 +32,10 @@ class Coupons extends Form /** * Enter discount code and click apply button. * - * @param SalesRuleInjectable $code + * @param SalesRule $code * @return void */ - public function applyCouponCode(SalesRuleInjectable $code) + public function applyCouponCode(SalesRule $code) { $this->_rootElement->find($this->couponCode)->setValue($code->getCouponCode()); $this->_rootElement->find($this->applyButton, Locator::SELECTOR_XPATH)->click(); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CouponCode.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CouponCode.php index b3d081c56d4c7..0a28aff4f63e9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CouponCode.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CouponCode.php @@ -6,7 +6,7 @@ namespace Magento\Sales\Test\Fixture\OrderInjectable; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\Fixture\DataSource; @@ -24,12 +24,12 @@ class CouponCode extends DataSource public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) { $this->params = $params; - if (isset($data['value']) && $data['value'] instanceof SalesRuleInjectable) { + if (isset($data['value']) && $data['value'] instanceof SalesRule) { $this->data = $data['value']; return; } if (isset($data['dataSet'])) { - $salesRule = $fixtureFactory->createByCode('salesRuleInjectable', ['dataSet' => $data['dataSet']]); + $salesRule = $fixtureFactory->createByCode('salesRule', ['dataSet' => $data['dataSet']]); $salesRule->persist(); $this->data = $salesRule; } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Curl.php index e98f4ba0afff5..7d993cb5f0094 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Curl.php @@ -11,7 +11,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Downloadable\Test\Fixture\DownloadableProduct; use Magento\Sales\Test\Fixture\OrderInjectable; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\Handler\Curl as AbstractCurl; use Magento\Mtf\Util\Protocol\CurlInterface; @@ -111,10 +111,10 @@ protected function prepareData(FixtureInterface $fixture) /** * Prepare coupon data. * - * @param SalesRuleInjectable $data + * @param SalesRule $data * @return array */ - protected function prepareCouponCode(SalesRuleInjectable $data) + protected function prepareCouponCode(SalesRule $data) { return ['order' => ['coupon' => ['code' => $data->getCouponCode()]]]; } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php index 1b573901d93ca..a9307ce813213 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php @@ -15,7 +15,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\CustomerAccountLogin; use Magento\Customer\Test\Page\CustomerAccountLogout; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Constraint\AbstractConstraint; /** @@ -121,8 +121,8 @@ abstract protected function assert(); * @param CatalogCategoryView $catalogCategoryView * @param CatalogProductView $catalogProductView * @param Customer $customer - * @param SalesRuleInjectable $salesRule - * @param SalesRuleInjectable $salesRuleOrigin + * @param SalesRule $salesRule + * @param SalesRule $salesRuleOrigin * @param array $productQuantity * @param CatalogProductSimple $productForSalesRule1 * @param CatalogProductSimple $productForSalesRule2 @@ -141,8 +141,8 @@ public function processAssert( CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, Customer $customer, - SalesRuleInjectable $salesRule, - SalesRuleInjectable $salesRuleOrigin, + SalesRule $salesRule, + SalesRule $salesRuleOrigin, array $productQuantity, CatalogProductSimple $productForSalesRule1, CatalogProductSimple $productForSalesRule2 = null, diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleForm.php index ccd77f877ced2..d8a6445267051 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleForm.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleForm.php @@ -6,7 +6,7 @@ namespace Magento\SalesRule\Test\Constraint; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -34,15 +34,15 @@ class AssertCartPriceRuleForm extends AbstractConstraint * * @param PromoQuoteIndex $promoQuoteIndex * @param PromoQuoteEdit $promoQuoteEdit - * @param SalesRuleInjectable $salesRule - * @param SalesRuleInjectable $salesRuleOrigin + * @param SalesRule $salesRule + * @param SalesRule $salesRuleOrigin * @return void */ public function processAssert( PromoQuoteIndex $promoQuoteIndex, PromoQuoteEdit $promoQuoteEdit, - SalesRuleInjectable $salesRule, - SalesRuleInjectable $salesRuleOrigin = null + SalesRule $salesRule, + SalesRule $salesRuleOrigin = null ) { $filter = [ 'name' => $salesRule->hasData('name') ? $salesRule->getName() : $salesRuleOrigin->getName(), diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleIsNotPresentedInGrid.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleIsNotPresentedInGrid.php index 4c2fd8856a08f..a0914721420c8 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleIsNotPresentedInGrid.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleIsNotPresentedInGrid.php @@ -6,7 +6,7 @@ namespace Magento\SalesRule\Test\Constraint; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -19,10 +19,10 @@ class AssertCartPriceRuleIsNotPresentedInGrid extends AbstractConstraint * Assert that sales rule is not present in cart price rules grid. * * @param PromoQuoteIndex $promoQuoteIndex - * @param SalesRuleInjectable $salesRule + * @param SalesRule $salesRule * @return void */ - public function processAssert(PromoQuoteIndex $promoQuoteIndex, SalesRuleInjectable $salesRule) + public function processAssert(PromoQuoteIndex $promoQuoteIndex, SalesRule $salesRule) { \PHPUnit_Framework_Assert::assertFalse( $promoQuoteIndex->getPromoQuoteGrid()->isRowVisible(['name' => $salesRule->getName()]), diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule.xml similarity index 90% rename from dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml rename to dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule.xml index 25f432794e843..9008a93b8a36b 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule.xml @@ -6,7 +6,7 @@ */ --> - + Default price rule %isolation% Active @@ -36,7 +36,7 @@ Active - + 1 diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable/ConditionsSerialized.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule/ConditionsSerialized.php similarity index 94% rename from dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable/ConditionsSerialized.php rename to dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule/ConditionsSerialized.php index 4d9c65cff5333..d323abf4b46bd 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable/ConditionsSerialized.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRule/ConditionsSerialized.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +namespace Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Fixture\DataSource; diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/Curl.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php similarity index 97% rename from dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/Curl.php rename to dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php index 2543ccdf81971..d1c4bdee2f717 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/Curl.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\SalesRule\Test\Handler\SalesRuleInjectable; +namespace Magento\SalesRule\Test\Handler\SalesRule; use Magento\Backend\Test\Handler\Conditions; use Magento\Mtf\Fixture\FixtureInterface; @@ -15,7 +15,7 @@ /** * Curl handler for creating sales rule. */ -class Curl extends Conditions implements SalesRuleInjectableInterface +class Curl extends Conditions implements SalesRuleInterface { /** * Map of type parameter. diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/SalesRuleInjectableInterface.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/SalesRuleInterface.php similarity index 61% rename from dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/SalesRuleInjectableInterface.php rename to dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/SalesRuleInterface.php index 0a9c2598e8c49..d638e854cf273 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/SalesRuleInjectableInterface.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/SalesRuleInterface.php @@ -4,14 +4,14 @@ * See COPYING.txt for license details. */ -namespace Magento\SalesRule\Test\Handler\SalesRuleInjectable; +namespace Magento\SalesRule\Test\Handler\SalesRule; use Magento\Mtf\Handler\HandlerInterface; /** * Interface SalesRuleInterface. */ -interface SalesRuleInjectableInterface extends HandlerInterface +interface SalesRuleInterface extends HandlerInterface { // } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRule.xml similarity index 99% rename from dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml rename to dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRule.xml index 02d81f565a253..897aa57c1bf7f 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRule.xml @@ -6,7 +6,7 @@ */ --> - + Shopping Cart Price Rule with Specific Coupon %isolation% Description for Cart Price Rule diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php index 24bafea36fbe4..e82c3e9bcc2c2 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\SalesRule\Test\TestCase; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteNew; @@ -115,10 +115,10 @@ public function __prepare(FixtureFactory $fixtureFactory) /** * Create Sales Rule Entity. * - * @param SalesRuleInjectable $salesRule + * @param SalesRule $salesRule * @return void */ - public function testCreateSalesRule(SalesRuleInjectable $salesRule) + public function testCreateSalesRule(SalesRule $salesRule) { // Preconditions $this->salesRuleName = $salesRule->getName(); diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php index 49f3e7655790d..3dcf7ad8e3a6d 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\SalesRule\Test\TestCase; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\Mtf\TestCase\Injectable; @@ -63,10 +63,10 @@ public function __inject( /** * Delete Sales Rule Entity. * - * @param SalesRuleInjectable $salesRule + * @param SalesRule $salesRule * @return void */ - public function testDeleteSalesRule(SalesRuleInjectable $salesRule) + public function testDeleteSalesRule(SalesRule $salesRule) { // Preconditions $salesRule->persist(); diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php index ed72d923f05b1..93e0e86280525 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php @@ -6,7 +6,7 @@ namespace Magento\SalesRule\Test\TestCase; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; use Magento\Mtf\Fixture\FixtureFactory; @@ -92,13 +92,13 @@ public function __inject( /** * Update Sales Rule Entity. * - * @param SalesRuleInjectable $salesRule - * @param SalesRuleInjectable $salesRuleOrigin + * @param SalesRule $salesRule + * @param SalesRule $salesRuleOrigin * @return void */ public function testUpdateSalesRule( - SalesRuleInjectable $salesRule, - SalesRuleInjectable $salesRuleOrigin + SalesRule $salesRule, + SalesRule $salesRuleOrigin ) { // Preconditions $salesRuleOrigin->persist(); diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnBackendStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnBackendStep.php index 7e193a4d0ab1c..709e2c1644b71 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnBackendStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnBackendStep.php @@ -7,7 +7,7 @@ namespace Magento\SalesRule\Test\TestStep; use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -25,16 +25,16 @@ class ApplySalesRuleOnBackendStep implements TestStepInterface /** * SalesRule fixture. * - * @var SalesRuleInjectable + * @var SalesRule */ protected $salesRule; /** * @constructor * @param OrderCreateIndex $orderCreateIndex - * @param SalesRuleInjectable $salesRule + * @param SalesRule $salesRule */ - public function __construct(OrderCreateIndex $orderCreateIndex, SalesRuleInjectable $salesRule = null) + public function __construct(OrderCreateIndex $orderCreateIndex, SalesRule $salesRule = null) { $this->orderCreateIndex = $orderCreateIndex; $this->salesRule = $salesRule; diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php index 6bff54ec11dee..49fedf0d5d16d 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php @@ -7,7 +7,7 @@ namespace Magento\SalesRule\Test\TestStep; use Magento\Checkout\Test\Page\CheckoutCart; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -25,16 +25,16 @@ class ApplySalesRuleOnFrontendStep implements TestStepInterface /** * SalesRule fixture. * - * @var SalesRuleInjectable + * @var SalesRule */ protected $salesRule; /** * @constructor * @param CheckoutCart $checkoutCart - * @param SalesRuleInjectable $salesRule + * @param SalesRule $salesRule */ - public function __construct(CheckoutCart $checkoutCart, SalesRuleInjectable $salesRule = null) + public function __construct(CheckoutCart $checkoutCart, SalesRule $salesRule = null) { $this->checkoutCart = $checkoutCart; $this->salesRule = $salesRule; diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php index c458bed8659ad..bda908faf2677 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php @@ -51,7 +51,7 @@ public function run() $result['salesRule'] = null; if ($this->salesRule !== null) { $salesRule = $this->fixtureFactory->createByCode( - 'salesRuleInjectable', + 'salesRule', ['dataSet' => $this->salesRule] ); $salesRule->persist(); diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/curl/di.xml index 2591249e9e028..3416929d0ab44 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/curl/di.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/curl/di.xml @@ -6,5 +6,5 @@ */ --> - + diff --git a/dev/tests/functional/utils/config/ee_modules.yml.dist b/dev/tests/functional/utils/config/ee_modules.yml.dist deleted file mode 100644 index 33bd56450a7a2..0000000000000 --- a/dev/tests/functional/utils/config/ee_modules.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright © 2015 Magento. All rights reserved. -# See COPYING.txt for license details. -- Magento_Backend -- Magento_Catalog -- Magento_Customer \ No newline at end of file diff --git a/dev/tests/functional/utils/config/generator_config.yml.dist b/dev/tests/functional/utils/config/generator_config.yml.dist deleted file mode 100644 index 14dffd2306b79..0000000000000 --- a/dev/tests/functional/utils/config/generator_config.yml.dist +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright © 2015 Magento. All rights reserved. -# See COPYING.txt for license details. -# Generator running options, in case "generate_specified_modules" is set to "yes" then specified file is used -generate_specified_modules: no -specified_modules: dev\tests\functional\utils\config\ee_modules.yml.dist - -# Fallback path configurations -tests_fallback: - 1: - path: tests/app - -# Handler priority configuration -handler_fallback: - 1: Curl - 2: Direct - 3: Ui \ No newline at end of file From 5fc054d5dba5d3b44897318818af9d99703d9393 Mon Sep 17 00:00:00 2001 From: Oleksii Kolesnyk Date: Wed, 29 Apr 2015 19:31:48 +0300 Subject: [PATCH 08/16] MTA-587: Re-factor Test for Switch Currency - CR changes --- .../System/Currency/Rate/CurrencyRateForm.php | 10 ++++------ ...tyTest.php => AbstractCurrencySymbolEntityTest.php} | 2 +- .../Test/TestCase/EditCurrencySymbolEntityTest.php | 2 +- .../Test/TestCase/ResetCurrencySymbolEntityTest.php | 2 +- .../Directory/Test/TestCase/CreateCurrencyRateTest.php | 10 ++++------ .../Directory/Test/TestCase/CreateCurrencyRateTest.xml | 2 +- 6 files changed, 12 insertions(+), 16 deletions(-) rename dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/{CurrencySymbolEntityTest.php => AbstractCurrencySymbolEntityTest.php} (97%) diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php index 64e4c5220adfc..d5d1c887a484c 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php @@ -24,13 +24,11 @@ class CurrencyRateForm extends Form */ public function fill(FixtureInterface $fixture, SimpleElement $element = null) { - $fixtureData = $fixture->getData(); - $this->placeholders['currency_from'] = $fixtureData['currency_from']; - $this->placeholders['currency_to'] = $fixtureData['currency_to']; + /** @var \Magento\Directory\Test\Fixture\CurrencyRate $fixture */ + $this->placeholders['currency_from'] = $fixture->getCurrencyFrom(); + $this->placeholders['currency_to'] = $fixture->getCurrencyTo(); $this->applyPlaceholders(); - $mapping = $this->dataMapping(['rate' => $fixtureData['rate']]); - $this->_fill($mapping, $element); - return $this; + return parent::fill($fixture, $element); } } diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php similarity index 97% rename from dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php rename to dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php index 3f98754bb744c..6dc377557891a 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/CurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php @@ -15,7 +15,7 @@ /** * Abstract class for currency symbol tests. */ -abstract class CurrencySymbolEntityTest extends Injectable +abstract class AbstractCurrencySymbolEntityTest extends Injectable { /** * System Currency Symbol grid page. diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php index bdf2cbf9897af..c1597a1fbc4e6 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/EditCurrencySymbolEntityTest.php @@ -23,7 +23,7 @@ * @group Currency_(PS) * @ZephyrId MAGETWO-26600 */ -class EditCurrencySymbolEntityTest extends CurrencySymbolEntityTest +class EditCurrencySymbolEntityTest extends AbstractCurrencySymbolEntityTest { /* tags */ const MVP = 'no'; diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php index 767ae80be8a44..96537d399ce87 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/ResetCurrencySymbolEntityTest.php @@ -24,7 +24,7 @@ * @group Currency_(PS) * @ZephyrId MAGETWO-26638 */ -class ResetCurrencySymbolEntityTest extends CurrencySymbolEntityTest +class ResetCurrencySymbolEntityTest extends AbstractCurrencySymbolEntityTest { /* tags */ const MVP = 'no'; diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php index e7331e676de7f..04aa6c4ca73d6 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -6,6 +6,7 @@ namespace Magento\Directory\Test\TestCase; +use Magento\Config\Test\Fixture\ConfigData; use Magento\Mtf\TestCase\Injectable; use Magento\Directory\Test\Fixture\CurrencyRate; use Magento\Catalog\Test\Fixture\CatalogProductSimple; @@ -24,7 +25,7 @@ * 5. Perform assertions. * * @group Localization_(PS) - * @ZephyrId MAGETWO-12427 + * @ZephyrId MAGETWO-12427, MAGETWO-36824 */ class CreateCurrencyRateTest extends Injectable { @@ -59,14 +60,11 @@ public function __inject(SystemCurrencyIndex $currencyIndexPage) * @param $config * @return void */ - public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, $config) + public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, ConfigData $config) { // Preconditions: $product->persist(); - $this->objectManager->create( - 'Magento\Config\Test\TestStep\SetupConfigurationStep', - ['configData' => $config] - )->run(); + $config->persist(); // Steps: $this->currencyIndexPage->open(); diff --git a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml index 0167104dd192e..561f9307ff07f 100644 --- a/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml @@ -13,7 +13,7 @@ 0.8 currency_symbols_eur simple_10_dollar - config_currency_symbols_usd_and_eur + config_currency_symbols_usd_and_eur $10.00 €8.00 test_type:acceptance_test From e7b6087993bced32ea2adeca42234e472f89473d Mon Sep 17 00:00:00 2001 From: Oleksandr Manchenko Date: Thu, 30 Apr 2015 06:43:03 +0300 Subject: [PATCH 09/16] MTA-2056: Fix filling condition element --- .../Mtf/Client/Element/ConditionsElement.php | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index 7aea81e922b4a..f0c1e8c3b5079 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -170,7 +170,14 @@ class ConditionsElement extends SimpleElement * * @var string */ - protected $ruleParamInput = '.element [name^="rule"]'; + protected $ruleParamInput = '[name^="rule"]'; + + /** + * Latest occurred exception. + * + * @var \Exception + */ + protected $exception; /** * Set value to conditions. @@ -180,6 +187,8 @@ class ConditionsElement extends SimpleElement */ public function setValue($value) { + $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]); + $conditions = $this->decodeValue($value); $context = $this->find($this->mainCondition, Locator::SELECTOR_XPATH); $this->clear(); @@ -254,9 +263,6 @@ protected function addCondition($type, ElementInterface $context) $count = 0; do { - if (!$this->driver->find('*:focus')->isVisible()) { - $this->driver->selectWindow(); - } $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); try { @@ -264,12 +270,15 @@ protected function addCondition($type, ElementInterface $context) $isSetType = true; } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { $isSetType = false; + $this->exception = $e; + $this->eventManager->dispatchEvent(['exception'], [__METHOD__, $this->getAbsoluteSelector()]); } $count++; } while (!$isSetType && $count < self::TRY_COUNT); if (!$isSetType) { - throw new \Exception("Can not add condition: {$type}"); + $exception = $this->exception ? $this->exception : (new \Exception("Can not add condition: {$type}")); + throw $exception; } } @@ -287,46 +296,41 @@ protected function fillCondition(array $rules, ElementInterface $element) foreach ($rules as $rule) { /** @var ElementInterface $param */ $param = $this->findNextParam($element); + $isSet = false; $count = 0; do { try { - $this->openParam($param); + $openParamLink = $param->find('a'); + if ($openParamLink->isVisible()) { + $openParamLink->click(); + } + $this->waitUntil(function() use ($param) { + return $param->find($this->ruleParamInput)->isVisible() ? true : null; + }); if ($this->fillGrid($rule, $param)) { $isSet = true; } elseif ($this->fillSelect($rule, $param)) { $isSet = true; - } else { - $this->fillText($rule, $param); + } elseif ($this->fillText($rule, $param)) { $isSet = true; } } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { $isSet = false; + $this->exception = $e; + $this->eventManager->dispatchEvent(['exception'], [__METHOD__, $this->getAbsoluteSelector()]); } $count++; } while (!$isSet && $count < self::TRY_COUNT); if (!$isSet) { - throw new \Exception('Can not set value: ' . $rule); + $exception = $this->exception ? $this->exception : (new \Exception('Can not set value: ' . $rule)); + throw $exception; } } } - /** - * Open param of condition before filling. - * - * @param ElementInterface $param - * @return void - */ - protected function openParam(ElementInterface $param) - { - if (!$this->driver->find('*:focus')->isVisible()) { - $this->driver->selectWindow(); - } - $param->find('a')->click(); - } - /** * Fill grid element. * From 2571db6fa0294a707f15b40c2a7d2a482daf2686 Mon Sep 17 00:00:00 2001 From: Oleksandr Manchenko Date: Thu, 30 Apr 2015 13:57:57 +0300 Subject: [PATCH 10/16] MTA-584: Re-factor Test for Layered Navigation - Fixed logical and code style errors --- .../Catalog/Test/Handler/Category/Curl.php | 39 +++++++++-- .../Test/Repository/CatalogProductSimple.xml | 1 - .../Category/CreateCategoryEntityTest.xml | 2 - .../Product/Edit/Tab/Downloadable/LinkRow.php | 3 +- .../Test/Block/Navigation.php | 4 +- .../Constraint/AssertFilterProductList.php | 33 +++++----- .../Test/Repository/ConfigData.xml | 4 +- .../Test/TestCase/FilterProductListTest.php | 66 ++----------------- .../Test/TestCase/FilterProductListTest.xml | 27 ++++---- 9 files changed, 80 insertions(+), 99 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php index e684946a46f47..bd7a938684dd2 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php @@ -6,6 +6,7 @@ namespace Magento\Catalog\Test\Handler\Category; +use Magento\Catalog\Test\Fixture\Category; use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\Handler\Curl as AbstractCurl; use Magento\Mtf\Util\Protocol\CurlInterface; @@ -58,20 +59,24 @@ class Curl extends AbstractCurl implements CategoryInterface * * @param FixtureInterface|null $fixture [optional] * @return array + * @throws \Exception */ public function persist(FixtureInterface $fixture = null) { $data = $this->prepareData($fixture); - $url = $_ENV['app_backend_url'] . 'catalog/category/save/store/0/parent/' . $data['general']['parent_id'] . '/'; $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + $this->_eventManager->dispatchEvent(['curl_failed'], [$response]); + throw new \Exception('Category creation by curl handler was not successful!'); + } + preg_match('#http://.+/id/(\d+).+store/#m', $response, $matches); $id = isset($matches[1]) ? (int)$matches[1] : null; - return ['id' => $id]; } @@ -83,12 +88,16 @@ public function persist(FixtureInterface $fixture = null) */ protected function prepareData(FixtureInterface $fixture) { - $data['general'] = $this->replaceMappingData($fixture->getData()); - $data['is_anchor'] = isset($data['is_anchor']) ? $data['is_anchor'] : 0; + $data = ['general' => $this->replaceMappingData($fixture->getData())]; + $data['general']['is_anchor'] = isset($data['general']['is_anchor']) ? $data['general']['is_anchor'] : 0; + if ($fixture->hasData('landing_page')) { $data['general']['landing_page'] = $this->getBlockId($fixture->getLandingPage()); } + $data['category_products'] = $this->prepareCategoryProducts($fixture); + unset($data['general']['category_products']); + $diff = array_diff($this->dataUseConfig, array_keys($data['general'])); if (!empty($diff)) { $data['use_config'] = $diff; @@ -97,6 +106,28 @@ protected function prepareData(FixtureInterface $fixture) return $data; } + /** + * Prepare category products data for curl. + * + * @param FixtureInterface $category + * @return array + */ + protected function prepareCategoryProducts(FixtureInterface $category) + { + $categoryProducts = []; + $defaultPosition = 0; + + /** @var Category $category */ + if ($category->hasData('category_products')) { + $products = $category->getDataFieldConfig('category_products')['source']->getProducts(); + foreach ($products as $product) { + $categoryProducts[$product->getId()] = $defaultPosition; + } + } + + return json_encode($categoryProducts); + } + /** * Getting block id by name. * diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index b919ad39c1045..c4ae2d72fde4d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -79,7 +79,6 @@ 20 - - taxable_goods diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml index b4b2da10a3d73..83d80113af0ae 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml @@ -69,7 +69,6 @@ Yes Yes Yes - default catalogProductSimple::default,catalogProductSimple::default @@ -97,7 +96,6 @@ Price No 50 - default catalogProductSimple::default,catalogProductSimple::default diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinkRow.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinkRow.php index 64d1aab3f990b..774f85d7772f4 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinkRow.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinkRow.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable; use Magento\Mtf\Block\Form; @@ -19,7 +20,7 @@ class LinkRow extends Form * * @var string */ - protected $deleteButton = '.action-remove'; + protected $deleteButton = '.action-delete'; /** * Fill item link diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php index 1b0ff0a55ce03..4dfa6dd2122c1 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php @@ -61,14 +61,14 @@ public function getFilters() } /** - * Open filter link. + * Click filter link. * * @param string $filter * @param string $linkPattern * @return void * @throws \Exception */ - public function openFilterLink($filter, $linkPattern) + public function clickFilterLink($filter, $linkPattern) { $links = $this->_rootElement->getElements(sprintf($this->filterLink, $filter), Locator::SELECTOR_XPATH); diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php index 02b67de95a6d6..e2b384a266110 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php @@ -12,7 +12,7 @@ use Magento\Mtf\Constraint\AbstractConstraint; /** - * Check whether filtering product in the Frontend via layered navigation. + * Check whether products can be filtered in the Frontend via layered navigation. */ class AssertFilterProductList extends AbstractConstraint { @@ -27,35 +27,34 @@ class AssertFilterProductList extends AbstractConstraint * Assertion that filtered product list via layered navigation are displayed correctly. * * @param Category $category - * @param array $products * @param CmsIndex $cmsIndex * @param CatalogCategoryView $catalogCategoryView - * @param array $asserts + * @param array $layeredNavigation * @return void */ public function processAssert( Category $category, - array $products, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, - array $asserts + array $layeredNavigation ) { - $this->products = $products; + $this->products = $category->getDataFieldConfig('category_products')['source']->getProducts(); $cmsIndex->open(); $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); - foreach ($asserts as $assert) { - $catalogCategoryView->getLayeredNavigationBlock()->openFilterLink( - $assert['filter'], - $assert['linkPattern'] - ); - - $productNames = $this->getProductNames($assert['products']); - sort($productNames); - $pageProductNames = $catalogCategoryView->getListProductBlock()->getProductNames(); - sort($pageProductNames); - \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames); + foreach ($layeredNavigation as $filters) { + foreach ($filters as $filter) { + $catalogCategoryView->getLayeredNavigationBlock()->clickFilterLink( + $filter['title'], + $filter['linkPattern'] + ); + $productNames = $this->getProductNames($filter['products']); + sort($productNames); + $pageProductNames = $catalogCategoryView->getListProductBlock()->getProductNames(); + sort($pageProductNames); + \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames); + } $catalogCategoryView->getLayeredNavigationBlock()->clearAll(); } } diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml index 5540779491e99..2005dd8bf0cef 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Repository/ConfigData.xml @@ -7,7 +7,7 @@ --> - + default 0 @@ -29,7 +29,7 @@ 10 - + default 0 diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php index 98c741c3d1baa..dea532e69cf26 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php @@ -9,32 +9,27 @@ use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Fixture\Category; -use Magento\Mtf\Fixture\FixtureFactory; -use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\TestCase\Injectable; /** + * Preconditions: + * 1. Setup Layered Navigation configuration. + * * Steps: * 1. Create category. * 2. Create product with created category. * 3. Perform all assertions. * - * @group LayeredNavigation_(MX) + * @group Layered_Navigation_(MX) * @ZephyrId MAGETWO-12419 */ class FilterProductListTest extends Injectable { /* tags */ + const DOMAIN = 'MX'; const TEST_TYPE = 'acceptance_test'; /* end tags */ - /** - * Fixture Factory. - * - * @var FixtureFactory - */ - protected $fixtureFactory; - /** * Configuration setting. * @@ -42,27 +37,16 @@ class FilterProductListTest extends Injectable */ protected $configData; - /** - * Category fixture. - * - * @var Category - */ - protected $category; - /** * Filtering product in the Frontend via layered navigation. * - * @param FixtureFactory $fixtureFactory * @param string $configData * @param Category $category - * @param string $products * @return array */ - public function test(FixtureFactory $fixtureFactory, $configData, Category $category, $products) + public function test($configData, Category $category) { - $this->fixtureFactory = $fixtureFactory; $this->configData = $configData; - $this->category = $category; // Preconditions $this->objectManager->create( @@ -71,43 +55,7 @@ public function test(FixtureFactory $fixtureFactory, $configData, Category $cate )->run(); // Steps - $this->category->persist(); - $products = $this->prepareProducts($products); - - return ['products' => $products]; - } - - /** - * Create products and assign to category. - * - * @param string $products - * @return FixtureInterface[] - */ - public function prepareProducts($products) - { - $products = array_map('trim', explode(',', $products)); - $result = []; - - foreach ($products as $productData) { - list($productCode, $dataSet) = explode('::', $productData); - $product = $this->fixtureFactory->createByCode( - $productCode, - [ - 'dataSet' => $dataSet, - 'data' => [ - 'category_ids' => [ - 'presets' => null, - 'category' => $this->category - ] - ] - ] - ); - - $product->persist(); - $result[] = $product; - } - - return $result; + $category->persist(); } /** diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml index 094ab8506cad7..4cfbc8d6397ff 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml @@ -8,22 +8,27 @@ - layered_navigation_manual + layered_navigation_manual_range_10 default_anchor_subcategory - catalogProductSimple::product_20_dollar, configurableProduct::filterable_two_options_with_zero_price - - - Price - `^.+10\.00 - .+19\.99 1$`m - product_1 + catalogProductSimple::product_20_dollar, configurableProduct::filterable_two_options_with_zero_price + + + + Price + `^.+10\.00 - .+19\.99 1$`m + product_1 + - - attribute_dropdown - `^option_0_[0-9]+ 1$`m - product_1 + + + attribute_dropdown + `^option_0_[0-9]+ 1$`m + product_1 + test_type:acceptance_test + From e244b26df4b18ebbb1e98bcb1bf9fe3feea4654c Mon Sep 17 00:00:00 2001 From: Oleksandr Manchenko Date: Thu, 30 Apr 2015 14:11:59 +0300 Subject: [PATCH 11/16] MTA-2056: Fix filling condition element - Fixed code style errors --- .../Mtf/Client/Element/ConditionsElement.php | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index f0c1e8c3b5079..1232f52717388 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -105,6 +105,34 @@ class ConditionsElement extends SimpleElement */ protected $param = './span[span[*[substring(@id,(string-length(@id)-%d+1))="%s"]]]'; + /** + * Rule param wait locator. + * + * @var string + */ + protected $ruleParamWait = './/*[@class="rule-param-wait"]'; + + /** + * Rule param input selector. + * + * @var string + */ + protected $ruleParamInput = '[name^="rule"]'; + + /** + * Apply rule param link. + * + * @var string + */ + protected $applyRuleParam = './/*[@class="rule-param-apply"]'; + + /** + * Chooser grid locator. + * + * @var string + */ + protected $chooserGridLocator = 'div[id*=chooser]'; + /** * Key of last find param. * @@ -151,27 +179,6 @@ class ConditionsElement extends SimpleElement ':' => ':', ]; - /** - * Rule param wait locator. - * - * @var string - */ - protected $ruleParamWait = './/*[@class="rule-param-wait"]'; - - /** - * Chooser grid locator. - * - * @var string - */ - protected $chooserGridLocator = 'div[id*=chooser]'; - - /** - * Rule param input selector. - * - * @var string - */ - protected $ruleParamInput = '[name^="rule"]'; - /** * Latest occurred exception. * @@ -281,7 +288,7 @@ protected function addCondition($type, ElementInterface $context) throw $exception; } } - + /** * Fill single condition. * @@ -305,7 +312,7 @@ protected function fillCondition(array $rules, ElementInterface $element) if ($openParamLink->isVisible()) { $openParamLink->click(); } - $this->waitUntil(function() use ($param) { + $this->waitUntil(function () use ($param) { return $param->find($this->ruleParamInput)->isVisible() ? true : null; }); @@ -353,7 +360,7 @@ protected function fillGrid($rule, ElementInterface $param) ); $grid->searchAndSelect([$chooserConfig[1] => $rule]); - $apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH); + $apply = $param->find($this->applyRuleParam, Locator::SELECTOR_XPATH); if ($apply->isVisible()) { $apply->click(); } @@ -485,7 +492,7 @@ protected function resetKeyParam() /** * Param wait loader. * - * @return void + * @param ElementInterface $element */ protected function waitForCondition(ElementInterface $element) { From 32678f1ccd40797fd59b9b13232b11625dc918a9 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Thu, 30 Apr 2015 15:08:43 +0300 Subject: [PATCH 12/16] MTA-2081: Analyse functional test failures - Sprint 11 --- .../Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php index 5256125cd6230..b67edd7a4c178 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/TaxWithCrossBorderTest.php @@ -9,7 +9,7 @@ use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\CatalogRule\Test\Fixture\CatalogRule; use Magento\Customer\Test\Fixture\Customer; -use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Fixture\SalesRule; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; @@ -43,7 +43,7 @@ class TaxWithCrossBorderTest extends Injectable /** * Fixture SalesRule. * - * @var SalesRuleInjectable + * @var SalesRule */ protected $salesRule; @@ -108,14 +108,14 @@ protected function createCustomers() * * @param CatalogProductSimple $product * @param string $configData - * @param SalesRuleInjectable $salesRule [optional] + * @param SalesRule $salesRule [optional] * @param CatalogRule $catalogRule [optional] * @return void */ public function test( CatalogProductSimple $product, $configData, - SalesRuleInjectable $salesRule = null, + SalesRule $salesRule = null, CatalogRule $catalogRule = null ) { //Preconditions From 5e10150125f55dce408a3f32cfcc7a0820d4aed8 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Thu, 30 Apr 2015 18:43:29 +0300 Subject: [PATCH 13/16] MTA-2080: Sync qmt repository with mainline - Sprint 11 --- .../Mtf/Client/Element/ConditionsElement.php | 3 ++ .../AbstractCurrencySymbolEntityTest.php | 28 +++++++------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index 1232f52717388..d805ea841654d 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -296,6 +296,9 @@ protected function addCondition($type, ElementInterface $context) * @param ElementInterface $element * @return void * @throws \Exception + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function fillCondition(array $rules, ElementInterface $element) { diff --git a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php index 6dc377557891a..157b6dae2e1a1 100644 --- a/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php @@ -39,13 +39,20 @@ abstract class AbstractCurrencySymbolEntityTest extends Injectable protected $fixtureFactory; /** - * Prepare data. Create simple product. + * Create simple product and inject pages. * + * @param SystemCurrencySymbolIndex $currencySymbolIndex + * @param SystemCurrencyIndex $currencyIndex * @param FixtureFactory $fixtureFactory * @return array */ - public function __prepare(FixtureFactory $fixtureFactory) - { + public function __inject( + SystemCurrencySymbolIndex $currencySymbolIndex, + SystemCurrencyIndex $currencyIndex, + FixtureFactory $fixtureFactory + ) { + $this->currencySymbolIndex = $currencySymbolIndex; + $this->currencyIndex = $currencyIndex; $this->fixtureFactory = $fixtureFactory; $product = $this->fixtureFactory->createByCode( 'catalogProductSimple', @@ -56,21 +63,6 @@ public function __prepare(FixtureFactory $fixtureFactory) return ['product' => $product]; } - /** - * Create simple product and inject pages. - * - * @param SystemCurrencySymbolIndex $currencySymbolIndex - * @param SystemCurrencyIndex $currencyIndex - * @return void - */ - public function __inject( - SystemCurrencySymbolIndex $currencySymbolIndex, - SystemCurrencyIndex $currencyIndex - ) { - $this->currencySymbolIndex = $currencySymbolIndex; - $this->currencyIndex = $currencyIndex; - } - /** * Import currency rates. * From 738a88021f744f1fe48de471d104b15c05fe157e Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Thu, 30 Apr 2015 19:25:28 +0300 Subject: [PATCH 14/16] MTA-2080: Sync qmt repository with mainline - Sprint 11 --- .../Fixture/GroupedProduct/CheckoutData.php | 33 ------------------- .../Test/Repository/GroupedProduct.xml | 29 ---------------- ...CartFromCustomerWishlistOnFrontendTest.xml | 2 +- ...roductInCustomerWishlistOnFrontendTest.xml | 2 +- 4 files changed, 2 insertions(+), 64 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct/CheckoutData.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct/CheckoutData.php index 5c45ad254c0b0..2871ec912db01 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct/CheckoutData.php @@ -57,39 +57,6 @@ protected function getPreset($name) ], ], ], - 'three_simple_products_default_qty' => [ - 'options' => [ - [ - 'name' => 'product_key_0', - 'qty' => 17, - ], - [ - 'name' => 'product_key_1', - 'qty' => 36 - ], - [ - 'name' => 'product_key_2', - 'qty' => 20 - ], - ], - 'cartItem' => [ - 'price' => [ - 'product_key_0' => 560, - 'product_key_1' => 40, - 'product_key_2' => 100, - ], - 'qty' => [ - 'product_key_0' => 17, - 'product_key_1' => 36, - 'product_key_2' => 20, - ], - 'subtotal' => [ - 'product_key_0' => 9520.00, - 'product_key_1' => 1440.00, - 'product_key_2' => 2000.00, - ], - ], - ], ]; return isset($presets[$name]) ? $presets[$name] : null; } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml index fbf4305699a44..cd0bc02b3df4c 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct.xml @@ -117,34 +117,5 @@ three_simple_products - - - Grouped product %isolation% - grouped_product_%isolation% - - default - - - three_simple_products - - Product online - Catalog, Search - - taxable_goods - - test-grouped-product-%isolation% - - In Stock - - - Main Website - - - default - - - three_simple_products_default_qty - - diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.xml index 1cf13be71e2cd..d88f6d3054641 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.xml @@ -27,7 +27,7 @@ - groupedProduct::three_simple_products_default_qty + groupedProduct::three_simple_products - diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml index 28bf95af27ad8..835509955c51d 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnFrontendTest.xml @@ -28,7 +28,7 @@ - groupedProduct::three_simple_products_default_qty + groupedProduct::three_simple_products From 9770fa55fa6cf9926e764004d7768e3a19346e39 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Mon, 4 May 2015 14:50:52 +0300 Subject: [PATCH 15/16] MTA-2080: Sync qmt repository with mainline - Sprint 11 --- .../app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php | 2 +- .../Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml | 2 +- .../Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php index 5c4240ee3fd67..99fe29e6517c8 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php @@ -60,5 +60,5 @@ class CmsGrid extends Grid * * @var string */ - protected $editLink = 'td[data-part="body.row.cell"]'; + protected $editLink = '.action-menu-item'; } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml index c7a99a1c233ca..32892c7138a79 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -8,7 +8,7 @@ \Magento\Review\Test\Block\Adminhtml\Customer\Edit\Tab\Reviews - #tab_reviews + #tab_block_reviews css selector diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml index c00338cd02750..d6a8abbf78b15 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -8,7 +8,7 @@ \Magento\Wishlist\Test\Block\Adminhtml\Customer\Edit\Tab\Wishlist - #tab_wishlist + #tab_block_wishlist css selector From 18a38a283f203ef8fa6ee9618103157c175be341 Mon Sep 17 00:00:00 2001 From: Dmytro Aponasenko Date: Mon, 4 May 2015 18:12:53 +0300 Subject: [PATCH 16/16] MTA-2080: Sync qmt repository with mainline - Sprint 11 --- .../tests/app/Magento/Customer/Test/Handler/Customer/Curl.php | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index 4bd48676164b0..fb1030c3143f1 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -86,7 +86,6 @@ public function persist(FixtureInterface $customer = null) $data = $customer->getData(); $data['group_id'] = $this->getCustomerGroup($customer); $address = []; - $result = []; $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; if ($customer->hasData('address')) {