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..d805ea841654d 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,110 @@ 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 + * 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. * * @var int */ protected $findKeyParam = 0; /** - * Map of parameters + * Map of parameters. * * @var array */ @@ -122,7 +154,7 @@ class ConditionsElement extends SimpleElement ]; /** - * Map encode special chars + * Map encode special chars. * * @var array */ @@ -135,7 +167,7 @@ class ConditionsElement extends SimpleElement ]; /** - * Map decode special chars + * Map decode special chars. * * @var array */ @@ -148,34 +180,22 @@ 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. + * Latest occurred exception. * - * @var string + * @var \Exception */ - protected $ruleParamInput = '.element [name^="rule"]'; + protected $exception; /** - * Set value to conditions + * Set value to conditions. * * @param string $value * @return void */ 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(); @@ -183,7 +203,7 @@ public function setValue($value) } /** - * Add condition combination + * Add conditions combination. * * @param string $condition * @param ElementInterface $context @@ -192,15 +212,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 +222,7 @@ protected function addConditionsCombination($condition, ElementInterface $contex } /** - * Add conditions + * Add conditions. * * @param array $conditions * @param ElementInterface $context @@ -229,7 +241,7 @@ protected function addMultipleCondition(array $conditions, ElementInterface $con } /** - * Add single Condition + * Add single Condition. * * @param string $condition * @param ElementInterface $context @@ -238,36 +250,55 @@ 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; - } - $this->driver->selectWindow(); - return null; + $count = 0; + + do { + $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); + + try { + $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($type); + $isSetType = true; + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + $isSetType = false; + $this->exception = $e; + $this->eventManager->dispatchEvent(['exception'], [__METHOD__, $this->getAbsoluteSelector()]); } - ); - $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($condition['type']); + $count++; + } while (!$isSetType && $count < self::TRY_COUNT); - $createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH); - $this->waitForCondition($createdCondition); - $this->fillCondition($condition['rules'], $createdCondition); + if (!$isSetType) { + $exception = $this->exception ? $this->exception : (new \Exception("Can not add condition: {$type}")); + throw $exception; + } } /** - * Fill single condition + * Fill single condition. * * @param array $rules * @param ElementInterface $element * @return void * @throws \Exception + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function fillCondition(array $rules, ElementInterface $element) { @@ -275,52 +306,117 @@ protected function fillCondition(array $rules, ElementInterface $element) foreach ($rules as $rule) { /** @var ElementInterface $param */ $param = $this->findNextParam($element); + $isSet = false; + $count = 0; + + do { + try { + $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; + } 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); - $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) { + $exception = $this->exception ? $this->exception : (new \Exception('Can not set value: ' . $rule)); + throw $exception; } - $input = $this->ruleParamInput; - $param->waitUntil( - function () use ($param, $input) { - $element = $param->find($input); - return $element->isVisible() ? true : null; - } + } + } + + /** + * 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($this->applyRuleParam, 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 +440,7 @@ protected function decodeValue($value) } /** - * Parse condition + * Parse condition. * * @param string $condition * @return array @@ -366,7 +462,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 +483,7 @@ protected function findNextParam(ElementInterface $context) } /** - * Reset key of last find param + * Reset key of last find param. * * @return void */ @@ -397,25 +493,21 @@ protected function resetKeyParam() } /** - * Param wait loader + * Param wait loader. * - * @return void + * @param ElementInterface $element */ 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 +521,7 @@ protected function clear() } /** - * Get value from conditions + * Get value from conditions. * * @return null */ 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/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/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..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 @@ -65,6 +65,31 @@ + + + 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/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/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..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 @@ -9,17 +9,15 @@ 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 + * 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 @@ -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..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 @@ -9,15 +9,13 @@ 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 - * 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 @@ -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..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 @@ -12,18 +12,16 @@ 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 - * 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 */ @@ -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/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/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/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..d5d1c887a484c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/Block/Adminhtml/System/Currency/Rate/CurrencyRateForm.php @@ -0,0 +1,34 @@ +placeholders['currency_from'] = $fixture->getCurrencyFrom(); + $this->placeholders['currency_to'] = $fixture->getCurrencyTo(); + $this->applyPlaceholders(); + + return parent::fill($fixture, $element); + } +} 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/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..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 @@ -137,5 +137,27 @@ USD + + + + currency + 1 + + USD + EUR + + + + + + + currency + 1 + + USD + GBP + + + 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 new file mode 100644 index 0000000000000..157b6dae2e1a1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CurrencySymbol/Test/TestCase/AbstractCurrencySymbolEntityTest.php @@ -0,0 +1,101 @@ +currencySymbolIndex = $currencySymbolIndex; + $this->currencyIndex = $currencyIndex; + $this->fixtureFactory = $fixtureFactory; + $product = $this->fixtureFactory->createByCode( + 'catalogProductSimple', + ['dataSet' => 'product_with_category'] + ); + $product->persist(); + + return ['product' => $product]; + } + + /** + * 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 5d2cc6badaa78..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 @@ -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 AbstractCurrencySymbolEntityTest { /* 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,36 +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 - */ - 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(); - $this->currencyIndex->getMainPageActions()->saveCurrentRate(); - } - - /** - * 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 f64c407f6aeff..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 @@ -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 AbstractCurrencySymbolEntityTest { /* 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,36 +67,4 @@ public function test( ) ]; } - - /** - * Import currency rates. - * - * @param string $configData - * @return void - */ - 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(); - $this->currencyIndex->getMainPageActions()->saveCurrentRate(); - } - - /** - * 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/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index 61f32f55d0379..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 @@ -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, @@ -78,12 +82,11 @@ class Curl extends AbstractCurl implements CustomerInterface */ public function persist(FixtureInterface $customer = null) { - $address = []; - /** @var Customer $customer */ - $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; $data = $customer->getData(); $data['group_id'] = $this->getCustomerGroup($customer); + $address = []; + $url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true'; if ($customer->hasData('address')) { $address = $customer->getAddress(); @@ -179,7 +182,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/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php new file mode 100644 index 0000000000000..05cd0245e1a75 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Constraint/AssertCurrencyRateAppliedOnCatalogPage.php @@ -0,0 +1,71 @@ +getCategoryIds()[0]; + $cmsIndex->open(); + $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock(); + $actualPrice = $priceBlock->getPrice(''); + + \PHPUnit_Framework_Assert::assertEquals( + $basePrice, + $actualPrice, + 'Wrong price is displayed on Category page.' + ); + + $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol); + $cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + $actualPrice = $priceBlock->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..70fcf15c96298 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/Fixture/CurrencyRate.xml @@ -0,0 +1,20 @@ + + + + + + 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 new file mode 100644 index 0000000000000..04aa6c4ca73d6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.php @@ -0,0 +1,87 @@ + Currency > Currency Rates. + * 3. Fill currency rate according to dataSet. + * 4. Click on 'Save Currency Rates' button. + * 5. Perform assertions. + * + * @group Localization_(PS) + * @ZephyrId MAGETWO-12427, MAGETWO-36824 + */ +class CreateCurrencyRateTest extends Injectable +{ + /* tags */ + const TEST_TYPE = 'acceptance_test'; + const DOMAIN = 'PS'; + /* end tags */ + + /** + * Currency rate index page. + * + * @var SystemCurrencyIndex + */ + protected $currencyIndexPage; + + /** + * Inject data. + * + * @param SystemCurrencyIndex $currencyIndexPage + * @return void + */ + public function __inject(SystemCurrencyIndex $currencyIndexPage) + { + $this->currencyIndexPage = $currencyIndexPage; + } + + /** + * Create currency rate test. + * + * @param CurrencyRate $currencyRate + * @param CatalogProductSimple $product + * @param $config + * @return void + */ + public function test(CurrencyRate $currencyRate, CatalogProductSimple $product, ConfigData $config) + { + // Preconditions: + $product->persist(); + $config->persist(); + + // Steps: + $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..561f9307ff07f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Directory/Test/TestCase/CreateCurrencyRateTest.xml @@ -0,0 +1,24 @@ + + + + + + USD + 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 @@ + + + + + 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/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/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/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/LayeredNavigation/Test/Block/Navigation.php b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Block/Navigation.php index 41376ef7a3735..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 @@ -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; } + + /** + * Click filter link. + * + * @param string $filter + * @param string $linkPattern + * @return void + * @throws \Exception + */ + public function clickFilterLink($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..e2b384a266110 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/Constraint/AssertFilterProductList.php @@ -0,0 +1,90 @@ +products = $category->getDataFieldConfig('category_products')['source']->getProducts(); + $cmsIndex->open(); + $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); + + 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(); + } + } + + /** + * 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..2005dd8bf0cef --- /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..dea532e69cf26 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.php @@ -0,0 +1,73 @@ +configData = $configData; + + // Preconditions + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->configData] + )->run(); + + // Steps + $category->persist(); + } + + /** + * 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..4cfbc8d6397ff --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml @@ -0,0 +1,35 @@ + + + + + + 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 + + + + + attribute_dropdown + `^option_0_[0-9]+ 1$`m + product_1 + + + + test_type:acceptance_test + + + + + 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/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/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/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/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..b67edd7a4c178 --- /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 SalesRule + */ + 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 SalesRule $salesRule [optional] + * @param CatalogRule $catalogRule [optional] + * @return void + */ + public function test( + CatalogProductSimple $product, + $configData, + SalesRule $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/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(); 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/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 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/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. + + + 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