diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 5f5074addbc3975433141b19987cf6e9df6a55e1..efe7c5458aabed79e36e4a3ffaa646832910f8f9 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc22", + "magento/mtf": "1.0.0-rc23", "php": "~5.5.0|~5.6.0", "phpunit/phpunit": "4.1.0", "phpunit/phpunit-selenium": ">=1.2", diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php index bd53879a52018d712e7ef1bdc5ef38e59caa8022..dbc8efa6e71ccd62e5fdeaf17c86b749c2e44f0f 100755 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php @@ -13,11 +13,8 @@ use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\Fixture\InjectableFixture; use Magento\Mtf\Client\BrowserInterface; use Magento\Mtf\Client\Element\SimpleElement; -use Magento\Mtf\Util\Iterator\File; -use Magento\Mtf\Util\XmlConverter; /** - * Class FormTabs * Is used to represent any form with tabs on the page * * @SuppressWarnings(PHPMD.NumberOfChildren) @@ -30,11 +27,6 @@ class FormTabs extends Form */ protected $tabs = []; - /** - * @var XmlConverter - */ - protected $xmlConverter; - /** * Fields which aren't assigned to any tab * @@ -48,7 +40,6 @@ class FormTabs extends Form * @param Mapper $mapper * @param BlockFactory $blockFactory * @param BrowserInterface $browser - * @param XmlConverter $xmlConverter * @param array $config */ public function __construct( @@ -56,46 +47,17 @@ class FormTabs extends Form Mapper $mapper, BlockFactory $blockFactory, BrowserInterface $browser, - XmlConverter $xmlConverter, array $config = [] ) { - $this->xmlConverter = $xmlConverter; parent::__construct($element, $blockFactory, $mapper, $browser, $config); } /** * Initialize block */ - protected function _init() + protected function init() { - $this->tabs = $this->getTabs(); - } - - /** - * Get all tabs on the form - * - * @return array - */ - protected function getTabs() - { - $result = []; - - $paths = glob( - MTF_TESTS_PATH . preg_replace('/Magento\/\w+/', '*/*', str_replace('\\', '/', get_class($this))) . '.xml' - ); - $files = new File($paths); - - foreach ($files as $file) { - $presetXml = simplexml_load_string($file); - if ($presetXml instanceof \SimpleXMLElement) { - $array = $this->xmlConverter->convert($presetXml); - if (is_array($array)) { - $result = array_replace_recursive($result, $array); - } - } - } - - return $result; + $this->tabs = $this->getFormMapping(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php index 78e8c9965593fd9adc49af1d4885e8320472dab5..7147f86db8877e960013a314798fcd795f1b7f9a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/AttributeForm.php @@ -15,7 +15,6 @@ use Magento\Mtf\Client\Element; use Magento\Mtf\Client\Element\SimpleElement; use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; -use Magento\Mtf\Util\XmlConverter; /** * Edit attribute form on catalog product edit page. @@ -49,7 +48,6 @@ class AttributeForm extends FormTabs * @param Mapper $mapper * @param BlockFactory $blockFactory * @param BrowserInterface $browser - * @param XmlConverter $xmlConverter * @param array $config */ public function __construct( @@ -57,10 +55,9 @@ class AttributeForm extends FormTabs Mapper $mapper, BlockFactory $blockFactory, BrowserInterface $browser, - XmlConverter $xmlConverter, array $config = [] ) { - parent::__construct($element, $mapper, $blockFactory, $browser, $xmlConverter, $config); + parent::__construct($element, $mapper, $blockFactory, $browser, $config); $this->browser->switchToFrame(new Locator($this->iFrame)); } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml index 2a4163d237a8b8ceb913303ba10463ca8a789db5..ff3443eee0b503bc7c5d17caed6389d4b8226690 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Product/CatalogProductView.xml @@ -6,19 +6,16 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> - <page name="CatalogProductView" area="Product" mca="catalog/product/view" module="Magento_Catalog"> - <block name="viewBlock" class="Magento\Catalog\Test\Block\Product\View" locator="#maincontent" strategy="css selector"/> - <block name="additionalInformationBlock" class="Magento\Catalog\Test\Block\Product\Additional" locator="#additional" strategy="css selector"/> - <block name="customOptionsBlock" class="Magento\Catalog\Test\Block\Product\View\CustomOptions" locator="#product-options-wrapper" strategy="css selector"/> - <block name="relatedProductBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Related" locator=".block.related" strategy="css selector"/> - <block name="upsellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Upsell" locator=".block.upsell" strategy="css selector"/> - <block name="crosssellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Crosssell" locator=".block.crosssell" strategy="css selector"/> - <block name="downloadableLinksBlock" class="Magento\Downloadable\Test\Block\Catalog\Product\View\Links" locator="[data-container-for=downloadable-links]" strategy="css selector"/> - <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages .messages" strategy="css selector"/> - <block name="reviewSummary" class="Magento\Review\Test\Block\Product\View\Summary" locator=".product-reviews-summary" strategy="css selector"/> - <block name="customerReviewBlock" class="Magento\Review\Test\Block\Product\View" locator="#customer-reviews" strategy="css selector"/> - <block name="reviewFormBlock" class="Magento\Review\Test\Block\Form" locator="#review-form" strategy="css selector"/> - <block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper h1.page-title .base" strategy="css selector"/> - <block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".column.main .widget" strategy="css selector"/> - </page> + <page name="CatalogProductView" area="Product" mca="catalog/product/view" module="Magento_Catalog"> + <block name="viewBlock" class="Magento\Catalog\Test\Block\Product\View" locator="#maincontent" strategy="css selector" /> + <block name="additionalInformationBlock" class="Magento\Catalog\Test\Block\Product\Additional" locator="#additional" strategy="css selector" /> + <block name="customOptionsBlock" class="Magento\Catalog\Test\Block\Product\View\CustomOptions" locator="#product-options-wrapper" strategy="css selector" /> + <block name="relatedProductBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Related" locator=".block.related" strategy="css selector" /> + <block name="upsellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Upsell" locator=".block.upsell" strategy="css selector" /> + <block name="crosssellBlock" class="Magento\Catalog\Test\Block\Product\ProductList\Crosssell" locator=".block.crosssell" strategy="css selector" /> + <block name="downloadableLinksBlock" class="Magento\Downloadable\Test\Block\Catalog\Product\View\Links" locator="[data-container-for=downloadable-links]" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages .messages" strategy="css selector" /> + <block name="titleBlock" class="Magento\Theme\Test\Block\Html\Title" locator=".page-title-wrapper h1.page-title .base" strategy="css selector" /> + <block name="widgetView" class="Magento\Widget\Test\Block\WidgetView" locator=".column.main .widget" strategy="css selector" /> + </page> </config> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml index 11c19fd14519b9b8fd6cb122f3214f981d06309a..0d8c49414fb80ba6fd05ed3c27f40f16fe79731f 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml @@ -182,7 +182,6 @@ <data name="productAttribute/data/is_searchable" xsi:type="string">Yes</data> <data name="productAttribute/data/is_visible_in_advanced_search" xsi:type="string">Yes</data> <data name="productAttribute/data/is_comparable" xsi:type="string">Yes</data> - <data name="issue" xsi:type="string">Bug: MAGETWO-33625</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductAttributeIsUnique" /> </variation> </testCase> 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 26135d5e646639ed286f07201c4272ae3b881fa1..6649d45ba0e6312653b5c6766ab1727f20786aed 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 @@ -33,7 +33,7 @@ class CreateCatalogRuleTest extends AbstractCatalogRuleEntityTest const TEST_TYPE = 'acceptance_test'; const MVP = 'yes'; const DOMAIN = 'MX'; - const TO_MAINTAIN = 'yes'; + const TO_MAINTAIN = 'yes'; // Selecting conditions in parallel mode /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertOrderTotalOnReviewPage.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertOrderTotalOnReviewPage.php index 5d61be2bc1db1684505cf80daacf47325099a719..3bfb458f34130b1fe4b33f4d45b056c208a00aa4 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertOrderTotalOnReviewPage.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertOrderTotalOnReviewPage.php @@ -10,8 +10,7 @@ use Magento\Checkout\Test\Page\CheckoutOnepage; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertOrderTotalOnReviewPage - * Assert that Order Grand Total is correct on checkoutOnePage + * Assert that Order Grand Total is correct on checkoutOnePage. */ class AssertOrderTotalOnReviewPage extends AbstractConstraint { @@ -19,18 +18,17 @@ class AssertOrderTotalOnReviewPage extends AbstractConstraint * Assert that Order Grand Total is correct on checkoutOnePage * * @param CheckoutOnepage $checkoutOnepage - * @param string $grandTotal + * @param array $prices * @return void */ - public function processAssert(CheckoutOnepage $checkoutOnepage, $grandTotal) + public function processAssert(CheckoutOnepage $checkoutOnepage, array $prices) { $checkoutReviewGrandTotal = $checkoutOnepage->getReviewBlock()->getGrandTotal(); \PHPUnit_Framework_Assert::assertEquals( $checkoutReviewGrandTotal, - number_format($grandTotal, 2), - 'Grand Total price: \'' . $checkoutReviewGrandTotal - . '\' not equals with price from data set: \'' . $grandTotal . '\'' + number_format($prices['grandTotal'], 2), + "Grand Total price: $checkoutReviewGrandTotal not equals with price from data set: " . $prices['grandTotal'] ); } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index 7adfc7fc1ac63ea36b5a5eb242356dc80690ac82..f0c4143e4e91b985627ff89669da80783441f69c 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -12,41 +12,40 @@ use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Mtf\TestStep\TestStepInterface; /** - * Class PlaceOrderStep - * Place order in one page checkout + * Place order in one page checkout. */ class PlaceOrderStep implements TestStepInterface { /** - * Onepage checkout page + * Onepage checkout page. * * @var CheckoutOnepage */ protected $checkoutOnepage; /** - * Assert that Order Grand Total is correct on checkout page review block + * Assert that Order Grand Total is correct on checkout page review block. * * @var AssertOrderTotalOnReviewPage */ protected $assertOrderTotalOnReviewPage; /** - * One page checkout success page + * One page checkout success page. * * @var CheckoutOnepageSuccess */ protected $checkoutOnepageSuccess; /** - * Grand total price + * Price array. * * @var string */ - protected $grandTotal; + protected $prices; /** - * Checkout method + * Checkout method. * * @var string */ @@ -58,31 +57,31 @@ class PlaceOrderStep implements TestStepInterface * @param AssertOrderTotalOnReviewPage $assertOrderTotalOnReviewPage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param string $checkoutMethod - * @param string|null $grandTotal + * @param array $prices */ public function __construct( CheckoutOnepage $checkoutOnepage, AssertOrderTotalOnReviewPage $assertOrderTotalOnReviewPage, CheckoutOnepageSuccess $checkoutOnepageSuccess, $checkoutMethod, - $grandTotal = null + array $prices = [] ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertOrderTotalOnReviewPage = $assertOrderTotalOnReviewPage; - $this->grandTotal = $grandTotal; + $this->prices = $prices; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; $this->checkoutMethod = $checkoutMethod; } /** - * Place order after checking order totals on review step + * Place order after checking order totals on review step. * * @return array */ public function run() { - if ($this->grandTotal !== null) { - $this->assertOrderTotalOnReviewPage->processAssert($this->checkoutOnepage, $this->grandTotal); + if (!empty($this->prices)) { + $this->assertOrderTotalOnReviewPage->processAssert($this->checkoutOnepage, $this->prices); } $this->checkoutOnepage->getReviewBlock()->placeOrder(); diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml index eeea09970da769ab9eb00d22491aa9b4d6937999..3261040052d7dcff7d440a05031dc7e563d9eb03 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Customer.xml @@ -55,17 +55,6 @@ <field name="gender" xsi:type="string">Male</field> </dataset> - <dataset name="johndoe_with_balance"> - <field name="firstname" xsi:type="string">John</field> - <field name="lastname" xsi:type="string">Doe</field> - <field name="email" xsi:type="string">JohnDoe_%isolation%@example.com</field> - <field name="password" xsi:type="string">123123q</field> - <field name="password_confirmation" xsi:type="string">123123q</field> - <field name="dob" xsi:type="string">01/01/1990</field> - <field name="gender" xsi:type="string">Male</field> - <field name="amount_delta" xsi:type="string">501</field> - </dataset> - <dataset name="defaultBackend"> <field name="website_id" xsi:type="string">Main Website</field> <field name="firstname" xsi:type="string">John</field> diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml index a7697b5d62a60d863bf99a8b6c298cadb63b6f55..69a8cb56138fc5d25a46a3eb72ac00e5dd66be17 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/UpdateDownloadableProductEntityTest.xml @@ -15,18 +15,9 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">10</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">-</data> - <data name="product/data/category" xsi:type="string">-</data> - <data name="product/data/description" xsi:type="string">-</data> - <data name="product/data/short_description" xsi:type="string">-</data> - <data name="product/data/stock_data/manage_stock" xsi:type="string">-</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> - <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">-</data> - <data name="product/data/stock_data/min_qty" xsi:type="string">-</data> <data name="product/data/downloadable_sample/preset" xsi:type="string">with_three_samples</data> <data name="product/data/downloadable_links/preset" xsi:type="string">with_three_links</data> <data name="product/data/custom_options/preset" xsi:type="string">two_options</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -46,18 +37,8 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">50</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">Out of Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">-</data> <data name="product/data/category" xsi:type="string">Default Category</data> - <data name="product/data/description" xsi:type="string">-</data> - <data name="product/data/short_description" xsi:type="string">-</data> - <data name="product/data/stock_data/manage_stock" xsi:type="string">-</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> - <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">-</data> - <data name="product/data/stock_data/min_qty" xsi:type="string">-</data> - <data name="product/data/downloadable_sample/preset" xsi:type="string">-</data> <data name="product/data/downloadable_links/preset" xsi:type="string">default</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -71,20 +52,11 @@ <data name="product/data/price/value" xsi:type="string">9999</data> <data name="product/data/tax_class_id/dataSet" xsi:type="string">taxable_goods</data> <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">123</data> - <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">-</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">-</data> <data name="product/data/category" xsi:type="string">Default Category</data> - <data name="product/data/description" xsi:type="string">-</data> - <data name="product/data/short_description" xsi:type="string">-</data> <data name="product/data/stock_data/manage_stock" xsi:type="string">Yes</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">No</data> <data name="product/data/stock_data/min_qty" xsi:type="string">123</data> - <data name="product/data/downloadable_sample/preset" xsi:type="string">-</data> - <data name="product/data/downloadable_links/preset" xsi:type="string">-</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -100,18 +72,9 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">5</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">-</data> <data name="product/data/category" xsi:type="string">Default Category</data> <data name="product/data/description" xsi:type="string">This is description for downloadable product</data> - <data name="product/data/short_description" xsi:type="string">-</data> - <data name="product/data/stock_data/manage_stock" xsi:type="string">-</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> - <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">-</data> - <data name="product/data/stock_data/min_qty" xsi:type="string">-</data> - <data name="product/data/downloadable_sample/preset" xsi:type="string">-</data> <data name="product/data/downloadable_links/preset" xsi:type="string">default</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -127,18 +90,11 @@ <data name="product/data/quantity_and_stock_status/qty" xsi:type="string">10</data> <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> - <data name="product/data/weight" xsi:type="string">-</data> <data name="product/data/category" xsi:type="string">category %isolation%</data> - <data name="product/data/description" xsi:type="string">-</data> <data name="product/data/short_description" xsi:type="string">This is short description for downloadable product</data> - <data name="product/data/stock_data/manage_stock" xsi:type="string">-</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> - <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">-</data> - <data name="product/data/stock_data/min_qty" xsi:type="string">-</data> <data name="product/data/downloadable_sample/preset" xsi:type="string">default</data> <data name="product/data/downloadable_links/preset" xsi:type="string">with_three_links</data> <data name="product/data/custom_options/preset" xsi:type="string">default</data> - <data name="product/data/special_price" xsi:type="string">-</data> <data name="isRequired" xsi:type="string">Yes</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" /> @@ -159,16 +115,6 @@ <data name="product/data/quantity_and_stock_status/is_in_stock" xsi:type="string">In Stock</data> <data name="product/data/is_virtual" xsi:type="string">Yes</data> <data name="product/data/weight" xsi:type="string">10</data> - <data name="product/data/category" xsi:type="string">-</data> - <data name="product/data/description" xsi:type="string">-</data> - <data name="product/data/short_description" xsi:type="string">-</data> - <data name="product/data/stock_data/manage_stock" xsi:type="string">-</data> - <data name="product/data/stock_data/qty" xsi:type="string">-</data> - <data name="product/data/stock_data/use_config_min_qty" xsi:type="string">-</data> - <data name="product/data/stock_data/min_qty" xsi:type="string">-</data> - <data name="product/data/downloadable_sample/preset" xsi:type="string">-</data> - <data name="product/data/downloadable_links/preset" xsi:type="string">-</data> - <data name="product/data/custom_options/preset" xsi:type="string">-</data> <data name="product/data/special_price" xsi:type="string">40</data> <data name="isRequired" xsi:type="string">No</data> <data name="product/data/url_key" xsi:type="string">downloadableproduct-%isolation%</data> 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 2871ec912db01ef8020b14699f62d95c6f7299ac..5c45ad254c0b02f4444547e1b95ebba7fedf2727 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,6 +57,39 @@ class CheckoutData extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\Ch ], ], ], + '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 cd0bc02b3df4ccab18c34b1876eef98e775af553..fbf4305699a447b37e9a8d1bd756caec8f1f569e 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,5 +117,34 @@ <item name="preset" xsi:type="string">three_simple_products</item> </field> </dataset> + + <dataset name="three_simple_products_default_qty"> + <field name="name" xsi:type="string">Grouped product %isolation%</field> + <field name="sku" xsi:type="string">grouped_product_%isolation%</field> + <field name="category_ids" xsi:type="array"> + <item name="presets" xsi:type="string">default</item> + </field> + <field name="associated" xsi:type="array"> + <item name="preset" xsi:type="string">three_simple_products</item> + </field> + <field name="status" xsi:type="string">Product online</field> + <field name="visibility" xsi:type="string">Catalog, Search</field> + <field name="tax_class_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">taxable_goods</item> + </field> + <field name="url_key" xsi:type="string">test-grouped-product-%isolation%</field> + <field name="quantity_and_stock_status" xsi:type="array"> + <item name="is_in_stock" xsi:type="string">In Stock</item> + </field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="attribute_set_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="checkout_data" xsi:type="array"> + <item name="preset" xsi:type="string">three_simple_products_default_qty</item> + </field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/OfflinePayments/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/OfflinePayments/Test/Repository/ConfigData.xml index 068ba800210194b403fb71f6770fe927ce707690..8cdbbc48f92df79fe9ed26fb4b4dacd751c923c9 100644 --- a/dev/tests/functional/tests/app/Magento/OfflinePayments/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/OfflinePayments/Test/Repository/ConfigData.xml @@ -103,12 +103,6 @@ </dataset> <dataset name="checkmo_specificcountry_gb_rollback"> - <field name="payment/checkmo/active" xsi:type="array"> - <item name="scope" xsi:type="string">payment</item> - <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">No</item> - <item name="value" xsi:type="number">0</item> - </field> <field name="payment/checkmo/allowspecific" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Form.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php old mode 100755 new mode 100644 similarity index 98% rename from dev/tests/functional/tests/app/Magento/Review/Test/Block/Form.php rename to dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php index 449bc91419bbdd368b4451d28887e03ed3661e56..ae9ad57029992bccbd9fdab092443967b673161e --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Form.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php @@ -16,7 +16,7 @@ use Magento\Mtf\Block\Form as AbstractForm; /** * Review form on frontend. */ -class Form extends AbstractForm +class ReviewForm extends AbstractForm { /** * Legend selector. diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Form.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.xml old mode 100755 new mode 100644 similarity index 100% rename from dev/tests/functional/tests/app/Magento/Review/Test/Block/Form.xml rename to dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.xml diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Page/Product/CatalogProductView.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Product/CatalogProductView.xml new file mode 100644 index 0000000000000000000000000000000000000000..4e80f240eb1210acb7a23f17991390c3368ee5a9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Product/CatalogProductView.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="CatalogProductView" area="Product" mca="catalog/product/view" module="Magento_Catalog"> + <block name="reviewSummary" class="Magento\Review\Test\Block\Product\View\Summary" locator=".product-reviews-summary" strategy="css selector" /> + <block name="customerReviewBlock" class="Magento\Review\Test\Block\Product\View" locator="#customer-reviews" strategy="css selector" /> + <block name="reviewFormBlock" class="Magento\Review\Test\Block\ReviewForm" locator="#review-form" strategy="css selector" /> + </page> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..e118bac1958fb0b3c9d0906bdafe181e157a9a7b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Coupons.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\Create; + +use Magento\Backend\Test\Block\Widget\Form; +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\Mtf\Client\Locator; + +/** + * Adminhtml sales order create coupons block. + */ +class Coupons extends Form +{ + /** + * Fill discount code input selector. + * + * @var string + */ + protected $couponCode = 'input[name="coupon_code"]'; + + /** + * Click apply button selector. + * + * @var string + */ + protected $applyButton = '//*[@id="coupons:code"]/following-sibling::button'; + + /** + * Enter discount code and click apply button. + * + * @param SalesRuleInjectable $code + * @return void + */ + public function applyCouponCode(SalesRuleInjectable $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/Block/Adminhtml/Order/Create/CustomerActivities/Sidebar.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities/Sidebar.php index f9c089f1a25d99465df54d38fdc02023c7916d3f..f11fc5fce5417a63c7aee70db7ba264f8dc38190 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities/Sidebar.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/CustomerActivities/Sidebar.php @@ -29,15 +29,15 @@ abstract class Sidebar extends Block protected $addToOrderProductName = '//tr/td[.="%s"]'; /** - * Add product to order by name. + * Add productz to order. * - * @param string|array $names + * @param array $products * @return void */ - public function addToOrderByName($names) + public function addProductsToOrder(array $products) { - $names = is_array($names) ? $names : [$names]; - foreach ($names as $name) { + foreach ($products as $product) { + $name = $product->getName(); $this->_rootElement->find(sprintf($this->addToOrderProductName, $name), Locator::SELECTOR_XPATH)->click(); $this->_rootElement->click(); $this->_rootElement->find(sprintf($this->addToOrder, $name), Locator::SELECTOR_XPATH, 'checkbox') diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php index 7d2aec9dd17a3a28781cb7bdaeedffc277252f1b..03481f3e5b9eeaa0799429519d06796eb6b69ccd 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Items.php @@ -11,31 +11,30 @@ use Magento\Mtf\Block\Block; use Magento\Mtf\Client\Locator; /** - * Class Items - * Adminhtml sales order create items block + * Adminhtml sales order create items block. */ class Items extends Block { /** - * 'Add Products' button + * 'Add Products' button. * * @var string */ protected $addProducts = "//button[span='Add Products']"; /** - * Item product + * Item product. * * @var string */ protected $itemProduct = '//tr[td//*[normalize-space(text())="%s"]]'; /** - * Product names + * Product names. * * @var string */ - protected $productNames = '//td[@class="col-product"]//span'; + protected $productNames = '//td[@class="col-product"]/span'; /** * Selector for template block. @@ -45,7 +44,7 @@ class Items extends Block protected $template = './ancestor::body'; /** - * Click 'Add Products' button + * Click 'Add Products' button. * * @return void */ @@ -63,7 +62,7 @@ class Items extends Block } /** - * Get item product block + * Get item product block. * * @param string $name * @return \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items\ItemProduct diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php new file mode 100644 index 0000000000000000000000000000000000000000..47e544da94f09bc336e7f58cb40ef84b443c192a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo; + +use Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm; +use Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items; + +/** + * Credit memo create form. + */ +class Form extends AbstractForm +{ + /** + * Items block css selector. + * + * @var string + */ + protected $items = '#creditmemo_item_container'; + + /** + * Get items block. + * + * @return Items + */ + public function getItemsBlock() + { + return $this->blockFactory->create( + 'Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items', + ['element' => $this->_rootElement->find($this->items)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.xml new file mode 100644 index 0000000000000000000000000000000000000000..7e75ac518b8e7a2e66c38e5d9798c220d281e39f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <wrapper>creditmemo</wrapper> + <fields> + <comment_text /> + <shipping_amount /> + <adjustment_positive /> + <adjustment_negative /> + <comment_customer_notify> + <input>checkbox</input> + </comment_customer_notify> + <send_email> + <input>checkbox</input> + </send_email> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php new file mode 100644 index 0000000000000000000000000000000000000000..c97952243ea70985dd0690237b1e66ca5cdf0419 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form; + +use Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product; +use Magento\Mtf\Block\Block; +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; + +/** + * Credit Memo Items block on Credit Memo new page. + */ +class Items extends Block +{ + /** + * Item product. + * + * @var string + */ + protected $productItems = '//tr[contains(.,"%s")]'; + + /** + * 'Update Qty's' button css selector. + * + * @var string + */ + protected $updateQty = '.update-button'; + + /** + * Get item product block. + * + * @param FixtureInterface $product + * @return Product + */ + public function getItemProductBlock(FixtureInterface $product) + { + $selector = sprintf($this->productItems, $product->getSku()); + return $this->blockFactory->create( + 'Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product', + ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] + ); + } + + /** + * Click update qty button. + * + * @return void + */ + public function clickUpdateQty() + { + $this->_rootElement->find($this->updateQty)->click(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.php new file mode 100644 index 0000000000000000000000000000000000000000..bf367ef4339cc3cd06fbd943698c8a478ae0c47b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items; + +/** + * Item product form on credit memo items block. + */ +class Product extends \Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Product +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.xml new file mode 100644 index 0000000000000000000000000000000000000000..afde45a79835db8a6c029b9980af9a9685a3ad99 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items/Product.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <fields> + <qty> + <selector>[name$="[qty]"]</selector> + </qty> + <back_to_stock> + <selector>[name$="[back_to_stock]"]</selector> + <input>checkbox</input> + </back_to_stock> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php new file mode 100644 index 0000000000000000000000000000000000000000..a974bbb8b9aadb6739b31e79682eafb491b74e13 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo; + +use Magento\Mtf\Client\Locator; + +/** + * Invoice totals block. + */ +class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\Totals +{ + /** + * Submit invoice button selector. + * + * @var string + */ + protected $submit = '[data-ui-id="order-items-submit-button"]'; + + /** + * Capture amount select selector. + * + * @var string + */ + protected $capture = '[name="invoice[capture_case]"]'; + + /** + * Submit invoice. + * + * @return void + */ + public function submit() + { + $browser = $this->_rootElement; + $selector = $this->submit . '.disabled'; + $strategy = Locator::SELECTOR_CSS; + $browser->waitUntil( + function () use ($browser, $selector, $strategy) { + $element = $browser->find($selector, $strategy); + return $element->isVisible() == false ? true : null; + } + ); + $this->_rootElement->find($this->submit)->click(); + } + + /** + * Set Capture amount option: + * Capture Online|Capture Offline|Not Capture + * + * @param string $option + * @return void + */ + public function setCaptureOption($option) + { + $this->_rootElement->find($this->capture, Locator::SELECTOR_CSS, 'select')->setValue($option); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Grid.php index 8b43fc9c27ba44de78336999a4abb55aa4278999..7895c39a3a07399c78144d6f96ac6491d794eac0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Grid.php @@ -9,14 +9,14 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Invoice; use Magento\Backend\Test\Block\Widget\Grid as GridInterface; /** - * Class Grid - * Sales order grid - * + * Sales order grid. */ class Grid extends GridInterface { /** - * {@inheritdoc} + * Filters array mapping. + * + * @var array */ protected $filters = [ 'id' => [ @@ -25,50 +25,42 @@ class Grid extends GridInterface ]; /** - * Invoice amount + * Invoice amount. * * @var string */ protected $invoiceAmount = 'td.col-qty.col-base_grand_total'; /** - * An element locator which allows to select entities in grid + * An element locator which allows to select entities in grid. * * @var string */ protected $selectItem = 'tbody tr .col-invoice-number'; /** - * Get first invoice amount + * Get first invoice amount. * - * @return array|string + * @return string */ public function getInvoiceAmount() { - $invoiceAmount = $this->getInvoiceAmountElement()->getText(); + $invoiceAmount = $this->_rootElement->find($this->invoiceAmount)->getText(); return $this->escapeCurrency($invoiceAmount); } /** - * Click the first invoice amount + * Click the first invoice amount. * * @return void */ public function clickInvoiceAmount() { - $this->getInvoiceAmountElement()->click(); - } - - /** - * @return mixed|\Magento\Mtf\Client\Element - */ - private function getInvoiceAmountElement() - { - return $this->_rootElement->find($this->invoiceAmount); + $this->_rootElement->find($this->invoiceAmount)->click(); } /** - * Method that escapes currency symbols + * Method that escapes currency symbols. * * @param string $price * @return string|null diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php index 377cd4ba869dcf5fe606ce367a5b690f946c0442..f0fa33ca3a36d6e9e94681be8617915cee97c5f8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php @@ -7,13 +7,12 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; /** - * Class StatusGrid - * Backend sales order's status management grid + * Backend sales order's status management grid. */ class StatusGrid extends \Magento\Backend\Test\Block\Widget\Grid { /** - * Filters array mapping + * Filters array mapping. */ protected $filters = [ 'label' => [ @@ -28,7 +27,7 @@ class StatusGrid extends \Magento\Backend\Test\Block\Widget\Grid ]; /** - * Locator value for link in action column + * Locator value for link in action column. * * @var string */ @@ -42,7 +41,7 @@ class StatusGrid extends \Magento\Backend\Test\Block\Widget\Grid protected $unassignLink = '[data-column="unassign"] a'; /** - * Search custom status and unassign it + * Search custom status and unassign it. * * @param array $filter * @throws \Exception diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php index aac809e587dc15dec3869fd4730c4313dedb74b0..2cff2dad1f87ba3907482716c35b7f6953b78044 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php @@ -7,36 +7,12 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab; use Magento\Mtf\Block\Block; -use Magento\Mtf\Client\Locator; /** - * Class Info - * Order information tab block - * + * Order information tab block. */ class Info extends Block { - /** - * 3D Secure Verification Result - * - * @var string - */ - protected $_verificationResult = '//tr[normalize-space(th)="3D Secure Verification Result:"]/td'; - - /** - * 3D Secure Cardholder Validation - * - * @var string - */ - protected $_cardholderValidation = '//tr[normalize-space(th)="3D Secure Cardholder Validation:"]/td'; - - /** - * 3D Secure Electronic Commerce Indicator - * - * @var string - */ - protected $_eCommerceIndicator = '//tr[normalize-space(th)="3D Secure Electronic Commerce Indicator:"]/td'; - /** * Order status selector * @@ -44,36 +20,6 @@ class Info extends Block */ protected $orderStatus = '#order_status'; - /** - * Get 3D Secure Verification Result - * - * @return array|string - */ - public function getVerificationResult() - { - return $this->_rootElement->find($this->_verificationResult, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get 3D Secure Verification Result - * - * @return array|string - */ - public function getCardholderValidation() - { - return $this->_rootElement->find($this->_cardholderValidation, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get 3D Secure Electronic Commerce Indicator - * - * @return array|string - */ - public function getEcommerceIndicator() - { - return $this->_rootElement->find($this->_eCommerceIndicator, Locator::SELECTOR_XPATH)->getText(); - } - /** * Get order status from info block * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/History.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/History.php index bacbfe439e5591e8d9439d13d450d8a73fb6f504..0a2f39e06c7ac7e1db5aadec37d8f9b259b8b55f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/History.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/History.php @@ -27,7 +27,7 @@ class History extends Block * * @var string */ - protected $itemOrder = '//tr[td[contains(@class, "id") and normalize-space(.)="%d"]]'; + protected $itemOrder = '//tr[td[contains(@class, "id") and normalize-space(.)="%s"]]'; /** * Order total css selector. diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php index c8cb4a49db99ea30bfb4df35c1188ab72cef5c2f..04424257520c5c3fb7b7870add0d646c437c1ed5 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php @@ -155,6 +155,7 @@ class View extends Block public function openLinkByName($name) { $this->_rootElement->find(sprintf($this->link, $name), Locator::SELECTOR_XPATH)->click(); + sleep(3); // TODO: remove after resolving an issue with ajax on Frontend. } /** diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View/ActionsToolbar.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View/ActionsToolbar.php index 4c5756fecffd692f2951fa4f406f36b5de2ce106..bee100f5630759b0c4471635a4e3ec82de5be052 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View/ActionsToolbar.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View/ActionsToolbar.php @@ -23,6 +23,9 @@ class ActionsToolbar extends Block /** * Click link on this page. + * + * @param string $linkName + * @throws \Exception */ public function clickLink($linkName) { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.php new file mode 100644 index 0000000000000000000000000000000000000000..8f12c2710722401f17d38ac9354f56511f53da80 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Block\Widget\Guest; + +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Customer\Test\Fixture\Customer; + +/** + * Orders and Returns form search block. + */ +class Form extends \Magento\Mtf\Block\Form +{ + /** + * Search button selector. + * + * @var string + */ + protected $searchButtonSelector = '.action.submit'; + + /** + * Selector for loads form. + * + * @var string + */ + protected $loadsForm = 'div[id*=oar] input'; + + /** + * Fill the form. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @param bool $isSearchByEmail [optional] + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null, $isSearchByEmail = true) + { + if ($fixture instanceof InjectableFixture) { + /** @var OrderInjectable $fixture */ + /** @var Customer $customer */ + $customer = $fixture->getDataFieldConfig('customer_id')['source']->getCustomer(); + $data = [ + 'order_id' => $fixture->getId(), + 'billing_last_name' => $customer->getLastname(), + ]; + + if ($isSearchByEmail) { + $data['find_order_by'] = 'Email'; + $data['email_address'] = $customer->getEmail(); + } else { + $data['find_order_by'] = 'ZIP Code'; + $data['billing_zip_code'] = $fixture->getDataFieldConfig('billing_address_id')['source']->getPostcode(); + } + } else { + $data = $fixture->getData(); + } + $fields = isset($data['fields']) ? $data['fields'] : $data; + $mapping = $this->dataMapping($fields); + + $this->waitLoadForm(); + $this->_fill($mapping, $element); + + return $this; + } + + /** + * Wait while form is loading. + * + * @return void + */ + protected function waitLoadForm() + { + $rootElement = $this->_rootElement; + $selector = $this->loadsForm; + $this->browser->waitUntil( + function () use ($rootElement, $selector) { + $inputs = $rootElement->getElements($selector); + $i = 0; + foreach ($inputs as $input) { + if ($input->isVisible()) { + ++$i; + } + } + return $i == 1 ? true : null; + } + ); + } + + /** + * Submit search form. + * + * @return void + */ + public function submit() + { + $this->_rootElement->find($this->searchButtonSelector, Locator::SELECTOR_CSS)->click(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.xml new file mode 100644 index 0000000000000000000000000000000000000000..dcbdad87eeb4d8c7d6c5790a9402e91d509ebae6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Widget/Guest/Form.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <fields> + <order_id> + <selector>[name='oar_order_id']</selector> + </order_id> + <billing_last_name> + <selector>[name='oar_billing_lastname']</selector> + </billing_last_name> + <find_order_by> + <selector>[name='oar_type']</selector> + <input>select</input> + </find_order_by> + <email_address> + <selector>[name='oar_email']</selector> + </email_address> + <billing_zip_code> + <selector>[name='oar_zip']</selector> + </billing_zip_code> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderButtonsAvailable.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderButtonsAvailable.php index 676561e9aa8e9ac374bf226d5b3873677a665967..f2b7260f8930604b3eaebddbb5ffc0640bf8d3d0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderButtonsAvailable.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderButtonsAvailable.php @@ -6,27 +6,26 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Sales\Test\Page\SalesOrder; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertOrderButtonsAvailable - * Assert that specified in data set buttons exist on order page in backend + * Assert that specified in data set buttons exist on order page in backend. */ class AssertOrderButtonsAvailable extends AbstractConstraint { /** - * Assert that specified in data set buttons exist on order page in backend + * Assert that specified in data set buttons exist on order page in backend. * - * @param SalesOrder $salesOrder + * @param SalesOrderView $salesOrderView * @param string $orderButtonsAvailable * @return void */ - public function processAssert(SalesOrder $salesOrder, $orderButtonsAvailable) + public function processAssert(SalesOrderView $salesOrderView, $orderButtonsAvailable) { $buttons = explode(',', $orderButtonsAvailable); $absentButtons = []; - $actionsBlock = $salesOrder->getOrderActionsBlock(); + $actionsBlock = $salesOrderView->getPageActions(); foreach ($buttons as $button) { $button = trim($button); @@ -42,7 +41,7 @@ class AssertOrderButtonsAvailable extends AbstractConstraint } /** - * Returns string representation of successful assertion + * Returns string representation of successful assertion. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistory.php index 1630e60c334d05e41de2d4e4f2b0aa5003330ceb..2e88c267f38b0603d81edb6fa8a38dd2f81ac266 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistory.php @@ -26,14 +26,14 @@ class AssertOrderCommentsHistory extends AbstractConstraint * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder * @param string $orderId - * @param string $grandTotal + * @param array $prices * @return void */ public function processAssert( SalesOrderView $salesOrderView, OrderIndex $salesOrder, $orderId, - $grandTotal + array $prices ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); @@ -41,7 +41,7 @@ class AssertOrderCommentsHistory extends AbstractConstraint $actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); \PHPUnit_Framework_Assert::assertContains( - self::AUTHORIZED_AMOUNT . $grandTotal, + self::AUTHORIZED_AMOUNT . $prices['grandTotal'], $actualAuthorizedAmount, 'Incorrect authorized amount value for the order #' . $orderId ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php index d5ba1959297105811209aa3dbbd30321748bfcdd..f0a84298aaa2108f02e364065b1505ad426bc86b 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderGrandTotal.php @@ -21,20 +21,20 @@ class AssertOrderGrandTotal extends AbstractConstraint * @param SalesOrderView $salesOrderView * @param string $orderId * @param OrderIndex $salesOrder - * @param string $grandTotal + * @param array $prices * @return void */ public function processAssert( SalesOrderView $salesOrderView, OrderIndex $salesOrder, $orderId, - $grandTotal + array $prices ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); \PHPUnit_Framework_Assert::assertEquals( - $grandTotal, + $prices['grandTotal'], $salesOrderView->getOrderTotalsBlock()->getGrandTotal(), 'Grand Total price does not equal to price from data set.' ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php index 7967bf579874021a78f52deb2df10e49afab26e7..cd1d86ea1740c7c0588f3c4eb9c239c1f2b3e7b8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderNotVisibleOnMyAccount.php @@ -11,24 +11,17 @@ use Magento\Customer\Test\Page\CustomerAccountIndex; use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\OrderHistory; use Magento\Mtf\Constraint\AbstractConstraint; -use Magento\Mtf\ObjectManager; /** - * Class AssertOrderNotVisibleOnMyAccount - * Assert order is not visible in customer account on frontend + * Assert order is not visible in customer account on frontend. */ class AssertOrderNotVisibleOnMyAccount extends AbstractConstraint { - /* tags */ - const SEVERITY = 'low'; - /* end tags */ - /** * Assert order is not visible in customer account on frontend * * @param OrderInjectable $order * @param Customer $customer - * @param ObjectManager $objectManager * @param CustomerAccountIndex $customerAccountIndex * @param OrderHistory $orderHistory * @param string $status @@ -37,7 +30,6 @@ class AssertOrderNotVisibleOnMyAccount extends AbstractConstraint public function processAssert( OrderInjectable $order, Customer $customer, - ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status @@ -46,14 +38,14 @@ class AssertOrderNotVisibleOnMyAccount extends AbstractConstraint 'id' => $order->getId(), 'status' => $status, ]; - $customerLogin = $objectManager->create( + $this->objectManager->create( 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', ['customer' => $customer] - ); - $customerLogin->run(); + )->run(); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders'); \PHPUnit_Framework_Assert::assertFalse( - $orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), + $orderHistory->getOrderHistoryBlock()->isVisible() + && $orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . implode(', ', $filter) . '\' is present in Orders block on frontend.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderGrandTotal.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderGrandTotal.php index 8c6e930acbf77be7370b1f6b4743fb3c0d44e457..7369b9449d31a91767112e44fa822c12b4c7c8aa 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderGrandTotal.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertSalesPrintOrderGrandTotal.php @@ -18,13 +18,13 @@ class AssertSalesPrintOrderGrandTotal extends AbstractConstraint * Assert that Grand Total price was printed correctly on sales guest print page. * * @param SalesGuestPrint $salesGuestPrint - * @param string $grandTotal + * @param array $prices * @return void */ - public function processAssert(SalesGuestPrint $salesGuestPrint, $grandTotal) + public function processAssert(SalesGuestPrint $salesGuestPrint, array $prices) { \PHPUnit_Framework_Assert::assertEquals( - $grandTotal, + $prices['grandTotal'], $salesGuestPrint->getViewBlock()->getItemBlock()->getGrandTotal(), "Grand total was printed incorrectly." ); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml new file mode 100644 index 0000000000000000000000000000000000000000..4f26f0a213fffc903b7e364b16f3b79f286ea36f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml @@ -0,0 +1,618 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture name="orderInjectable" module="Magento_Sales" type="flat" entity_type="sales_order" collection="Magento\Sales\Model\Resource\Order\Collection" identifier="" repository_class="Magento\Sales\Test\Repository\OrderInjectable" handler_interface="Magento\Sales\Test\Handler\OrderInjectable\OrderInjectableInterface" class="Magento\Sales\Test\Fixture\OrderInjectable"> + <dataset name="default"> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="base_currency_code" xsi:type="boolean">false</field> + <field name="order_currency_code" xsi:type="string">USD</field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + </dataset> + <field name="entity_id" is_required="1" source="Magento\Sales\Test\Fixture\OrderInjectable\EntityId" group="null"> + <default_value xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default</item> + </default_value> + </field> + <field name="state" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="status" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="coupon_code" is_required="" source="Magento\Sales\Test\Fixture\OrderInjectable\CouponCode" group="null"> + <default_value xsi:type="null" /> + </field> + <field name="protect_code" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_description" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="is_virtual" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="store_id" is_required="" source="Magento\Sales\Test\Fixture\OrderInjectable\StoreId" group="null"> + <default_value xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </default_value> + </field> + <field name="customer_id" is_required="" source="Magento\Sales\Test\Fixture\OrderInjectable\CustomerId" group="null"> + <default_value xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </default_value> + </field> + <field name="base_discount_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_discount_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_discount_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_discount_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_grand_total" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_subtotal" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_subtotal_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_subtotal_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_subtotal_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_tax_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_to_global_rate" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_to_order_rate" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_invoiced_cost" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_offline_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_online_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_paid" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_qty_ordered" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="discount_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="discount_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="discount_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="discount_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="grand_total" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="store_to_base_rate" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="store_to_order_rate" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="subtotal" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="subtotal_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="subtotal_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="subtotal_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="tax_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_canceled" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_offline_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_online_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_paid" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_qty_ordered" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="can_ship_partially" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="can_ship_partially_item" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_is_guest" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_note_notify" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="billing_address_id" is_required="" source="Magento\Sales\Test\Fixture\OrderInjectable\BillingAddressId"> + <default_value xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </default_value> + </field> + <field name="customer_group_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="edit_increment" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="email_sent" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="forced_shipment_with_invoice" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="payment_auth_expiration" is_required=""> + <default_value xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </default_value> + </field> + <field name="quote_address_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="quote_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_address_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="adjustment_negative" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="adjustment_positive" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_adjustment_negative" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_adjustment_positive" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_discount_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_subtotal_incl_tax" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_total_due" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="payment_authorization_amount" is_required=""> + <default_value xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </default_value> + </field> + <field name="shipping_discount_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="subtotal_incl_tax" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_due" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="weight" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_dob" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="increment_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="applied_rule_ids" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_currency_code" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_email" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_firstname" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_lastname" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_middlename" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_prefix" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_suffix" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_taxvat" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="discount_description" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="ext_customer_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="ext_order_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="global_currency_code" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="hold_before_state" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="hold_before_status" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="order_currency_code" is_required=""> + <default_value xsi:type="string">USD</default_value> + </field> + <field name="original_increment_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="relation_child_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="relation_child_real_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="relation_parent_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="relation_parent_real_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="remote_ip" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_method" is_required=""> + <default_value xsi:type="string">flatrate_flatrate</default_value> + </field> + <field name="store_currency_code" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="store_name" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="x_forwarded_for" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_note" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="created_at" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="updated_at" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="total_item_count" is_required=""> + <default_value xsi:type="number">0</default_value> + </field> + <field name="customer_gender" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="hidden_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_hidden_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_hidden_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_hidden_tax_amnt" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="hidden_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_hidden_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="hidden_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_hidden_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="shipping_incl_tax" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_shipping_incl_tax" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="coupon_rule_name" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_customer_balance_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_balance_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_customer_balance_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_balance_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_customer_balance_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_balance_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="bs_customer_bal_total_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="customer_bal_total_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gift_cards" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_gift_cards_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gift_cards_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_gift_cards_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gift_cards_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="base_gift_cards_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gift_cards_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gift_message_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_id" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_allow_gift_receipt" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_add_card" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_price" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_tax_amount" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_price_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_tax_amount_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_tax_amount_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_tax_invoiced" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_price_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_base_tax_amount_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_tax_amount_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_base_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_items_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_base_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="gw_card_tax_refunded" is_required=""> + <default_value xsi:type="null" /> + </field> + <field name="id" /> + <field name="price" is_required="1" group="null" source="Magento\Sales\Test\Fixture\OrderInjectable\Price" /> + </fixture> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/BillingAddressId.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/BillingAddressId.php new file mode 100644 index 0000000000000000000000000000000000000000..8aaa2b0cc381d1df3bdd37aa7e590a2f5d75e433 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/BillingAddressId.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +use Magento\Customer\Test\Fixture\Address; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * Billing address data. + */ +class BillingAddressId extends DataSource +{ + /** + * Current preset. + * + * @var string + */ + protected $currentPreset; + + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->params = $params; + if (isset($data['value'])) { + $this->data = $data['value']; + return; + } + if (isset($data['dataSet'])) { + $addresses = $fixtureFactory->createByCode('address', ['dataSet' => $data['dataSet']]); + $this->data = $addresses->getData(); + $this->data['street'] = [$this->data['street']]; + } + if (isset($data['billingAddress']) && $data['billingAddress'] instanceof Address) { + /** @var Address $address */ + $address = $data['billingAddress']; + $this->data = $address->getData(); + $this->data['street'] = [$this->data['street']]; + } + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..b3d081c56d4c759fe4728523de1732c42f1477d0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CouponCode.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * Coupon code data. + */ +class CouponCode extends DataSource +{ + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->params = $params; + if (isset($data['value']) && $data['value'] instanceof SalesRuleInjectable) { + $this->data = $data['value']; + return; + } + if (isset($data['dataSet'])) { + $salesRule = $fixtureFactory->createByCode('salesRuleInjectable', ['dataSet' => $data['dataSet']]); + $salesRule->persist(); + $this->data = $salesRule; + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CustomerId.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CustomerId.php new file mode 100644 index 0000000000000000000000000000000000000000..b970afcd0d1ab5e7b87175dabe52324ba57d2d2f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/CustomerId.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +use Magento\Customer\Test\Fixture\Customer; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * Prepare CustomerId for order list. + */ +class CustomerId extends DataSource +{ + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $params + * @param array $data + */ + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) + { + $this->params = $params; + if (isset($data['customer']) && $data['customer'] instanceof Customer) { + $this->data = $data['customer']; + return; + } + if (isset($data['dataSet'])) { + $customer = $fixtureFactory->createByCode('customer', ['dataSet' => $data['dataSet']]); + if ($customer->hasData('id') === false) { + $customer->persist(); + } + $this->data = $customer; + } + } + + /** + * Get customer fixture. + * + * @return Customer + */ + public function getCustomer() + { + return $this->data; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/EntityId.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/EntityId.php new file mode 100644 index 0000000000000000000000000000000000000000..7b99bad4281b90281275c27b779155d1c97cd53f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/EntityId.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * EntityId data. + */ +class EntityId extends DataSource +{ + /** + * Current preset. + * + * @var string + */ + protected $currentPreset; + + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->params = $params; + + if (isset($data['value'])) { + $this->data = $data['value']; + return; + } + + if (!isset($data['products'])) { + return; + } + if (is_string($data['products'])) { + $products = explode(',', $data['products']); + foreach ($products as $product) { + list($fixture, $dataSet) = explode('::', trim($product)); + $product = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]); + $product->persist(); + $this->data['products'][] = $product; + } + } elseif (is_array($data['products'])) { + $this->data['products'] = $data['products']; + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/Price.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/Price.php new file mode 100644 index 0000000000000000000000000000000000000000..0de14ee47f836ac21ef905568ff4d19fe4a8857c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/Price.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +/** + * Data keys: + * - preset (Price data verification preset name) + */ +class Price extends \Magento\Catalog\Test\Fixture\CatalogProductSimple\Price +{ + /** + * @constructor + * @param array $params + * @param array $data + */ + public function __construct(array $params, array $data = []) + { + $this->params = $params; + if (isset($data['preset'])) { + $this->currentPreset = $data['preset']; + $this->data = $this->getPreset(); + } + } + + /** + * Get preset array + * + * @return array|null + */ + public function getPreset() + { + $presets = [ + 'default_with_discount' => [ + 'subtotal' => 560, + 'discount' => 280, + ], + 'full_invoice' => [ + [ + 'grand_order_total' => 565, + 'grand_invoice_total' => 565, + ], + ], + 'partial_invoice' => [ + [ + 'grand_order_total' => 210, + 'grand_invoice_total' => 110, + ], + ], + 'full_refund' => [ + [ + 'grand_creditmemo_total' => 565, + ], + ], + 'full_refund_with_zero_shipping_refund' => [ + [ + 'grand_creditmemo_total' => 555, + ], + ], + 'partial_refund' => [ + [ + 'grand_creditmemo_total' => 110, + ], + ], + ]; + if (!isset($presets[$this->currentPreset])) { + return null; + } + return $presets[$this->currentPreset]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/StoreId.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/StoreId.php new file mode 100644 index 0000000000000000000000000000000000000000..11579ab84e9e8502d143e5c285f4774f271415c9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable/StoreId.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Fixture\OrderInjectable; + +use Magento\Store\Test\Fixture\Store; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * Prepare StoreId for Store Group. + */ +class StoreId extends DataSource +{ + /** + * Store fixture. + * + * @var Store + */ + public $store; + + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $data + * @param array $params [optional] + */ + public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = []) + { + $this->params = $params; + + $storeData = isset($data['dataSet']) ? ['dataSet' => $data['dataSet']] : []; + if (isset($data['data'])) { + $storeData = array_replace_recursive($storeData, $data); + } + + if ($storeData) { + $store = $fixtureFactory->createByCode('store', $storeData); + /** @var Store $store */ + if (!$store->getStoreId()) { + $store->persist(); + } + $this->store = $store; + $this->data = $store->getName(); + } + } + + /** + * Return Store fixture. + * + * @return Store + */ + public function getStore() + { + return $this->store; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderStatus.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderStatus.xml new file mode 100644 index 0000000000000000000000000000000000000000..b86502663dbd5b42802155a742536c492ab9d278 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderStatus.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture name="orderStatus" module="Magento_Sales" type="composite" collection="Magento\Sales\Model\Resource\Order\Status\Collection" repository_class="Magento\Sales\Test\Repository\OrderStatus" handler_interface="Magento\Sales\Test\Handler\OrderStatus\OrderStatusInterface" class="Magento\Sales\Test\Fixture\OrderStatus"> + <dataset name="default"> + <field name="status" xsi:type="string">order_status%isolation%</field> + <field name="label" xsi:type="string">orderLabel%isolation%</field> + </dataset> + <field name="status" is_required="1"> + <default_value xsi:type="string">order_status%isolation%</default_value> + </field> + <field name="label" is_required=""> + <default_value xsi:type="string">orderLabel%isolation%</default_value> + </field> + <field name="state" is_required="1"> + <default_value xsi:type="null" /> + </field> + <field name="is_default" is_required=""> + <default_value xsi:type="number">0</default_value> + </field> + <field name="visible_on_front" is_required=""> + <default_value xsi:type="number">0</default_value> + </field> + </fixture> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..e98f4ba0afff567f479384c0c7eaecef6543505d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/Curl.php @@ -0,0 +1,375 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Handler\OrderInjectable; + +use Magento\Bundle\Test\Fixture\BundleProduct; +use Magento\ConfigurableProduct\Test\Fixture\ConfigurableProduct; +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\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Handler\Curl as AbstractCurl; +use Magento\Mtf\Util\Protocol\CurlInterface; +use Magento\Mtf\Util\Protocol\CurlTransport; +use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; + +/** + * Create new order via curl. + */ +class Curl extends AbstractCurl implements OrderInjectableInterface +{ + /** + * Customer fixture. + * + * @var Customer + */ + protected $customer; + + /** + * Customer fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Mapping values for data. + * + * @var array + */ + protected $mappingData = [ + 'region_id' => [ + 'California' => '12', + ], + 'country_id' => [ + 'United States' => 'US', + ], + ]; + + /** + * Steps for create order on backend. + * + * @var array + */ + protected $steps = [ + 'customer_choice' => 'header,data', + 'products_choice' => 'search,items,shipping_method,totals,giftmessage,billing_method', + 'apply_coupon_code' => 'items,shipping_method,totals,billing_method', + 'shipping_data_address' => 'shipping_method,billing_method,shipping_address,totals,giftmessage', + 'shipping_data_method_get' => 'shipping_method,totals', + 'shipping_data_method_set' => 'shipping_method,totals,billing_method', + ]; + + /** + * Post request for creating order. + * + * @param FixtureInterface|null $fixture [optional] + * @return array + */ + public function persist(FixtureInterface $fixture = null) + { + $this->order = $fixture; + $this->customer = $fixture->getDataFieldConfig('customer_id')['source']->getCustomer(); + $data = $this->replaceMappingData($this->prepareData($fixture)); + return ['id' => $this->createOrder($data)]; + } + + /** + * Prepare POST data for creating product request. + * + * @param FixtureInterface $fixture + * @return array + */ + protected function prepareData(FixtureInterface $fixture) + { + $result = []; + $data = $fixture->getData(); + $result['customer_choice'] = $this->prepareCustomerData($data); + $result['products_choice'] = $this->prepareProductsData($data['entity_id']); + if (isset($data['coupon_code'])) { + $result['apply_coupon_code'] = $this->prepareCouponCode($data['coupon_code']); + } + $result['order_data'] = $this->prepareOrderData($data); + $result['shipping_data_address'] = $this->prepareShippingData($result['order_data']); + $result['shipping_data_method_get'] = [ + 'payment' => $data['payment_auth_expiration'], + 'collect_shipping_rates' => 1, + ]; + $result['shipping_data_method_set'] = [ + 'order' => ['shipping_method' => $result['order_data']['order']['shipping_method']], + 'payment' => $data['payment_auth_expiration'], + ]; + + return $result; + } + + /** + * Prepare coupon data. + * + * @param SalesRuleInjectable $data + * @return array + */ + protected function prepareCouponCode(SalesRuleInjectable $data) + { + return ['order' => ['coupon' => ['code' => $data->getCouponCode()]]]; + } + + /** + * Prepare shipping data. + * + * @param array $data + * @return array + */ + protected function prepareShippingData(array $data) + { + $result = [ + 'order' => [ + 'billing_address' => $data['billing_address'], + ], + 'payment' => $this->order->getPaymentAuthExpiration(), + 'reset_shipping' => 1, + 'shipping_as_billing' => 1, + ]; + return $result; + } + + /** + * Prepare products data. + * + * @param array $data + * @return array + */ + protected function prepareProductsData(array $data) + { + $result['item'] = []; + foreach ($data['products'] as $value) { + if (!$value->hasData('checkout_data')) { + continue; + } + $methodName = 'prepare' . ucfirst($value->getDataConfig()['type_id']) . 'Data'; + if (!method_exists($this, $methodName)) { + $methodName = 'prepareSimpleData'; + } + $result['item'][$value->getId()] = $this->$methodName($value); + } + return $result; + } + + /** + * Prepare data for configurable product. + * + * @param ConfigurableProduct $product + * @return array + */ + protected function prepareConfigurableData(ConfigurableProduct $product) + { + $result = []; + $checkoutData = $product->getCheckoutData(); + $result['qty'] = $checkoutData['qty']; + $attributesData = $product->hasData('configurable_attributes_data') + ? $product->getDataFieldConfig('configurable_attributes_data')['source']->getAttributesData() + : null; + if ($attributesData == null) { + return $result; + } + foreach ($checkoutData['options']['configurable_options'] as $option) { + $attributeId = $attributesData[$option['title']]['attribute_id']; + $optionId = $attributesData[$option['title']]['options'][$option['value']]['id']; + $result['super_attribute'][$attributeId] = $optionId; + } + + return $result; + } + + /** + * Prepare data for bundle product. + * + * @param BundleProduct $product + * @return array + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function prepareBundleData(BundleProduct $product) + { + $result = []; + $checkoutData = $product->getCheckoutData(); + $bundleOptions = isset($checkoutData['options']['bundle_options']) + ? $checkoutData['options']['bundle_options'] + : []; + $bundleSelections = $product->getBundleSelections(); + $bundleSelectionsData = []; + $result['qty'] = $checkoutData['qty']; + + foreach ($bundleSelections['bundle_options'] as $option) { + foreach ($option['assigned_products'] as $productData) { + $productName = $productData['search_data']['name']; + $bundleSelectionsData[$productName] = [ + 'selection_id' => $productData['selection_id'], + 'option_id' => $productData['option_id'], + ]; + } + } + + foreach ($bundleOptions as $option) { + $productName = $option['value']['name']; + foreach ($bundleSelectionsData as $fullProductName => $value) { + if (null !== strpos($fullProductName, $productName)) { + $productName = $fullProductName; + } + } + + if (isset($bundleSelectionsData[$productName])) { + $optionId = $bundleSelectionsData[$productName]['option_id']; + $selectionId = $bundleSelectionsData[$productName]['selection_id']; + $result['bundle_option'][$optionId] = $selectionId; + } + } + + return $result; + } + + /** + * Prepare data for downloadable product. + * + * @param DownloadableProduct $product + * @return array + */ + protected function prepareDownloadableData(DownloadableProduct $product) + { + $result = []; + $checkoutData = $product->getCheckoutData(); + foreach ($checkoutData['options']['links'] as $link) { + $result['links'][] = $link['id']; + } + + return $result; + } + + /** + * Prepare data for simple product. + * + * @param FixtureInterface $product + * @return array + */ + protected function prepareSimpleData(FixtureInterface $product) + { + return ['qty' => $product->getCheckoutData()['qty']]; + } + + /** + * Prepare order data. + * + * @param array $data + * @return array + */ + protected function prepareOrderData(array $data) + { + $customerGroupId = $this->customer->hasData('group_id') + ? $this->customer->getDataFieldConfig('group_id')['source']->getCustomerGroup()->getCustomerGroupId() + : 1; + $result = [ + 'name' => $this->customer->getFirstname(), + 'order' => [ + 'currency' => $data['order_currency_code'], + 'account' => [ + 'group_id' => $customerGroupId, + 'email' => $this->customer->getEmail(), + ], + 'shipping_method' => isset($data['shipping_method']) ? $data['shipping_method'] : '', + ], + 'item' => $this->prepareOrderProductsData($data['entity_id']), + 'billing_address' => $this->prepareBillingAddress($data['billing_address_id']), + 'shipping_same_as_billing' => 'on', + 'payment' => $data['payment_auth_expiration'], + + ]; + + return $result; + } + + /** + * Prepare customer data. + * + * @param array $data + * @return array + */ + protected function prepareCustomerData(array $data) + { + return [ + 'currency_id' => $data['base_currency_code'], + 'customer_id' => $this->customer->getData('id'), + 'payment' => $data['payment_authorization_amount'], + 'store_id' => $this->order->getDataFieldConfig('store_id')['source']->store->getStoreId() + ]; + } + + /** + * Prepare order products data. + * + * @param array $data + * @return array + */ + protected function prepareOrderProductsData(array $data) + { + $result = []; + foreach ($data['products'] as $value) { + if (isset($value->getCheckoutData()['qty'])) { + $result[$value->getId()] = ['qty' => ['qty' => $value->getCheckoutData()['qty']]]; + } + } + + return $result; + } + + /** + * Prepare billing address data. + * + * @param array $data + * @return array + */ + protected function prepareBillingAddress(array $data) + { + $result = $data; + $result['firstname'] = $this->customer->getFirstname(); + $result['lastname'] = $this->customer->getLastname(); + + return $result; + } + + /** + * Create product via curl. + * + * @param array $data + * @return int|null + * @throws \Exception + */ + protected function createOrder(array $data) + { + $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); + foreach ($this->steps as $key => $step) { + if (!isset($data[$key])) { + continue; + } + $url = $_ENV['app_backend_url'] . 'sales/order_create/loadBlock/block/' . $step . '?isAjax=true'; + $curl->write(CurlInterface::POST, $url, '1.1', [], $data[$key]); + $curl->read(); + } + $url = $_ENV['app_backend_url'] . 'sales/order_create/save'; + $curl->addOption(CURLOPT_HEADER, 1); + $curl->write(CurlInterface::POST, $url, '1.1', [], $data['order_data']); + $response = $curl->read(); + $curl->close(); + + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception("Order creation by curl handler was not successful! Response: $response"); + } + preg_match("~<h1 class=\"page-title\">#(.*)</h1>~", $response, $matches); + + return isset($matches[1]) ? $matches[1] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/OrderInjectableInterface.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/OrderInjectableInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..e08ecf55e8570d79b4ea4b06e403089e7130bd38 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderInjectable/OrderInjectableInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Handler\OrderInjectable; + +use Magento\Mtf\Handler\HandlerInterface; + +/** + * Interface OrderInjectableInterface + */ +interface OrderInjectableInterface extends HandlerInterface +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/Curl.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..1ff9f0d8de366f274313dff361ab2b728bfac8de --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/Curl.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Handler\OrderStatus; + +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Handler\Curl as AbstractCurl; +use Magento\Mtf\Util\Protocol\CurlInterface; +use Magento\Mtf\Util\Protocol\CurlTransport; +use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; + +/** + * Curl handler for creating OrderStatus. + */ +class Curl extends AbstractCurl implements OrderStatusInterface +{ + /** + * Default attribute values for fixture. + * + * @var array + */ + protected $defaultAttributeValues = [ + 'is_new' => 1, + 'store_labels[1]' => '', + ]; + + /** + * Mapping values for data. + * + * @var array + */ + protected $mappingData = [ + 'state' => [ + 'Pending' => 'new', + ], + 'is_default' => [ + 'Yes' => 1, + 'No' => 0, + ], + 'visible_on_front' => [ + 'Yes' => 1, + 'No' => 0, + ], + ]; + + /** + * Post request for creating OrderStatus. + * + * @param FixtureInterface $fixture + * @return void + * @throws \Exception + */ + public function persist(FixtureInterface $fixture = null) + { + $url = $_ENV['app_backend_url'] . 'sales/order_status/save/'; + $data = array_merge($this->defaultAttributeValues, $fixture->getData()); + $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); + $curl->write(CurlInterface::POST, $url, '1.1', [], $data); + $response = $curl->read(); + $curl->close(); + + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception("OrderStatus entity creating by curl handler was not successful! Response: $response"); + } + + if (isset($data['state'])) { + $url = $_ENV['app_backend_url'] . 'sales/order_status/assignPost/'; + $data = $this->replaceMappingData($data); + $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); + $curl->write(CurlInterface::POST, $url, '1.1', [], $data); + $response = $curl->read(); + $curl->close(); + + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception( + "Assigning OrderStatus entity by curl handler was not successful! Response: $response" + ); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/OrderStatusInterface.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/OrderStatusInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..8bdff4f5546f34f6eca1d29afeafe7eb7b655fbe --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Handler/OrderStatus/OrderStatusInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Handler\OrderStatus; + +use Magento\Mtf\Handler\HandlerInterface; + +/** + * Interface OrderStatusInterface + */ +interface OrderStatusInterface extends HandlerInterface +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable.xml new file mode 100644 index 0000000000000000000000000000000000000000..e0ac81201f8b3b611057687c771d69964ca835fd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable.xml @@ -0,0 +1,235 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\Sales\Test\Repository\OrderInjectable"> + <dataset name="default"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="two_simple_product"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default,catalogProductSimple::default</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="virtual_product"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductVirtual::default</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="downloadable_product"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">downloadableProduct::with_two_bought_links</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="two_downloadable_product"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">downloadableProduct::with_two_bought_links, downloadableProduct::with_two_bought_links</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="with_coupon"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + <field name="coupon_code" xsi:type="array"> + <item name="dataSet" xsi:type="string">active_sales_rule_for_all_groups</item> + </field> + <field name="price" xsi:type="array"> + <item name="preset" xsi:type="string">default_with_discount</item> + </field> + </dataset> + + <dataset name="with_coupon"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::default</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + <field name="coupon_code" xsi:type="array"> + <item name="dataSet" xsi:type="string">active_sales_rule_for_all_groups</item> + </field> + <field name="price" xsi:type="array"> + <item name="preset" xsi:type="string">default_with_discount</item> + </field> + </dataset> + + <dataset name="simple_big_qty"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::simple_big_qty</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">johndoe_unique</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + + <dataset name="virtual_big_qty"> + <field name="entity_id" xsi:type="array"> + <item name="products" xsi:type="string">catalogProductSimple::virtual_big_qty</item> + </field> + <field name="customer_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">johndoe_unique</item> + </field> + <field name="billing_address_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">US_address</item> + </field> + <field name="store_id" xsi:type="array"> + <item name="dataSet" xsi:type="string">default_store_view</item> + </field> + <field name="shipping_method" xsi:type="string">flatrate_flatrate</field> + <field name="payment_auth_expiration" xsi:type="array"> + <item name="method" xsi:type="string">checkmo</item> + </field> + <field name="payment_authorization_amount" xsi:type="array"> + <item name="method" xsi:type="string">free</item> + </field> + <field name="base_currency_code" xsi:type="string">0</field> + <field name="order_currency_code" xsi:type="string">USD</field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderStatus.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderStatus.xml new file mode 100644 index 0000000000000000000000000000000000000000..9391fbb88435c4005376699cb3081ac07675e6c6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderStatus.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\Sales\Test\Repository\OrderStatus"> + <dataset name="default"> + <field name="status" xsi:type="string">order_status%isolation%</field> + <field name="label" xsi:type="string">orderLabel%isolation%</field> + </dataset> + + <dataset name="assign_to_pending"> + <field name="status" xsi:type="string">order_status%isolation%</field> + <field name="label" xsi:type="string">orderLabel%isolation%</field> + <field name="state" xsi:type="string">Pending</field> + <field name="is_default" xsi:type="string">Yes</field> + <field name="visible_on_front" xsi:type="string">Yes</field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..148ccff6b0733ec95672421561ba0b04eab3525f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.php @@ -0,0 +1,167 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Constraint\AssertOrderStatusSuccessAssignMessage; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Fixture\OrderStatus; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusAssign; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusIndex; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Custom Order Status is created. + * + * Steps: + * 1. Log in as admin. + * 2. Navigate to the Stores > Settings > Order Status. + * 3. Click on "Assign Status to State. + * 4. Fill in all data according to data set. + * 5. Save Status Assignment. + * 6. Call assert assertOrderStatusSuccessAssignMessage. + * 7. Create Order. + * 8. Perform all assertions from dataSet. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29382 + */ +class AssignCustomOrderStatusTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Order Status Index page. + * + * @var OrderStatusIndex + */ + protected $orderStatusIndex; + + /** + * Order Status Assign page. + * + * @var OrderStatusAssign + */ + protected $orderStatusAssign; + + /** + * Order Index page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * OrderStatus Fixture. + * + * @var OrderStatus + */ + protected $orderStatus; + + /** + * OrderInjectable Fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Prepare data. + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Inject pages. + * + * @param OrderStatusIndex $orderStatusIndex + * @param OrderStatusAssign $orderStatusAssign + * @param OrderIndex $orderIndex + * @return void + */ + public function __inject( + OrderStatusIndex $orderStatusIndex, + OrderStatusAssign $orderStatusAssign, + OrderIndex $orderIndex + ) { + $this->orderStatusIndex = $orderStatusIndex; + $this->orderStatusAssign = $orderStatusAssign; + $this->orderIndex = $orderIndex; + } + + /** + * Run Assign Custom OrderStatus. + * + * @param OrderStatus $orderStatus + * @param OrderInjectable $order + * @param array $orderStatusState + * @param AssertOrderStatusSuccessAssignMessage $assertion + * @return array + */ + public function test( + OrderStatus $orderStatus, + OrderInjectable $order, + array $orderStatusState, + AssertOrderStatusSuccessAssignMessage $assertion + ) { + // Preconditions: + $orderStatus->persist(); + /** @var OrderStatus $orderStatus */ + $orderStatus = $this->fixtureFactory->createByCode( + 'orderStatus', + ['data' => array_merge($orderStatus->getData(), $orderStatusState)] + ); + + // Steps: + $this->orderStatusIndex->open(); + $this->orderStatusIndex->getGridPageActions()->assignStatusToState(); + $this->orderStatusAssign->getAssignForm()->fill($orderStatus); + $this->orderStatusAssign->getPageActionsBlock()->save(); + $assertion->processAssert($this->orderStatusIndex); + + $order->persist(); + + // Prepare data for tear down + $this->orderStatus = $orderStatus; + $this->order = $order; + + return [ + 'orderId' => $order->getId(), + 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer(), + 'status' => $orderStatus->getLabel() + ]; + } + + /** + * Change created order status and unassign custom order status + * + * @return void + */ + public function tearDown() + { + $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel'); + $filter = ['label' => $this->orderStatus->getLabel()]; + $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..295a0103799502586f3c49783973c38eb5cc6983 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/AssignCustomOrderStatusTest.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\AssignCustomOrderStatusTest"> + <variation name="AssignCustomOrderStatusTestVariation1"> + <data name="orderStatusState/state" xsi:type="string">Pending</data> + <data name="orderStatusState/is_default" xsi:type="string">No</data> + <data name="orderStatusState/visible_on_front" xsi:type="string">Yes</data> + <data name="statusToCheck" xsi:type="string">Pending</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="AssignCustomOrderStatusTestVariation2"> + <data name="orderStatusState/state" xsi:type="string">Pending</data> + <data name="orderStatusState/is_default" xsi:type="string">Yes</data> + <data name="orderStatusState/visible_on_front" xsi:type="string">No</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderNotVisibleOnMyAccount" /> + </variation> + <variation name="AssignCustomOrderStatusTestVariation3"> + <data name="orderStatusState/state" xsi:type="string">Pending</data> + <data name="orderStatusState/is_default" xsi:type="string">Yes</data> + <data name="orderStatusState/visible_on_front" xsi:type="string">Yes</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ae747237cf2f89bac2cd70a58fa4609e2d55da77 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Enable payment method "Check/Money Order". + * 2. Enable shipping method one of "Flat Rate". + * 3. Create order + * + * Steps: + * 1. Login to backend. + * 2. Sales > Orders. + * 3. Open the created order. + * 4. Do cancel Order. + * 5. Perform all assetions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28191 + */ +class CancelCreatedOrderTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * Enable "Check/Money Order" and "Flat Rate" in configuration. + * + * @return void + */ + public function __prepare() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'checkmo, flatrate', 'rollback' => true] + )->run(); + } + + /** + * Inject pages + * + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @return void + */ + public function __inject(OrderIndex $orderIndex, SalesOrderView $salesOrderView) + { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + } + + /** + * Cancel created order. + * + * @param OrderInjectable $order + * @return array + */ + public function test(OrderInjectable $order) + { + // Preconditions + $order->persist(); + + // Steps + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + $this->salesOrderView->getPageActions()->cancel(); + + return [ + 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer(), + ]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..b5c195908cc8140a1b75fd84fc4c8f55549123c0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CancelCreatedOrderTest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CancelCreatedOrderTest"> + <variation name="CancelCreatedOrderTestVariation1"> + <data name="description" xsi:type="string">cancel order and check status on the frontend</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default,catalogProductSimple::default</data> + <data name="status" xsi:type="string">Canceled</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f54fc41993282a7ae85effedd6b33161aa14df37 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.php @@ -0,0 +1,126 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Enable payment method "Check/Money Order". + * 2. Enable shipping method one of "Flat Rate/Free Shipping". + * 3. Create order. + * 4. Create Invoice. + * + * Steps: + * 1. Go to Sales > Orders > find out placed order and open. + * 2. Click 'Credit Memo' button. + * 3. Fill data from dataSet. + * 4. On order's page click 'Refund offline' button. + * 5. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29116 + */ +class CreateCreditMemoEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const STABLE = 'no'; // Backend customer form load + /* end tags */ + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Skip fields for create product fixture. + * + * @var array + */ + protected $skipFields = [ + 'attribute_set_id', + 'website_ids', + 'checkout_data', + 'type_id', + 'price', + ]; + + /** + * Set up configuration. + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->fixtureFactory = $fixtureFactory; + + $setupConfigurationStep = $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'checkmo, flatrate'] + ); + $setupConfigurationStep->run(); + } + + /** + * Create credit memo. + * + * @param OrderInjectable $order + * @param array $data + * @return array + */ + public function test(OrderInjectable $order, array $data) + { + // Preconditions + $order->persist(); + $this->objectManager->create('Magento\Sales\Test\TestStep\CreateInvoiceStep', ['order' => $order])->run(); + + // Steps + $createCreditMemoStep = $this->objectManager->create( + 'Magento\Sales\Test\TestStep\CreateCreditMemoStep', + ['order' => $order, 'data' => $data] + ); + $result = $createCreditMemoStep->run(); + + return [ + 'ids' => ['creditMemoIds' => $result['creditMemoIds']], + 'product' => $this->getProduct($order, $data), + 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer() + ]; + } + + /** + * Get product's fixture. + * + * @param OrderInjectable $order + * @param array $data + * @param int $index [optional] + * @return FixtureInterface + */ + protected function getProduct(OrderInjectable $order, array $data, $index = 0) + { + if (!isset($data['items_data'][$index]['back_to_stock']) + || $data['items_data'][$index]['back_to_stock'] != 'Yes' + ) { + return $order->getEntityId()['products'][$index]; + } + $product = $order->getEntityId()['products'][$index]; + $productData = $product->getData(); + $checkoutDataQty = $productData['checkout_data']['qty']; + $productData['quantity_and_stock_status']['qty'] -= ($checkoutDataQty - $data['items_data'][$index]['qty']); + $productData = array_diff_key($productData, array_flip($this->skipFields)); + + return $this->fixtureFactory->create(get_class($product), ['data' => $productData]); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..1d730f56e5bbcc70863d71c20ca7f9ddc99b4d7c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCreditMemoEntityTest.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CreateCreditMemoEntityTest"> + <variation name="CreateCreditMemoEntityTestVariation1"> + <data name="description" xsi:type="string">Assert items return to stock (partial refund)</data> + <data name="data/items_data/0/back_to_stock" xsi:type="string">Yes</data> + <data name="data/items_data/0/qty" xsi:type="string">1</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::product_100_dollar</data> + <data name="order/data/price/preset" xsi:type="string">partial_refund</data> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoButton" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInRefundsGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundedGrandTotalOnFrontend" /> + <constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoItems" /> + </variation> + <variation name="CreateCreditMemoEntityTestVariation2"> + <data name="description" xsi:type="string">Assert 0 shipping refund</data> + <data name="data/items_data/0/qty" xsi:type="string">1</data> + <data name="data/form_data/shipping_amount" xsi:type="string">0</data> + <data name="data/form_data/adjustment_positive" xsi:type="string">5</data> + <data name="data/form_data/adjustment_negative" xsi:type="string">10</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default</data> + <data name="order/data/price/preset" xsi:type="string">full_refund_with_zero_shipping_refund</data> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoButton" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInRefundsGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundedGrandTotalOnFrontend" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCreditMemoItems" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a16471097cef29fc08be51ec17988b56d724c5a9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderStatus; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusNew; +use Magento\Mtf\TestCase\Injectable; + +/** + * Steps: + * 1. Log in as admin. + * 2. Navigate to the Stores > Settings > Order Status. + * 3. Click on "Create New Status" button. + * 4. Fill in all data according to data set. + * 5. Save order status. + * 6. Verify created order status. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-23412 + */ +class CreateCustomOrderStatusEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Order staus page. + * + * @var OrderStatusIndex + */ + protected $orderStatusIndexPage; + + /** + * Create order status page. + * + * @var OrderStatusNew + */ + protected $orderStatusNewPage; + + /** + * Inject pages. + * + * @param OrderStatusIndex $orderStatusIndexPage + * @param OrderStatusNew $orderStatusNewPage + * @return void + */ + public function __inject( + OrderStatusIndex $orderStatusIndexPage, + OrderStatusNew $orderStatusNewPage + ) { + $this->orderStatusIndexPage = $orderStatusIndexPage; + $this->orderStatusNewPage = $orderStatusNewPage; + } + + /** + * Run Create Order Status test. + * + * @param OrderStatus $orderStatus + * @return void + */ + public function testCreateOrderStatus(OrderStatus $orderStatus) + { + // Steps + $this->orderStatusIndexPage->open(); + $this->orderStatusIndexPage->getGridPageActions()->addNew(); + $this->orderStatusNewPage->getOrderStatusForm()->fill($orderStatus); + $this->orderStatusNewPage->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..2de5caa7940d118fdcb2e9d83811f32f4a675ec5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CreateCustomOrderStatusEntityTest"> + <variation name="CreateCustomOrderStatusEntityTestVariation1"> + <data name="orderStatus/data/status" xsi:type="string">order_status%isolation%</data> + <data name="orderStatus/data/label" xsi:type="string">orderLabel%isolation%</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + </variation> + <variation name="CreateCustomOrderStatusEntityTestVariation2"> + <data name="orderStatus/data/status" xsi:type="string">pending</data> + <data name="orderStatus/data/label" xsi:type="string">orderLabel%isolation%</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusDuplicateStatus" /> + </variation> + <variation name="CreateCustomOrderStatusEntityTestVariation3"> + <data name="orderStatus/data/status" xsi:type="string">order_status%isolation%</data> + <data name="orderStatus/data/label" xsi:type="string">Processing</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c490060364c978df658f645025826b5f2335f0f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Enable payment method "Check/Money Order". + * 2. Enable shipping method one of "Flat Rate/Free Shipping". + * 3. Create order. + * + * Steps: + * 1. Go to Sales > Orders. + * 2. Select created order in the grid and open it. + * 3. Click 'Invoice' button. + * 4. Fill data according to dataSet. + * 5. Click 'Submit Invoice' button. + * 6. Perform assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28209 + */ +class CreateInvoiceEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Set up configuration. + * + * @return void + */ + public function __prepare() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'checkmo, flatrate'] + )->run(); + } + + /** + * Create invoice. + * + * @param OrderInjectable $order + * @param array $data + * @return array + */ + public function test(OrderInjectable $order, array $data) + { + // Preconditions + $order->persist(); + + // Steps + $result = $this->objectManager->create( + 'Magento\Sales\Test\TestStep\CreateInvoiceStep', + ['order' => $order, 'data' => $data] + )->run(); + + return [ + 'ids' => [ + 'invoiceIds' => $result['invoiceIds'], + 'shipmentIds' => isset($result['shipmentIds']) ? $result['shipmentIds'] : null, + ] + ]; + } + + /** + * Log out. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create('Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep')->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..43b018bc8b8c2d6a7f689c61dd5e96aa9761aac1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateInvoiceEntityTest.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CreateInvoiceEntityTest"> + <variation name="CreateInvoiceEntityTestVariation1"> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/price/preset" xsi:type="string">full_invoice</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default</data> + <data name="order/data/total_qty_ordered/0" xsi:type="string">1</data> + <data name="data/items_data/0/qty" xsi:type="string">-</data> + <data name="data/form_data/do_shipment" xsi:type="string">Yes</data> + <data name="data/form_data/comment_text" xsi:type="string">comments</data> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceWithShipmentSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertNoInvoiceButton" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoicedAmountOnFrontend" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertNoShipButton" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentInShipmentsTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + </variation> + <variation name="CreateInvoiceEntityTestVariation2"> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/price/preset" xsi:type="string">partial_invoice</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::product_100_dollar</data> + <data name="order/data/total_qty_ordered/0" xsi:type="string">-</data> + <data name="data/items_data/0/qty" xsi:type="string">1</data> + <data name="data/form_data/do_shipment" xsi:type="string">No</data> + <data name="data/form_data/comment_text" xsi:type="string">comments</data> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoicedAmountOnFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php new file mode 100644 index 0000000000000000000000000000000000000000..67700cfedc82feb577c88a8b86f66ffd30bac571 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create product. + * + * Steps: + * 1. Open Backend. + * 2. Open Sales -> Orders. + * 3. Click Create New Order. + * 4. Select Customer created in preconditions. + * 5. Add Product. + * 6. Fill data according dataSet. + * 7. Click Update Product qty. + * 8. Fill data according dataSet. + * 9. Click Get Shipping Method and rates. + * 10. Fill data according dataSet. + * 11. Submit Order. + * 12. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28696 + */ +class CreateOrderBackendTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TEST_TYPE = 'acceptance_test'; + /* end tags */ + + /** + * Runs sales order on backend. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } + + /** + * Disable enabled config after test. + * + * @return void + */ + public function tearDown() + { + if (isset($this->currentVariation['arguments']['configData'])) { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->currentVariation['arguments']['configData'], 'rollback' => true] + )->run(); + } + $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->objectManager->create('Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..c8328baab4af1305a8f77e86a412dc67fdc3f4ba --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CreateOrderBackendTest"> + <variation name="CreateOrderBackendTestVariation1"> + <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Cash on Delivery payment method</data> + <data name="products" xsi:type="string">catalogProductSimple::default</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="saveAddress" xsi:type="string">No</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">565.00</item> + </data> + <data name="payment/method" xsi:type="string">cashondelivery</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Reorder, Cancel, Send Notification, Hold, Invoice, Ship, Edit</data> + <data name="configData" xsi:type="string">cashondelivery</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="CreateOrderBackendTestVariation2"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36210</data> + <data name="description" xsi:type="string">Create order with virtual product for registered UK customer using Check/Money Order payment method</data> + <data name="products" xsi:type="string">catalogProductVirtual::default</data> + <data name="customer/dataSet" xsi:type="string">customer_UK</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">10.00</item> + </data> + <data name="payment/method" xsi:type="string">checkmo</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Notification, Hold, Invoice, Edit</data> + <data name="configData" xsi:type="string">checkmo_specificcountry_gb</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="CreateOrderBackendTestVariation3"> + <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Bank Transfer payment method</data> + <data name="products" xsi:type="string">catalogProductSimple::default</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="saveAddress" xsi:type="string">No</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">565.00</item> + </data> + <data name="payment/method" xsi:type="string">banktransfer</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Notification, Hold, Reorder, Invoice, Edit</data> + <data name="configData" xsi:type="string">banktransfer</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="CreateOrderBackendTestVariation4"> + <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="description" xsi:type="string">Create order with virtual product for registered UK customer using Bank Transfer payment method</data> + <data name="products" xsi:type="string">catalogProductVirtual::default</data> + <data name="customer/dataSet" xsi:type="string">customer_UK</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_UK</data> + <data name="saveAddress" xsi:type="string">No</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">10.00</item> + </data> + <data name="payment/method" xsi:type="string">banktransfer</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Notification, Hold, Invoice, Edit</data> + <data name="configData" xsi:type="string">freeshipping_specificcountry_gb, banktransfer</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="CreateOrderBackendTestVariation5"> + <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="description" xsi:type="string">Create order with simple product for registered US customer using Fixed shipping method and Purchase Order payment method</data> + <data name="products" xsi:type="string">catalogProductSimple::default</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="saveAddress" xsi:type="string">No</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">565.00</item> + </data> + <data name="payment/method" xsi:type="string">purchaseorder</data> + <data name="payment/po_number" xsi:type="string">123456</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Cancel, Send Notification, Hold, Invoice, Reorder, Edit</data> + <data name="configData" xsi:type="string">purchaseorder</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + <variation name="CreateOrderBackendTestVariation6"> + <data name="description" xsi:type="string">MAGETWO-12395 - Create Offline Order for Registered Customer in Admin</data> + <data name="products" xsi:type="string">catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="saveAddress" xsi:type="string">No</data> + <data name="checkoutMethod" xsi:type="string">login</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">32.73</item> + </data> + <data name="payment/method" xsi:type="string">checkmo</data> + <data name="tag" xsi:type="string">test_type:acceptance_test</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + </variation> + <variation name="CreateOrderBackendTestVariation7"> + <data name="description" xsi:type="string">MAGETWO-12520 - Create Order for New Customer in Admin with Offline Payment Method</data> + <data name="products" xsi:type="string">catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option</data> + <data name="taxRule" xsi:type="string">us_ca_ny_rule</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="saveAddress" xsi:type="string">Yes</data> + <data name="checkoutMethod" xsi:type="string">register</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">32.73</item> + </data> + <data name="payment/method" xsi:type="string">checkmo</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, to_maintain:yes</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Customer\Test\Constraint\AssertCustomerForm" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c0c57982c726f90a33f1d94b028b2a040bded26a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Enable payment method "Check/Money Order". + * 2. Enable shipping method one of "Flat Rate". + * 3. Create order. + * + * Steps: + * 1. Login to backend. + * 2. Go to Sales > Orders. + * 3. Open the created order. + * 4. Do 'Hold' for Order. + * 5. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28214 + */ +class HoldCreatedOrderTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * Enable "Check/Money Order" and "Flat Rate" in configuration. + * + * @return void + */ + public function __prepare() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => 'checkmo, flatrate', 'rollback' => true] + )->run(); + } + + /** + * Inject pages. + * + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @return void + */ + public function __inject(OrderIndex $orderIndex, SalesOrderView $salesOrderView) + { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + } + + /** + * Put created order on hold. + * + * @param OrderInjectable $order + * @return array + */ + public function test(OrderInjectable $order) + { + // Preconditions + $order->persist(); + + // Steps + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); + $this->salesOrderView->getPageActions()->hold(); + + return [ + 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer(), + ]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..962f0262f34f2714a8bc06325a8926069115d57e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/HoldCreatedOrderTest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\HoldCreatedOrderTest"> + <variation name="HoldCreatedOrderTestVariation1"> + <data name="description" xsi:type="string">hold order and check status on the front in my account</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default,catalogProductSimple::default</data> + <data name="orderButtonsUnavailable" xsi:type="string">Invoice,Cancel,Reorder,Ship,Edit</data> + <data name="status" xsi:type="string">On Hold</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderOnHoldSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsUnavailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertUnholdButton" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..264f392cf0123e8e85c8579d9593506bab5bb04d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.php @@ -0,0 +1,140 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestCase\Injectable; + +/** + * Precondition: + * 1. Create orders. + * + * Steps: + * 1. Navigate to backend. + * 2. Go to Sales > Orders. + * 3. Select Mass Action according to dataSet. + * 4. Submit. + * 5. Perform Asserts. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-27897 + */ +class MassOrdersUpdateTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Order index page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Fixture factory. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Injection data. + * + * @param OrderIndex $orderIndex + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __inject(OrderIndex $orderIndex, FixtureFactory $fixtureFactory) + { + $this->orderIndex = $orderIndex; + $this->fixtureFactory = $fixtureFactory; + } + + /** + * Mass orders update. + * + * @param string $steps + * @param int $ordersCount + * @param string $action + * @param string $resultStatuses + * @return array + */ + public function test($steps, $ordersCount, $action, $resultStatuses) + { + // Preconditions + $orders = $this->createOrders($ordersCount, $steps); + $items = $this->prepareFilter($orders); + + // Steps + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->massaction($items, $action); + + return ['orders' => $orders, 'orderStatuses' => explode(',', $resultStatuses)]; + } + + /** + * Create orders. + * + * @param int $count + * @param string $steps + * @return array + */ + protected function createOrders($count, $steps) + { + $orders = []; + $steps = explode('|', $steps); + for ($i = 0; $i < $count; $i++) { + /** @var OrderInjectable $order */ + $order = $this->fixtureFactory->createByCode('orderInjectable', ['dataSet' => 'default']); + $order->persist(); + $orders[$i] = $order; + $this->processSteps($order, $steps[$i]); + } + + return $orders; + } + + /** + * Process which step to take for order. + * + * @param OrderInjectable $order + * @param string $steps + * @return void + */ + protected function processSteps(OrderInjectable $order, $steps) + { + $steps = array_diff(explode(',', $steps), ['-']); + foreach ($steps as $step) { + $action = str_replace(' ', '', ucwords($step)); + $methodAction = (($action != 'OnHold') ? 'Create' : '') . $action . 'Step'; + $path = 'Magento\Sales\Test\TestStep'; + $processStep = $this->objectManager->create($path . '\\' . $methodAction, ['order' => $order]); + $processStep->run(); + } + } + + /** + * Prepare filter. + * + * @param OrderInjectable[] $orders + * @return array + */ + protected function prepareFilter(array $orders) + { + $items = []; + foreach ($orders as $order) { + $items[] = ['id' => $order->getId()]; + } + + return $items; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..c9c529d4ae07bebf8cf83fa3fb22575c2509fd47 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MassOrdersUpdateTest.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MassOrdersUpdateTest"> + <variation name="MassOrdersUpdateTestVariation1"> + <data name="description" xsi:type="string">cancel orders in status Pending and Processing</data> + <data name="steps" xsi:type="string">-</data> + <data name="action" xsi:type="string">Cancel</data> + <data name="ordersCount" xsi:type="string">1</data> + <data name="resultStatuses" xsi:type="string">Canceled</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation2"> + <data name="description" xsi:type="string">try to cancel orders in status Complete, Closed</data> + <data name="steps" xsi:type="string">invoice, shipment|invoice, credit memo</data> + <data name="action" xsi:type="string">Cancel</data> + <data name="ordersCount" xsi:type="string">2</data> + <data name="resultStatuses" xsi:type="string">Complete,Closed</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionFailMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation3"> + <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="description" xsi:type="string">try to cancel orders in status Pending, Closed</data> + <data name="steps" xsi:type="string">invoice|invoice, credit memo</data> + <data name="action" xsi:type="string">Cancel</data> + <data name="ordersCount" xsi:type="string">2</data> + <data name="resultStatuses" xsi:type="string">Processing,Closed</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelMassActionFailMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation4"> + <data name="description" xsi:type="string">Put orders in statuses Pending, Processing on Hold</data> + <data name="steps" xsi:type="string">-|invoice</data> + <data name="action" xsi:type="string">Hold</data> + <data name="ordersCount" xsi:type="string">2</data> + <data name="resultStatuses" xsi:type="string">On Hold,On Hold</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderOnHoldSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation5"> + <data name="description" xsi:type="string">Try to put order in statuse Complete on Hold</data> + <data name="steps" xsi:type="string">invoice, shipment</data> + <data name="action" xsi:type="string">Hold</data> + <data name="ordersCount" xsi:type="string">1</data> + <data name="resultStatuses" xsi:type="string">Complete</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderOnHoldFailMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation6"> + <data name="description" xsi:type="string">Release order in statuse On Hold</data> + <data name="steps" xsi:type="string">on hold</data> + <data name="action" xsi:type="string">Unhold</data> + <data name="ordersCount" xsi:type="string">1</data> + <data name="resultStatuses" xsi:type="string">Pending</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderReleaseSuccessMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + <variation name="MassOrdersUpdateTestVariation7"> + <data name="description" xsi:type="string">try to Release order in status Pending</data> + <data name="steps" xsi:type="string">-</data> + <data name="action" xsi:type="string">Unhold</data> + <data name="ordersCount" xsi:type="string">1</data> + <data name="resultStatuses" xsi:type="string">Pending</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderReleaseFailMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrdersInOrdersGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4a66d441d4fc9221cf5b1d0f349f1b6af332d518 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create product. + * 3. Create order with this product. + * + * Steps: + * 1. Open Customers > All Customers. + * 2. Search and open customer from preconditions. + * 3. Click Create Order. + * 4. Check product in Last Ordered Items section. + * 5. Click Update Changes. + * 6. Perform all assertions. + * + * @group Customers_(CS), Order_Management_(CS) + * @ZephyrId MAGETWO-27640 + */ +class MoveLastOrderedProductsOnOrderPageTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Order create index page. + * + * @var OrderCreateIndex + */ + protected $orderCreateIndex; + + /** + * Customer index page. + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer index edit page. + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Inject pages. + * + * @param OrderCreateIndex $orderCreateIndex + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @return void + */ + public function __inject( + OrderCreateIndex $orderCreateIndex, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit + ) { + $this->orderCreateIndex = $orderCreateIndex; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + } + + /** + * Move last ordered products on order page. + * + * @param OrderInjectable $order + * @return array + */ + public function test(OrderInjectable $order) + { + // Preconditions: + $order->persist(); + $customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer(); + + // Steps: + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getPageActionsBlock()->createOrder(); + $this->orderCreateIndex->getStoreBlock()->selectStoreView(); + $products = $order->getEntityId()['products']; + $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); + $activitiesBlock->getLastOrderedItemsBlock()->addProductsToOrder($products); + $activitiesBlock->updateChanges(); + + return ['products' => $products]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..db32b31002732a1c3df2362d9af163e1c64e0321 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MoveLastOrderedProductsOnOrderPageTest"> + <variation name="MoveLastOrderedProductsOnOrderPageTestVariation1"> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + <variation name="MoveLastOrderedProductsOnOrderPageTestVariation2"> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">configurableProduct::default</data> + <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..65eb1855623eea37ff73dfa9fd3a4647423dec7c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.php @@ -0,0 +1,171 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Catalog\Test\Page\Product\CatalogProductCompare; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create products. + * 3. Add products to compare list. + * + * Steps: + * 1. Open Customers -> All Customers. + * 2. Search and open customer from preconditions. + * 3. Click 'Create Order'. + * 4. Check product in comparison list section. + * 5. Click 'Update Changes'. + * 6. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28050 + */ +class MoveProductsInComparedOnOrderPageTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Cms index page. + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Browser instance. + * + * @var BrowserInterface + */ + protected $browser; + + /** + * Catalog product page. + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Order create index page. + * + * @var OrderCreateIndex + */ + protected $orderCreateIndex; + + /** + * Customer index page. + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer index edit page. + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Catalog product compare page. + * + * @var CatalogProductCompare + */ + protected $catalogProductCompare; + + /** + * Create customer. + * + * @param Customer $customer + * @param BrowserInterface $browser + * @return array + */ + public function __prepare(Customer $customer, BrowserInterface $browser) + { + $customer->persist(); + $this->browser = $browser; + + return ['customer' => $customer]; + } + + /** + * Inject pages. + * + * @param CmsIndex $cmsIndex + * @param CatalogProductView $catalogProductView + * @param OrderCreateIndex $orderCreateIndex + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @param CatalogProductCompare $catalogProductCompare + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CatalogProductView $catalogProductView, + OrderCreateIndex $orderCreateIndex, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit, + CatalogProductCompare $catalogProductCompare + ) { + $this->cmsIndex = $cmsIndex; + $this->catalogProductView = $catalogProductView; + $this->orderCreateIndex = $orderCreateIndex; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + $this->catalogProductCompare = $catalogProductCompare; + } + + /** + * Move compare products on order page. + * + * @param Customer $customer + * @param string $products + * @return array + */ + public function test(Customer $customer, $products) + { + // Preconditions + // Create products + $products = $this->objectManager->create( + '\Magento\Catalog\Test\TestStep\CreateProductsStep', + ['products' => $products] + )->run()['products']; + // Login under customer + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $customer] + )->run(); + // Add products to compare + foreach ($products as $itemProduct) { + $this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->clickAddToCompare(); + } + + // Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getPageActionsBlock()->createOrder(); + $this->orderCreateIndex->getStoreBlock()->selectStoreView(); + $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); + $activitiesBlock->getProductsInComparisonBlock()->addProductsToOrder($products); + $activitiesBlock->updateChanges(); + + return ['products' => $products, 'productsIsConfigured' => false]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..28946b2dfd52d04182904397f556dfeae39e71df --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MoveProductsInComparedOnOrderPageTest"> + <variation name="MoveProductsInComparedOnOrderPageTestVariation1"> + <data name="products" xsi:type="string">catalogProductSimple::default,catalogProductSimple::default</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + <variation name="MoveProductsInComparedOnOrderPageTestVariation2"> + <data name="tag" xsi:type="string">to_maintain:yes</data> + <data name="products" xsi:type="string">configurableProduct::default,configurableProduct::default</data> + <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fa3bf369cad5c5e0a9a47303538f760912cdf2fe --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.php @@ -0,0 +1,173 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Catalog\Test\Page\Product\CatalogProductCompare; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create products. + * 3. Add products to compare list. + * 4. Clear compare list. + * + * Steps: + * 1. Open Customers > All Customers. + * 2. Search and open customer from preconditions. + * 3. Click 'Create Order'. + * 4. Check product in 'Recently compared List' section. + * 5. Click 'Update Changes'. + * 6. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28109 + */ +class MoveRecentlyComparedProductsOnOrderPageTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Cms index page. + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Browser instance. + * + * @var BrowserInterface + */ + protected $browser; + + /** + * Catalog product page. + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Order create index page. + * + * @var OrderCreateIndex + */ + protected $orderCreateIndex; + + /** + * Customer index page. + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer index edit page. + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Catalog product compare page. + * + * @var CatalogProductCompare + */ + protected $catalogProductCompare; + + /** + * Create customer. + * + * @param Customer $customer + * @param BrowserInterface $browser + * @return array + */ + public function __prepare(Customer $customer, BrowserInterface $browser) + { + $customer->persist(); + $this->browser = $browser; + + return ['customer' => $customer]; + } + + /** + * Inject pages. + * + * @param CmsIndex $cmsIndex + * @param CatalogProductView $catalogProductView + * @param OrderCreateIndex $orderCreateIndex + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @param CatalogProductCompare $catalogProductCompare + * @return void + */ + public function __inject( + CmsIndex $cmsIndex, + CatalogProductView $catalogProductView, + OrderCreateIndex $orderCreateIndex, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit, + CatalogProductCompare $catalogProductCompare + ) { + $this->cmsIndex = $cmsIndex; + $this->catalogProductView = $catalogProductView; + $this->orderCreateIndex = $orderCreateIndex; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + $this->catalogProductCompare = $catalogProductCompare; + } + + /** + * Move recently compared products on order page. + * + * @param Customer $customer + * @param string $products + * @return array + */ + public function test(Customer $customer, $products) + { + // Preconditions + // Create product + $products = $this->objectManager->create( + '\Magento\Catalog\Test\TestStep\CreateProductsStep', + ['products' => $products] + )->run()['products']; + // Login under customer + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $customer] + )->run(); + foreach ($products as $itemProduct) { + $this->browser->open($_ENV['app_frontend_url'] . $itemProduct->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->clickAddToCompare(); + } + $this->cmsIndex->getLinksBlock()->openLink("Compare Products"); + $this->catalogProductCompare->getCompareProductsBlock()->removeAllProducts(); + + // Steps: + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getPageActionsBlock()->createOrder(); + $this->orderCreateIndex->getStoreBlock()->selectStoreView(); + $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); + $activitiesBlock->getRecentlyComparedProductsBlock()->addProductsToOrder($products); + $activitiesBlock->updateChanges(); + + return ['products' => $products, 'productsIsConfigured' => false]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..c392c0ed4648acf34955412584f8679b15bb700e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MoveRecentlyComparedProductsOnOrderPageTest"> + <variation name="MoveRecentlyComparedProductsOnOrderPageTestVariation1"> + <data name="products" xsi:type="string">catalogProductSimple::default,catalogProductSimple::default</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + <variation name="MoveRecentlyComparedProductsOnOrderPageTestVariation2" firstConstraint="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" method="test"> + <data name="products" xsi:type="string">configurableProduct::default,configurableProduct::default</data> + <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..31fd3de31d59505404cb4f90d48fd0987adbf77a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create product. + * 3. Open product on frontend. + * + * Steps: + * 1. Login in to Backend. + * 2. Open Customers > All Customers. + * 3. Search and open customer from preconditions. + * 4. Click Create Order. + * 5. Check product in Recently Viewed Products section. + * 6. Click Update Changes. + * 7. Click Configure. + * 8. Fill data from dataSet. + * 9. Click OK. + * 10. Click Update Items and Qty's button. + * 11. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29723 + */ +class MoveRecentlyViewedProductsOnOrderPageTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Runs Move Recently Viewed Products On Order Page. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..7bd0a534e1993380d2719d2a38d53d8e0bddeee2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyViewedProductsOnOrderPageTest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MoveRecentlyViewedProductsOnOrderPageTest"> + <variation name="MoveRecentlyViewedProductsOnOrderPageTestVariation1"> + <data name="products" xsi:type="string">configurableProduct::default</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + <variation name="MoveRecentlyViewedProductsOnOrderPageTestVariation2"> + <data name="products" xsi:type="string">bundleProduct::bundle_fixed_product</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php new file mode 100644 index 0000000000000000000000000000000000000000..36637b0a89863b410d7db2f3d1fbc30c7de15e62 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.php @@ -0,0 +1,169 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Create customer. + * 2. Create product. + * 3. Add product to cart. + * + * Steps: + * 1. Open Customers > All Customers. + * 2. Search and open customer from preconditions. + * 3. Click Create Order. + * 4. Check product in Shopping Cart section. + * 5. Click Update Changes. + * 6. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28540 + */ +class MoveShoppingCartProductsOnOrderPageTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Customer logout page + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Browser instance + * + * @var BrowserInterface + */ + protected $browser; + + /** + * Catalog product page + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Customer index page + * + * @var CustomerIndex + */ + protected $customerIndex; + + /** + * Customer index edit page + * + * @var CustomerIndexEdit + */ + protected $customerIndexEdit; + + /** + * Order create index page + * + * @var OrderCreateIndex + */ + protected $orderCreateIndex; + + /** + * Prepare data. + * + * @param Customer $customer + * @return array + */ + public function __prepare(Customer $customer) + { + $customer->persist(); + + return ['customer' => $customer]; + } + + /** + * Inject pages. + * + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogProductView $catalogProductView + * @param CustomerIndex $customerIndex + * @param CustomerIndexEdit $customerIndexEdit + * @param BrowserInterface $browser + * @param OrderCreateIndex $orderCreateIndex + * @return void + */ + public function __inject( + CustomerAccountLogout $customerAccountLogout, + CatalogProductView $catalogProductView, + CustomerIndex $customerIndex, + CustomerIndexEdit $customerIndexEdit, + BrowserInterface $browser, + OrderCreateIndex $orderCreateIndex + ) { + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogProductView = $catalogProductView; + $this->customerIndex = $customerIndex; + $this->customerIndexEdit = $customerIndexEdit; + $this->browser = $browser; + $this->orderCreateIndex = $orderCreateIndex; + } + + /** + * Create order from customer page (cartActions). + * + * @param Customer $customer + * @param string $product + * @return array + */ + public function test(Customer $customer, $product) + { + //Preconditions + // Create product + $product = $this->objectManager->create( + '\Magento\Catalog\Test\TestStep\CreateProductStep', + ['product' => $product] + )->run()['product']; + // Login under customer + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $customer] + )->run(); + $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->catalogProductView->getViewBlock()->addToCart($product); + + //Steps + $this->customerIndex->open(); + $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); + $this->customerIndexEdit->getPageActionsBlock()->createOrder(); + $this->orderCreateIndex->getStoreBlock()->selectStoreView(); + $this->orderCreateIndex->getCustomerActivitiesBlock()->getShoppingCartItemsBlock() + ->addProductsToOrder([$product]); + $this->orderCreateIndex->getCustomerActivitiesBlock()->updateChanges(); + + return ['products' => [$product]]; + } + + /** + * Log out after test. + * + * @return void + */ + public function tearDown() + { + $this->customerAccountLogout->open(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..60887adfe898c5620a78e453d395a8d3c2ef22c5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\MoveShoppingCartProductsOnOrderPageTest"> + <variation name="MoveShoppingCartProductsOnOrderPageTestVariation1"> + <data name="product" xsi:type="string">catalogProductSimple::default</data> + <constraint name="Magento\Sales\Test\Constraint\AssertProductInItemsOrderedGrid" /> + </variation> + <variation name="MoveShoppingCartProductsOnOrderPageTestVariation2" firstConstraint="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" method="test"> + <data name="product" xsi:type="string">configurableProduct::default</data> + <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInItemsOrderedGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1e7e13da8b55aa384852be9ec86a09d943bb2df8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\Client\BrowserInterface; +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Create products. + * 2. Enable all Gift Options. + * 3. Create Gift Card Account with Balance = 1. + * 4. Create Customer Account. + * 5. Place order with options according to dataSet. + * + * Steps: + * 1. Find the Order on frontend. + * 2. Navigate to: Orders and Returns. + * 3. Fill the form with correspondent Order data. + * 4. Click on the "Continue" button. + * 5. Click on the "Print Order" button. + * 6. Perform appropriate assertions.v + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-30253 + */ +class PrintOrderFrontendGuestTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Browser. + * + * @var BrowserInterface + */ + protected $browser; + + /** + * Prepare data. + * + * @param BrowserInterface $browser + */ + public function __prepare(BrowserInterface $browser) + { + $this->browser = $browser; + } + + /** + * Runs print order on frontend. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } + + /** + * Close browser. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->browser->closeWindow(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..c5bce1d33a76dc478e09ee229b777fff8e2345b3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\PrintOrderFrontendGuestTest"> + <variation name="PrintOrderFrontendGuestTestVariation1"> + <data name="customer" xsi:type="array"> + <item name="dataSet" xsi:type="string">johndoe_with_addresses"</item> + </data> + <data name="billingAddress" xsi:type="array"> + <item name="dataSet" xsi:type="string">customer_US"</item> + </data> + <data name="payment" xsi:type="array"> + <item name="method" xsi:type="string">checkmo"</item> + </data> + <data name="products" xsi:type="string">bundleProduct::bundle_dynamic_product, configurableProduct::default, downloadableProduct::default</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">723.00</item> + </data> + <data name="paymentMethod" xsi:type="string">Check / Money order</data> + <data name="salesRule" xsi:type="string">active_sales_rule_with_fixed_price_discount_coupon</data> + <data name="salesRuleDiscount" xsi:type="string">300.00</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <constraint name="Magento\Sales\Test\Constraint\AssertSalesPrintOrderBillingAddress" /> + <constraint name="Magento\Sales\Test\Constraint\AssertSalesPrintOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertSalesPrintOrderPaymentMethod" /> + <constraint name="Magento\Sales\Test\Constraint\AssertSalesPrintOrderProducts" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertSalesRuleOnPrintOrder" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShippingMethodOnPrintOrder" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2706971f12810aad500a1c8cee168296420b5384 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Create two products. + * 2. Create a customer. + * 3. Create order. + * + * Steps: + * 1. Go to backend. + * 2. Open Sales > Orders. + * 3. Open the created order. + * 4. Do 'Reorder' for placed order. + * 5. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29007 + */ +class ReorderOrderEntityTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Reorder created order. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } + + /** + * Disable enabled config after test. + * + * @return void + */ + public function tearDown() + { + if (isset($this->currentVariation['arguments']['configData'])) { + $setConfigStep = $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => $this->currentVariation['arguments']['configData'], 'rollback' => true] + ); + $setConfigStep->run(); + } + $this->objectManager->create('Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..200b45de0adb16a93d2c5343434e3038d064973d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\ReorderOrderEntityTest"> + <variation name="ReorderOrderEntityTestVariation1"> + <data name="description" xsi:type="string">Reorder placed order (update products, billing address).</data> + <data name="order/dataSet" xsi:type="string">two_simple_product</data> + <data name="salesRule" xsi:type="string">active_sales_rule_with_fixed_price_discount_coupon</data> + <data name="customer/dataSet" xsi:type="string">customer_US</data> + <data name="billingAddress/dataSet" xsi:type="string">customer_US</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">1,030.00</item> + </data> + <data name="payment/method" xsi:type="string">checkmo</data> + <data name="previousOrderStatus" xsi:type="string">Pending</data> + <data name="status" xsi:type="string">Pending</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Reorder, Cancel, Send Notification, Hold, Invoice, Ship, Edit</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertReorderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..05813d46b2d8b1850062a97c3401775e4290d93a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderStatus; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusIndex; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Custom Order Status is created. + * 2. Order Status assigned to State. + * + * Steps: + * 1. Log in to backend. + * 2. Navigate to the Stores > Settings > Order Status. + * 3. Click "Unassign" for appropriate status. + * 4. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29450 + */ +class UnassignCustomOrderStatusTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Order Status Index page. + * + * @var OrderStatusIndex + */ + protected $orderStatusIndex; + + /** + * Injection data. + * + * @param OrderStatusIndex $orderStatusIndex + * @return void + */ + public function __inject(OrderStatusIndex $orderStatusIndex) + { + $this->orderStatusIndex = $orderStatusIndex; + } + + /** + * Run Unassign Custom OrderStatus test. + * + * @param OrderStatus $orderStatus + * @return void + */ + public function test(OrderStatus $orderStatus) + { + // Preconditions: + $orderStatus->persist(); + + // Steps: + $orderStatusLabel = $orderStatus->getLabel(); + $this->orderStatusIndex->open(); + $this->orderStatusIndex->getOrderStatusGrid()->searchAndUnassign(['label' => $orderStatusLabel]); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..c429fc46730d9b6983b05843d316b1f6a9586c1e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UnassignCustomOrderStatusTest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\UnassignCustomOrderStatusTest"> + <variation name="UnassignCustomOrderStatusTestVariation1"> + <data name="description" xsi:type="string">unassign order status</data> + <data name="orderStatus/dataSet" xsi:type="string">assign_to_pending</data> + <data name="defaultState" xsi:type="string">Pending</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessUnassignMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusNotAssigned" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1ddf03146ceeee32abf630ad2166ac73b2f7f1c4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.php @@ -0,0 +1,159 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Fixture\OrderStatus; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusEdit; +use Magento\Sales\Test\Page\Adminhtml\OrderStatusIndex; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Custom Order Status is created. + * 2. New order should be created if orderExist=Yes. + * + * Steps: + * 1. Log in as admin. + * 2. Navigate to the Stores > Settings > Order Status. + * 3. Click on Custom Order Status from grid. + * 4. Fill in all data according to data set. + * 5. Save order status. + * 6. Perform all assertions. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-29868 + */ +class UpdateCustomOrderStatusTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Order Status Index page. + * + * @var OrderStatusIndex + */ + protected $orderStatusIndex; + + /** + * Order Status Edit page. + * + * @var OrderStatusEdit + */ + protected $orderStatusEdit; + + /** + * Order Index page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * OrderStatus Fixture. + * + * @var OrderStatus + */ + protected $orderStatus; + + /** + * OrderStatus Fixture. + * + * @var OrderStatus + */ + protected $orderStatusInitial; + + /** + * OrderInjectable Fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Injection data. + * + * @param OrderStatusIndex $orderStatusIndex + * @param OrderStatusEdit $orderStatusEdit + * @param OrderIndex $orderIndex + * @return void + */ + public function __inject( + OrderStatusIndex $orderStatusIndex, + OrderStatusEdit $orderStatusEdit, + OrderIndex $orderIndex + ) { + $this->orderStatusIndex = $orderStatusIndex; + $this->orderStatusEdit = $orderStatusEdit; + $this->orderIndex = $orderIndex; + } + + /** + * Run Update Custom OrderStatus Test. + * + * @param OrderStatus $orderStatusInitial + * @param OrderStatus $orderStatus + * @param OrderInjectable $order + * @param FixtureFactory $fixtureFactory + * @param string $orderExist + * @return array + */ + public function test( + OrderStatus $orderStatusInitial, + OrderStatus $orderStatus, + OrderInjectable $order, + FixtureFactory $fixtureFactory, + $orderExist + ) { + // Preconditions: + $orderStatusInitial->persist(); + if ($orderExist == 'Yes') { + $order->persist(); + } + // Steps: + $this->orderStatusIndex->open(); + $this->orderStatusIndex->getOrderStatusGrid()->searchAndOpen(['label' => $orderStatusInitial->getLabel()]); + $this->orderStatusEdit->getOrderStatusForm()->fill($orderStatus); + $this->orderStatusEdit->getFormPageActions()->save(); + + // Configuring orderStatus for asserts. + $orderStatus = $fixtureFactory->createByCode( + 'orderStatus', + ['data' => array_merge($orderStatusInitial->getData(), $orderStatus->getData())] + ); + + // Prepare data for tear down + $this->orderStatus = $orderStatus; + $this->orderStatusInitial = $orderStatusInitial; + $this->order = $order; + + return [ + 'orderStatus' => $orderStatus, + 'status' => $orderStatus->getLabel(), + 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer() + ]; + } + + /** + * Change created order status and unassign custom order status if order was created. + * + * @return void + */ + public function tearDown() + { + if ($this->order->hasData('id')) { + $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel'); + $filter = ['label' => $this->orderStatus->getLabel(), 'status' => $this->orderStatusInitial->getStatus()]; + $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter); + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..3db975b7ed80ef2a51bca736ad384f19ec914aa5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/UpdateCustomOrderStatusTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\UpdateCustomOrderStatusTest"> + <variation name="UpdateCustomOrderStatusTestVariation1"> + <data name="description" xsi:type="string">change status label to existed</data> + <data name="orderStatusInitial/dataSet" xsi:type="string">default</data> + <data name="orderExist" xsi:type="string">No</data> + <data name="orderStatus/data/label" xsi:type="string">Processing</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + </variation> + <variation name="UpdateCustomOrderStatusTestVariation2"> + <data name="description" xsi:type="string">change status label to new and check orderStatus for order with changed orderStatus</data> + <data name="orderStatusInitial/dataSet" xsi:type="string">assign_to_pending</data> + <data name="orderExist" xsi:type="string">Yes</data> + <data name="orderStatus/data/label" xsi:type="string">orderLabel%isolation%</data> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGridOnFrontend" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddRecentlyViewedProductsToCartStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddRecentlyViewedProductsToCartStep.php index d995a2c78298b4d2932cf9836377407933f321eb..c642f0e5ccee6a3e86fdf0dc7768440222d3dac1 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddRecentlyViewedProductsToCartStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/AddRecentlyViewedProductsToCartStep.php @@ -47,21 +47,7 @@ class AddRecentlyViewedProductsToCartStep implements TestStepInterface public function run() { $recentlyBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); - $recentlyBlock->getRecentlyViewedItemsBlock()->addToOrderByName($this->extractProductNames()); + $recentlyBlock->getRecentlyViewedItemsBlock()->addProductsToOrder($this->products); $recentlyBlock->updateChanges(); } - - /** - * Extract products name. - * - * @return array - */ - protected function extractProductNames() - { - $result = []; - foreach ($this->products as $product) { - $result[] = $product->getName(); - } - return $result; - } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php new file mode 100644 index 0000000000000000000000000000000000000000..fa43917e81db2e7454503c886f21e2dc7550ecdc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderCreditMemoNew; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Create credit memo from order on backend. + */ +class CreateCreditMemoStep implements TestStepInterface +{ + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * OrderCreditMemoNew Page. + * + * @var OrderCreditMemoNew + */ + protected $orderCreditMemoNew; + + /** + * OrderInjectable fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Credit memo data. + * + * @var array|null + */ + protected $data; + + /** + * @construct + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @param OrderInjectable $order + * @param OrderCreditMemoNew $orderCreditMemoNew + * @param array|null $data [optional] + */ + public function __construct( + OrderIndex $orderIndex, + SalesOrderView $salesOrderView, + OrderInjectable $order, + OrderCreditMemoNew $orderCreditMemoNew, + $data = null + ) { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + $this->order = $order; + $this->orderCreditMemoNew = $orderCreditMemoNew; + $this->data = $data; + } + + /** + * Create credit memo from order on backend. + * + * @return array + */ + public function run() + { + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + $this->salesOrderView->getPageActions()->orderCreditMemo(); + if (!empty($this->data)) { + $this->orderCreditMemoNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']); + $this->orderCreditMemoNew->getFormBlock()->updateQty(); + } + $this->orderCreditMemoNew->getFormBlock()->submit(); + + return ['creditMemoIds' => $this->getCreditMemoIds()]; + } + + /** + * Get credit memo ids. + * + * @return array + */ + protected function getCreditMemoIds() + { + $this->salesOrderView->getOrderForm()->openTab('creditmemos'); + return $this->salesOrderView->getOrderForm()->getTabElement('creditmemos')->getGridBlock()->getIds(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php new file mode 100644 index 0000000000000000000000000000000000000000..304f58063a029496d5b50dfb06dab0cdb02a4d9b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php @@ -0,0 +1,146 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew; +use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceView; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Shipping\Test\Page\Adminhtml\OrderShipmentView; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Create invoice from order on backend. + */ +class CreateInvoiceStep implements TestStepInterface +{ + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * Order New Invoice Page. + * + * @var OrderInvoiceNew + */ + protected $orderInvoiceNew; + + /** + * Order invoice view page. + * + * @var OrderInvoiceView + */ + protected $orderInvoiceView; + + /** + * Order shipment view page. + * + * @var OrderShipmentView + */ + protected $orderShipmentView; + + /** + * OrderInjectable fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Invoice data. + * + * @var array|null + */ + protected $data; + + /** + * @construct + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @param OrderInvoiceNew $orderInvoiceNew + * @param OrderInvoiceView $orderInvoiceView + * @param OrderInjectable $order + * @param OrderShipmentView $orderShipmentView + * @param array|null $data[optional] + */ + public function __construct( + OrderIndex $orderIndex, + SalesOrderView $salesOrderView, + OrderInvoiceNew $orderInvoiceNew, + OrderInvoiceView $orderInvoiceView, + OrderInjectable $order, + OrderShipmentView $orderShipmentView, + $data = null + ) { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + $this->orderInvoiceNew = $orderInvoiceNew; + $this->orderInvoiceView = $orderInvoiceView; + $this->order = $order; + $this->orderShipmentView = $orderShipmentView; + $this->data = $data; + } + + /** + * Create invoice (with shipment optionally) for order on backend. + * + * @return array + */ + public function run() + { + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + $this->salesOrderView->getPageActions()->invoice(); + if (!empty($this->data)) { + $this->orderInvoiceNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']); + $this->orderInvoiceNew->getFormBlock()->updateQty(); + } + $this->orderInvoiceNew->getFormBlock()->submit(); + $invoiceIds = $this->getInvoiceIds(); + if (!empty($this->data)) { + $shipmentIds = $this->getShipmentIds(); + } + + return [ + 'invoiceIds' => $invoiceIds, + 'shipmentIds' => isset($shipmentIds) ? $shipmentIds : null, + ]; + } + + /** + * Get invoice ids. + * + * @return array + */ + protected function getInvoiceIds() + { + $this->salesOrderView->getOrderForm()->openTab('invoices'); + return $this->salesOrderView->getOrderForm()->getTabElement('invoices')->getGridBlock()->getIds(); + } + + /** + * Get shipment ids. + * + * @return array + */ + protected function getShipmentIds() + { + $this->salesOrderView->getOrderForm()->openTab('shipments'); + return $this->salesOrderView->getOrderForm()->getTabElement('shipments')->getGridBlock()->getIds(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOrderStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOrderStep.php new file mode 100644 index 0000000000000000000000000000000000000000..5373d0da6c99781491bf2ad6d7d2f0ed23e1f808 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOrderStep.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Step for create order. + */ +class CreateOrderStep implements TestStepInterface +{ + /** + * Order. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Preparing step properties. + * + * @constructor + * @param OrderInjectable $order + */ + public function __construct(OrderInjectable $order) + { + $this->order = $order; + } + + /** + * Create order. + * + * @return array + */ + public function run() + { + $this->order->persist(); + + return ['products' => $this->order->getEntityId()['products'], 'order' => $this->order]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php new file mode 100644 index 0000000000000000000000000000000000000000..1ea259d0e05cd8bab3aa9ffdbb4130114a86562d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateShipmentStep.php @@ -0,0 +1,116 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Shipping\Test\Page\Adminhtml\OrderShipmentNew; +use Magento\Shipping\Test\Page\Adminhtml\OrderShipmentView; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Create shipping from order on backend. + */ +class CreateShipmentStep implements TestStepInterface +{ + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * New Order Shipment Page. + * + * @var OrderShipmentNew + */ + protected $orderShipmentNew; + + /** + * Order shipment view page. + * + * @var OrderShipmentView + */ + protected $orderShipmentView; + + /** + * OrderInjectable fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * Invoice data. + * + * @var array|null + */ + protected $data; + + /** + * @construct + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @param OrderShipmentNew $orderShipmentNew + * @param OrderShipmentView $orderShipmentView + * @param OrderInjectable $order + * @param array|null $data [optional] + */ + public function __construct( + OrderIndex $orderIndex, + SalesOrderView $salesOrderView, + OrderShipmentNew $orderShipmentNew, + OrderShipmentView $orderShipmentView, + OrderInjectable $order, + $data = null + ) { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + $this->orderShipmentNew = $orderShipmentNew; + $this->orderShipmentView = $orderShipmentView; + $this->order = $order; + $this->data = $data; + } + + /** + * Create shipping for order on backend. + * + * @return array + */ + public function run() + { + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + $this->salesOrderView->getPageActions()->ship(); + if (!empty($this->data)) { + $this->orderShipmentNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']); + } + $this->orderShipmentNew->getFormBlock()->submit(); + + return ['shipmentIds' => $this->getShipmentIds()]; + } + + /** + * Get shipment id. + * + * @return array + */ + public function getShipmentIds() + { + $this->salesOrderView->getOrderForm()->openTab('shipments'); + return $this->salesOrderView->getOrderForm()->getTabElement('shipments')->getGridBlock()->getIds(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OnHoldStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OnHoldStep.php new file mode 100644 index 0000000000000000000000000000000000000000..ede5372c7f4bdb1cd91b42a5ee7eb2a68bf74b2d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OnHoldStep.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * On hold order on backend. + */ +class OnHoldStep implements TestStepInterface +{ + /** + * Orders Page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order View Page. + * + * @var SalesOrderView + */ + protected $salesOrderView; + + /** + * OrderInjectable fixture. + * + * @var OrderInjectable + */ + protected $order; + + /** + * @construct + * @param OrderIndex $orderIndex + * @param SalesOrderView $salesOrderView + * @param OrderInjectable $order + */ + public function __construct(OrderIndex $orderIndex, SalesOrderView $salesOrderView, OrderInjectable $order) + { + $this->orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + $this->order = $order; + } + + /** + * On hold order on backend. + * + * @return void + */ + public function run() + { + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + $this->salesOrderView->getPageActions()->hold(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenOrderStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenOrderStep.php new file mode 100644 index 0000000000000000000000000000000000000000..d82b38e263d797a526c9f8bad5c39b213c8457c4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenOrderStep.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Open order step. + */ +class OpenOrderStep implements TestStepInterface +{ + /** + * Sales order index page. + * + * @var OrderIndex + */ + protected $orderIndex; + + /** + * Order instance. + * + * @var OrderInjectable + */ + protected $order; + + /** + * @constructor + * @param OrderInjectable $order + * @param OrderIndex $orderIndex + */ + public function __construct(OrderInjectable $order, OrderIndex $orderIndex) + { + $this->orderIndex = $orderIndex; + $this->order = $order; + } + + /** + * Open order. + * + * @return void + */ + public function run() + { + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenSalesOrderOnFrontendForGuestStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenSalesOrderOnFrontendForGuestStep.php new file mode 100644 index 0000000000000000000000000000000000000000..783f7e0f37c7c60f4325508d6410b046b4a98ead --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/OpenSalesOrderOnFrontendForGuestStep.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestStep; + +use Magento\Cms\Test\Page\CmsIndex; +use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Sales\Test\Page\SalesGuestForm; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Open sales order page on frontend for guest. + */ +class OpenSalesOrderOnFrontendForGuestStep implements TestStepInterface +{ + /** + * Customer log out page. + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Cms index page. + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Sales guest page. + * + * @var SalesGuestForm + */ + protected $salesGuestForm; + + /** + * Fixture order. + * + * @var OrderInjectable + */ + protected $order; + + /** + * @constructor + * @param CustomerAccountLogout $customerAccountLogout + * @param CmsIndex $cmsIndex + * @param SalesGuestForm $salesGuestForm + * @param OrderInjectable $order + */ + public function __construct( + CustomerAccountLogout $customerAccountLogout, + CmsIndex $cmsIndex, + SalesGuestForm $salesGuestForm, + OrderInjectable $order + ) { + $this->customerAccountLogout = $customerAccountLogout; + $this->cmsIndex = $cmsIndex; + $this->salesGuestForm = $salesGuestForm; + $this->order = $order; + } + + /** + * Run step. + * + * @return void + */ + public function run() + { + $this->customerAccountLogout->open(); + $this->cmsIndex->getFooterBlock()->clickLink('Orders and Returns'); + $this->salesGuestForm->getSearchForm()->fill($this->order); + $this->salesGuestForm->getSearchForm()->submit(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml index 4e5838f04aecf4c22d2ccb9ab95d93a37ffd415e..4e7817f293e701d2d0254be667ed8be7eadba345 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml @@ -35,11 +35,7 @@ </scenario> <scenario name="MoveRecentlyViewedProductsOnOrderPageTest" firstStep="createProducts"> <step name="createProducts" module="Magento_Catalog" next="createCustomer" /> - <step name="createCustomer" module="Magento_Customer" next="loginCustomerOnFrontend"> - <item name="customer"> - <item name="dataSet" value="default" /> - </item> - </step> + <step name="createCustomer" module="Magento_Customer" next="loginCustomerOnFrontend" /> <step name="loginCustomerOnFrontend" module="Magento_Customer" next="openProductsOnFrontend" /> <step name="openProductsOnFrontend" module="Magento_Catalog" next="openCustomerOnBackend" /> <step name="openCustomerOnBackend" module="Magento_Customer" next="createOrderFromCustomerAccount" /> @@ -50,26 +46,14 @@ </scenario> <scenario name="PrintOrderFrontendGuestTest" firstStep="createProducts"> <step name="createProducts" module="Magento_Catalog" next="createCustomer" /> - <step name="createCustomer" module="Magento_Customer" next="openSalesOrders"> - <item name="customer"> - <item name="dataSet" value="johndoe_with_addresses" /> - </item> - </step> + <step name="createCustomer" module="Magento_Customer" next="openSalesOrders" /> <step name="openSalesOrders" module="Magento_Sales" next="createNewOrder" /> <step name="createNewOrder" module="Magento_Sales" next="selectCustomerOrder" /> <step name="selectCustomerOrder" module="Magento_Sales" next="selectStore" /> <step name="selectStore" module="Magento_Sales" next="addProducts" /> <step name="addProducts" module="Magento_Sales" next="fillBillingAddress" /> - <step name="fillBillingAddress" module="Magento_Sales" next="selectPaymentMethodForOrder"> - <item name="billingAddress"> - <item name="dataSet" value="customer_US" /> - </item> - </step> - <step name="selectPaymentMethodForOrder" module="Magento_Sales" next="selectShippingMethodForOrder"> - <item name="payment"> - <item name="method" value="checkmo" /> - </item> - </step> + <step name="fillBillingAddress" module="Magento_Sales" next="selectPaymentMethodForOrder" /> + <step name="selectPaymentMethodForOrder" module="Magento_Sales" next="selectShippingMethodForOrder" /> <step name="selectShippingMethodForOrder" module="Magento_Sales" next="submitOrder" /> <step name="submitOrder" module="Magento_Sales" next="openSalesOrderOnFrontendForGuest" /> <step name="openSalesOrderOnFrontendForGuest" module="Magento_Sales" next="printOrderOnFrontend" /> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Grid.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Grid.php new file mode 100644 index 0000000000000000000000000000000000000000..02d2e2652fad958f5dbde7807cc33c1b6ae18e10 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Grid.php @@ -0,0 +1,83 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Block\Adminhtml\Promo; + +use Magento\Mtf\Client\Locator; + +/** + * Backend sales rule grid. + */ +class Grid extends \Magento\Backend\Test\Block\Widget\Grid +{ + /** + * Id of a row selector. + * + * @var string + */ + protected $rowIdSelector = 'td.col-rule_id'; + + /** + * Locator for promo quote form. + * + * @var string + */ + protected $promoQuoteFormSelector = 'div#promo_catalog_edit_tabs'; + + /** + * First row selector + * + * @var string + */ + protected $firstRowSelector = '//tr[1]/td[@data-column="name"]'; + + /** + * Filters array mapping. + * + * @var array + */ + protected $filters = [ + 'rule_id' => [ + 'selector' => '#promo_quote_grid_filter_rule_id', + ], + 'name' => [ + 'selector' => 'input[name="name"]', + ], + ]; + + /** + * Locator value for link in sales rule name column. + * + * @var string + */ + protected $editLink = 'td[class*=col-name]'; + + /** + * An element locator which allows to select entities in grid. + * + * @var string + */ + protected $selectItem = 'tbody tr .col-name'; + + /** + * Return the id of the row that matched the search filter. + * + * @param $filter + * @param bool $isSearchable + * @return array|int|string + */ + public function getIdOfRow($filter, $isSearchable = true) + { + $rid = -1; + $this->search($filter, $isSearchable); + $rowItem = $this->_rootElement->find($this->rowItem, Locator::SELECTOR_CSS); + if ($rowItem->isVisible()) { + $idElement = $rowItem->find($this->rowIdSelector); + $rid = $idElement->getText(); + } + return $rid; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.php new file mode 100644 index 0000000000000000000000000000000000000000..9a2b007711a0dde54bb0dbb61aa80122318f7e79 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit; + +use Magento\Backend\Test\Block\Widget\FormTabs; + +/** + * Sales rule edit form. + */ +class PromoQuoteForm extends FormTabs +{ + /** + * Selector of element to wait for. If set by child will wait for element after action + * + * @var string + */ + protected $waitForSelector = 'div#promo_catalog_edit_tabs'; + + /** + * Wait for should be for visibility or not? + * + * @var boolean + */ + protected $waitForSelectorVisible = false; +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.xml new file mode 100644 index 0000000000000000000000000000000000000000..756e14f274fa065bdd3ce9914a5d41d6e778841d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/PromoQuoteForm.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tabs> + <rule_information> + <class>\Magento\Backend\Test\Block\Widget\Tab</class> + <selector>#promo_catalog_edit_tabs_main_section</selector> + <strategy>css selector</strategy> + <fields> + <name /> + <description /> + <is_active> + <input>select</input> + </is_active> + <website_ids> + <selector>[name="website_ids[]"]</selector> + <input>multiselect</input> + </website_ids> + <customer_group_ids> + <selector>[name="customer_group_ids[]"]</selector> + <input>multiselect</input> + </customer_group_ids> + <coupon_type> + <input>select</input> + </coupon_type> + <coupon_code /> + <uses_per_coupon /> + <uses_per_customer /> + <from_date /> + <to_date /> + <sort_order /> + <is_rss> + <input>select</input> + </is_rss> + </fields> + </rule_information> + <conditions> + <class>\Magento\Backend\Test\Block\Widget\Tab</class> + <selector>#promo_catalog_edit_tabs_conditions_section</selector> + <strategy>css selector</strategy> + <fields> + <conditions_serialized> + <selector>#rule_conditions_fieldset</selector> + <input>conditions</input> + </conditions_serialized> + </fields> + </conditions> + <actions> + <class>\Magento\Backend\Test\Block\Widget\Tab</class> + <selector>#promo_catalog_edit_tabs_actions_section</selector> + <strategy>css selector</strategy> + <fields> + <simple_action> + <input>select</input> + </simple_action> + <discount_amount /> + <discount_qty /> + <discount_step /> + <apply_to_shipping> + <input>select</input> + </apply_to_shipping> + <stop_rules_processing> + <input>select</input> + </stop_rules_processing> + <simple_free_shipping> + <input>select</input> + </simple_free_shipping> + <actions_serialized> + <selector>#rule_actions_fieldset</selector> + <input>conditions</input> + </actions_serialized> + </fields> + </actions> + <labels> + <class>\Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Tab\Labels</class> + <selector>#promo_catalog_edit_tabs_labels_section</selector> + <strategy>css selector</strategy> + </labels> +</tabs> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php new file mode 100644 index 0000000000000000000000000000000000000000..35ad53e038c1c94d20ee093d83b640ce7d590390 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Conditions.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Tab; + +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Backend\Test\Block\Widget\Tab; + +/** + * Sales rule condition tab. + */ +class Conditions extends Tab +{ + /** + * Field Prefix Constant + */ + const FIELD_PREFIX = '#conditions__1__'; + + /** + * Set the mapping and fill the form. + * + * @param array $fields + * @param SimpleElement|null $element + * @return $this + * + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + public function fillFormTab(array $fields, SimpleElement $element = null) + { + foreach ($fields as $key => $value) { + $this->mapping[$key] = self::FIELD_PREFIX . $key; + } + return parent::fillFormTab($fields, $element); + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php new file mode 100644 index 0000000000000000000000000000000000000000..7805f1ec94f6ac91cdf3075d5f8f546626cdc407 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/Labels.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Tab; + +use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Mtf\Client\Element\SimpleElement; + +/** + * Backend sales rule label tab. + */ +class Labels extends Tab +{ + /** + * Store label field name. + */ + const STORE_LABEL_NAME = '[name="store_labels[%s]"]'; + + /** + * Fill data to labels fields on labels tab. + * + * @param array $fields + * @param SimpleElement|null $element + * @return $this + */ + public function fillFormTab(array $fields, SimpleElement $element = null) + { + if (isset($fields['store_labels'])) { + $count = 0; + foreach ($fields['store_labels']['value'] as $storeLabel) { + $element->find(sprintf(self::STORE_LABEL_NAME, $count))->setValue($storeLabel); + ++$count; + } + } + + return $this; + } + + /** + * Get data of labels tab. + * + * @param array|null $fields + * @param SimpleElement|null $element + * @return array + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getDataFormTab($fields = null, SimpleElement $element = null) + { + $context = $element === null ? $this->_rootElement : $element; + $storeLabels = []; + $count = 0; + $field = $context->find(sprintf(self::STORE_LABEL_NAME, $count)); + while ($field->isVisible()) { + $fieldValue = $field->getValue(); + if ($fieldValue != '') { + $storeLabels[$count] = $fieldValue; + } + ++$count; + $field = $context->find(sprintf(self::STORE_LABEL_NAME, $count)); + } + + return ['store_labels' => $storeLabels]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/Items.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/Items.php new file mode 100644 index 0000000000000000000000000000000000000000..5914551482f6ab10db655f07b811b185723865bc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/Items.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Block\Order; + +/** + * Items block on order's view page. + */ +class Items extends \Magento\Sales\Test\Block\Order\Items +{ + /** + * Sales Rule selector. + * + * @var string + */ + protected $salesRuleSelector = '.discount > .amount > span.price'; + + /** + * Get sales rule discount. + * + * @return string + */ + public function getSalesRuleDiscount() + { + return $this->escapeCurrency($this->_rootElement->find($this->salesRuleSelector)->getText()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php new file mode 100644 index 0000000000000000000000000000000000000000..58c533220c5140b2dee350de44ae27ffb3292390 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Order/View.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Block\Order; + +use Magento\Mtf\Client\Locator; + +/** + * View block on order's view page. + */ +class View extends \Magento\Sales\Test\Block\Order\View +{ + /** + * Get item block. + * + * @param int $id [optional] + * @return Items + */ + public function getItemBlock($id = null) + { + $selector = ($id === null) ? $this->content : sprintf($this->itemBlock, $id) . $this->content; + return $this->blockFactory->create( + 'Magento\SalesRule\Test\Block\Order\Items', + ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] + ); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..1b573901d93ca029d529bf6c812e436b43d0ee05 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleApplying.php @@ -0,0 +1,209 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Magento\Catalog\Test\Page\Category\CatalogCategoryView; +use Magento\Catalog\Test\Page\Product\CatalogProductView; +use Magento\Checkout\Test\Page\CheckoutCart; +use Magento\Cms\Test\Page\CmsIndex; +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\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Abstract class for implementing assert applying. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +abstract class AssertCartPriceRuleApplying extends AbstractConstraint +{ + /** + * Page CheckoutCart. + * + * @var CheckoutCart + */ + protected $checkoutCart; + + /** + * Page CmsIndex. + * + * @var CmsIndex + */ + protected $cmsIndex; + + /** + * Page CustomerAccountLogin. + * + * @var CustomerAccountLogin + */ + protected $customerAccountLogin; + + /** + * Page CustomerAccountLogout. + * + * @var CustomerAccountLogout + */ + protected $customerAccountLogout; + + /** + * Page CatalogCategoryView. + * + * @var CatalogCategoryView + */ + protected $catalogCategoryView; + + /** + * Page CatalogProductView. + * + * @var CatalogProductView + */ + protected $catalogProductView; + + /** + * Customer from precondition. + * + * @var Customer + */ + protected $customer; + + /** + * First product from precondition. + * + * @var CatalogProductSimple + */ + protected $productForSalesRule1; + + /** + * Second product from precondition. + * + * @var CatalogProductSimple + */ + protected $productForSalesRule2; + + /** + * Implementation assert. + * + * @return void + */ + abstract protected function assert(); + + /** + * 1. Navigate to frontend + * 2. If "Log Out" link is visible and "isLoggedIn" empty + * - makes logout + * 3. If "isLoggedIn" not empty + * - login as customer + * 4. Clear shopping cart + * 5. Add test product(s) to shopping cart with specify quantity + * 6. If "salesRule/data/coupon_code" not empty: + * - fill "Enter your code" input in Dіscount Codes + * - click "Apply Coupon" button + * 7. If "address/data/country_id" not empty: + * On Estimate Shipping and Tax: + * - fill Country, State/Province, Zip/Postal Code + * - click 'Get a Quote' button + * - select 'Flat Rate' shipping + * - click 'Update Total' button + * 8. Implementation assert + * + * @param CheckoutCart $checkoutCart + * @param CmsIndex $cmsIndex + * @param CustomerAccountLogin $customerAccountLogin + * @param CustomerAccountLogout $customerAccountLogout + * @param CatalogCategoryView $catalogCategoryView + * @param CatalogProductView $catalogProductView + * @param Customer $customer + * @param SalesRuleInjectable $salesRule + * @param SalesRuleInjectable $salesRuleOrigin + * @param array $productQuantity + * @param CatalogProductSimple $productForSalesRule1 + * @param CatalogProductSimple $productForSalesRule2 + * @param Address $address + * @param int|null $isLoggedIn + * @param array $shipping + * @return void + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ + public function processAssert( + CheckoutCart $checkoutCart, + CmsIndex $cmsIndex, + CustomerAccountLogin $customerAccountLogin, + CustomerAccountLogout $customerAccountLogout, + CatalogCategoryView $catalogCategoryView, + CatalogProductView $catalogProductView, + Customer $customer, + SalesRuleInjectable $salesRule, + SalesRuleInjectable $salesRuleOrigin, + array $productQuantity, + CatalogProductSimple $productForSalesRule1, + CatalogProductSimple $productForSalesRule2 = null, + Address $address = null, + $isLoggedIn = null, + array $shipping = [] + ) { + $this->checkoutCart = $checkoutCart; + $this->cmsIndex = $cmsIndex; + $this->customerAccountLogin = $customerAccountLogin; + $this->customerAccountLogout = $customerAccountLogout; + $this->catalogCategoryView = $catalogCategoryView; + $this->catalogProductView = $catalogProductView; + $this->customer = $customer; + $this->productForSalesRule1 = $productForSalesRule1; + $this->productForSalesRule2 = $productForSalesRule2; + $isLoggedIn ? $this->login() : $this->customerAccountLogout->open(); + $this->checkoutCart->open()->getCartBlock()->clearShoppingCart(); + $this->addProductsToCart($productQuantity); + $this->checkoutCart->open(); + if ($address !== null) { + $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address); + $this->checkoutCart->getShippingBlock()->selectShippingMethod($shipping); + } + if ($salesRule->getCouponCode() || $salesRuleOrigin->getCouponCode()) { + $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode( + $salesRule->getCouponCode() ? $salesRule->getCouponCode() : $salesRuleOrigin->getCouponCode() + ); + } + $this->assert(); + } + + /** + * LogIn customer. + * + * @return void + */ + protected function login() + { + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $this->customer] + )->run(); + } + + /** + * Add products to cart. + * + * @param array $productQuantity + * @return void + */ + protected function addProductsToCart(array $productQuantity) + { + foreach ($productQuantity as $product => $quantity) { + if ($quantity > 0) { + $categoryName = $this->$product->getCategoryIds()[0]; + $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName); + $this->catalogCategoryView->getListProductBlock()->getProductItem($this->$product)->open(); + $this->catalogProductView->getViewBlock()->setQtyAndClickAddToCart($quantity); + $this->catalogProductView->getMessagesBlock()->waitSuccessMessage(); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php new file mode 100644 index 0000000000000000000000000000000000000000..55a3450a6e108f56d86c72c681135232309b0c5f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +/** + * Check that shopping cart subtotal not equals with grand total(excluding shipping price if exist). + */ +class AssertCartPriceRuleConditionIsApplied extends AssertCartPriceRuleApplying +{ + /** + * Assert that shopping cart subtotal not equals with grand total. + * + * @return void + */ + protected function assert() + { + $subTotal = $this->checkoutCart->getTotalsBlock()->getSubtotal(); + $grandTotal = $this->checkoutCart->getTotalsBlock()->getGrandTotal(); + + if ($this->checkoutCart->getTotalsBlock()->isVisibleShippingPriceBlock()) { + $shippingPrice = $this->checkoutCart->getTotalsBlock()->getShippingPrice(); + $grandTotal = number_format(($grandTotal - $shippingPrice), 2); + } + \PHPUnit_Framework_Assert::assertNotEquals( + $subTotal, + $grandTotal, + 'Shopping cart subtotal: \'' . $subTotal . '\' equals with grand total: \'' . $grandTotal . '\'' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return "Shopping cart subtotal doesn't equal to grand total - price rule has been applied."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsNotApplied.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsNotApplied.php new file mode 100644 index 0000000000000000000000000000000000000000..b1c0efdbff284fe2b9e48a8ceab0f85a9afa77f8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsNotApplied.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +/** + * Check that shopping cart subtotal equals with grand total (excluding shipping price if exist). + */ +class AssertCartPriceRuleConditionIsNotApplied extends AssertCartPriceRuleApplying +{ + /** + * Assert that shopping cart subtotal equals with grand total. + * + * @return void + */ + protected function assert() + { + $subTotal = $this->checkoutCart->getTotalsBlock()->getSubtotal(); + $grandTotal = $this->checkoutCart->getTotalsBlock()->getGrandTotal(); + + if ($this->checkoutCart->getTotalsBlock()->isVisibleShippingPriceBlock()) { + $shippingPrice = $this->checkoutCart->getTotalsBlock()->getShippingPrice(); + $grandTotal = number_format(($grandTotal - $shippingPrice), 2); + } + \PHPUnit_Framework_Assert::assertEquals( + $subTotal, + $grandTotal, + 'Shopping cart subtotal: \'' . $subTotal . '\' not equals with grand total: \'' . $grandTotal . '\'' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return "Shopping cart subtotal equals to grand total - price rule has not been applied."; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..ccd77f877ced270b43d7bcc9f2081422676f0b58 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleForm.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert sales rule form. + */ +class AssertCartPriceRuleForm extends AbstractConstraint +{ + /** + * Skipped fields for verify data. + * + * @var array + */ + protected $skippedFields = [ + 'conditions_serialized', + 'actions_serialized', + 'from_date', + 'to_date', + 'id' + ]; + + /** + * Assert that displayed sales rule data on edit page(backend) equals passed from fixture. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @param PromoQuoteEdit $promoQuoteEdit + * @param SalesRuleInjectable $salesRule + * @param SalesRuleInjectable $salesRuleOrigin + * @return void + */ + public function processAssert( + PromoQuoteIndex $promoQuoteIndex, + PromoQuoteEdit $promoQuoteEdit, + SalesRuleInjectable $salesRule, + SalesRuleInjectable $salesRuleOrigin = null + ) { + $filter = [ + 'name' => $salesRule->hasData('name') ? $salesRule->getName() : $salesRuleOrigin->getName(), + ]; + + $promoQuoteIndex->open(); + $promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); + $formData = $promoQuoteEdit->getSalesRuleForm()->getData(); + $fixtureData = $salesRuleOrigin != null + ? array_merge($salesRuleOrigin->getData(), $salesRule->getData()) + : $salesRule->getData(); + $dataDiff = $this->verify($fixtureData, $formData); + \PHPUnit_Framework_Assert::assertTrue( + empty($dataDiff), + 'Sales rule data on edit page(backend) not equals to passed from fixture.' + . "\nFailed values:\n " . implode(";\n ", $dataDiff) + ); + } + + /** + * Verify data in form equals to passed from fixture. + * + * @param array $fixtureData + * @param array $formData + * @return array + */ + protected function verify(array $fixtureData, array $formData) + { + $errorMessage = []; + + foreach ($fixtureData as $key => $value) { + if (is_array($value)) { + $diff = array_diff($value, $formData[$key]); + $diff = array_merge($diff, array_diff($formData[$key], $value)); + if (!empty($diff)) { + $errorMessage[] = "Data in " . $key . " field is not equal." + . "\nExpected: " . implode(", ", $value) + . "\nActual: " . implode(", ", $formData[$key]); + } + } else { + if (!in_array($key, $this->skippedFields) && $value !== $formData[$key]) { + $errorMessage[] = "Data in " . $key . " field not equal." + . "\nExpected: " . $value + . "\nActual: " . $formData[$key]; + } + } + } + + return $errorMessage; + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Displayed sales rule data on edit page(backend) equals to passed from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleFreeShippingIsApplied.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleFreeShippingIsApplied.php new file mode 100644 index 0000000000000000000000000000000000000000..92814e0453ba21253a61e4d22b288a8ac8b418d5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleFreeShippingIsApplied.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +/** + * Check that shopping cart free shipping is applied. + */ +class AssertCartPriceRuleFreeShippingIsApplied extends AssertCartPriceRuleApplying +{ + const FREE_SHIPPING_PRICE = '0.00'; + + /** + * Assert that free shipping is applied in shopping cart. + * + * @return void + */ + protected function assert() + { + $shippingPrice = $this->checkoutCart->getTotalsBlock()->getShippingPrice(); + + \PHPUnit_Framework_Assert::assertEquals( + $shippingPrice, + self::FREE_SHIPPING_PRICE, + 'Current shipping price: \'' . $shippingPrice + . '\' not equals with free shipping price: \'' . self::FREE_SHIPPING_PRICE . '\'' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Free shipping is applied.'; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..4c2fd8856a08fdd1af69c5594124fef9443166f4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleIsNotPresentedInGrid.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert if sales rule is absent in grid. + */ +class AssertCartPriceRuleIsNotPresentedInGrid extends AbstractConstraint +{ + /** + * Assert that sales rule is not present in cart price rules grid. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @param SalesRuleInjectable $salesRule + * @return void + */ + public function processAssert(PromoQuoteIndex $promoQuoteIndex, SalesRuleInjectable $salesRule) + { + \PHPUnit_Framework_Assert::assertFalse( + $promoQuoteIndex->getPromoQuoteGrid()->isRowVisible(['name' => $salesRule->getName()]), + 'Sales rule \'' . $salesRule->getName() . '\' is present in cart price rules grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Sales rule is not present in cart price rules grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessDeleteMessage.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessDeleteMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..4c507b9605f409dbf1132308e66021b54ee994e3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessDeleteMessage.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert sales rule delte message. + */ +class AssertCartPriceRuleSuccessDeleteMessage extends AbstractConstraint +{ + /* tags */ + const SEVERITY = 'low'; + /* end tags */ + + const SUCCESS_DELETE_MESSAGE = 'The rule has been deleted.'; + + /** + * Assert that success message is displayed after sales rule delete. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @return void + */ + public function processAssert(PromoQuoteIndex $promoQuoteIndex) + { + $actualMessage = $promoQuoteIndex->getMessagesBlock()->getSuccessMessages(); + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_DELETE_MESSAGE, + $actualMessage, + 'Wrong success message is displayed.' + . "\nExpected: " . self::SUCCESS_DELETE_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Sales rule success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessSaveMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..409498a592682a5890945a2a9d979c631502f762 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleSuccessSaveMessage.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert sales rule save message. + */ +class AssertCartPriceRuleSuccessSaveMessage extends AbstractConstraint +{ + const SUCCESS_MESSAGE = 'The rule has been saved.'; + + /** + * Assert that success message is displayed after sales rule save. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @return void + */ + public function processAssert(PromoQuoteIndex $promoQuoteIndex) + { + $actualMessage = $promoQuoteIndex->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 the object. + * + * @return string + */ + public function toString() + { + return 'Sales rule success save message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertSalesRuleOnPrintOrder.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertSalesRuleOnPrintOrder.php new file mode 100644 index 0000000000000000000000000000000000000000..6c2afcd79bdc35b145038c8cd5311a3625c06e70 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertSalesRuleOnPrintOrder.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Constraint; + +use Magento\Sales\Test\Page\SalesGuestPrint; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that sales rule amount printed correctly on sales guest print page. + */ +class AssertSalesRuleOnPrintOrder extends AbstractConstraint +{ + /** + * Assert that sales rule amount printed correctly on sales guest print page. + * + * @param SalesGuestPrint $salesGuestPrint + * @param string $salesRuleDiscount + * @return void + */ + public function processAssert(SalesGuestPrint $salesGuestPrint, $salesRuleDiscount) + { + \PHPUnit_Framework_Assert::assertEquals( + $salesRuleDiscount, + $salesGuestPrint->getViewSalesRule()->getItemBlock()->getSalesRuleDiscount(), + "Sales rule amount not equals." + ); + } + + /** + * Returns a string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return "Sales rule amount was printed correctly."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml new file mode 100644 index 0000000000000000000000000000000000000000..25f432794e8432456a08e315988cfe84f60525fb --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture name="salesRuleInjectable" module="Magento_SalesRule" type="flat" entity_type="salesrule" collection="Magento\SalesRule\Model\Resource\Rule\Collection" repository_class="Magento\SalesRule\Test\Repository\SalesRuleInjectable" handler_interface="Magento\SalesRule\Test\Handler\SalesRuleInjectable\SalesRuleInjectableInterface" class="Magento\SalesRule\Test\Fixture\SalesRuleInjectable"> + <dataset name="default"> + <field name="name" xsi:type="string">Default price rule %isolation%</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + <item name="2" xsi:type="string">Wholesale</item> + <item name="3" xsi:type="string">Retailer</item> + </field> + <field name="coupon_type" xsi:type="string">No Coupon</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + </dataset> + <field name="rule_id" is_required="1" /> + <field name="name" group="rule_information"> + <default_value xsi:type="string">Default price rule %isolation%</default_value> + </field> + <field name="description" group="rule_information" /> + <field name="from_date" group="rule_information" source="Magento\Backend\Test\Fixture\Source\Date" /> + <field name="to_date" group="rule_information" source="Magento\Backend\Test\Fixture\Source\Date" /> + <field name="uses_per_customer" group="rule_information"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="is_active" group="rule_information"> + <default_value xsi:type="string">Active</default_value> + </field> + <field name="conditions_serialized" group="conditions" source="Magento\SalesRule\Test\Fixture\SalesRuleInjectable\ConditionsSerialized" /> + <field name="actions_serialized" group="actions" /> + <field name="stop_rules_processing" group="actions"> + <default_value xsi:type="string">1</default_value> + </field> + <field name="is_advanced"> + <default_value xsi:type="string">1</default_value> + </field> + <field name="product_ids" /> + <field name="sort_order" group="rule_information"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="simple_action" group="actions"> + <default_value xsi:type="string">Percent of product price discount</default_value> + </field> + <field name="discount_amount" group="actions"> + <default_value xsi:type="number">50</default_value> + </field> + <field name="discount_qty" group="actions" /> + <field name="discount_step" group="actions" /> + <field name="apply_to_shipping" group="actions"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="times_used"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="is_rss" group="rule_information"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="coupon_type" group="rule_information"> + <default_value xsi:type="string">No Coupon</default_value> + </field> + <field name="use_auto_generation" group="rule_information"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="uses_per_coupon" group="rule_information"> + <default_value xsi:type="number">0</default_value> + </field> + <field name="simple_free_shipping" group="actions" /> + <field name="id" /> + <field name="website_ids" group="rule_information"> + <default_value xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </default_value> + </field> + <field name="customer_group_ids" group="rule_information"> + <default_value xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + <item name="2" xsi:type="string">Wholesale</item> + <item name="3" xsi:type="string">Retailer</item> + </default_value> + </field> + <field name="store_labels" group="labels" /> + <field name="coupon_code" group="rule_information" /> + <field name="rule" /> + </fixture> +</config> 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/SalesRuleInjectable/ConditionsSerialized.php new file mode 100644 index 0000000000000000000000000000000000000000..4d9c65cff5333e179f7dc06f72f857f5da9baf54 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Fixture/SalesRuleInjectable/ConditionsSerialized.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Fixture\SalesRuleInjectable; + +use Magento\Mtf\Fixture\DataSource; + +/** + * Source for conditions serialized. + */ +class ConditionsSerialized extends DataSource +{ + /** + * Path to chooser grid class + * + * @var array + */ + protected $chooserGrid = []; + + /** + * Path to additional chooser grid class + * + * @var array + */ + protected $additionalChooserGrid = []; + + /** + * @constructor + * @param array $params + * @param string $data + */ + public function __construct(array $params, $data) + { + $this->chooserGrid = array_merge($this->chooserGrid, $this->additionalChooserGrid); + $this->params = $params; + foreach ($this->chooserGrid as $conditionsType => $chooserGrid) { + $data = preg_replace( + '#(' . preg_quote($conditionsType) . '\|.*?\|)([^\d].*?)#', + '${1}%' . $chooserGrid['class'] . '#' . $chooserGrid['field'] . '%${2}', + $data + ); + } + $this->data = $data; + } +} 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/SalesRuleInjectable/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..2543ccdf8197195b9cdbdc2bdb6444ef5903a784 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/Curl.php @@ -0,0 +1,195 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Handler\SalesRuleInjectable; + +use Magento\Backend\Test\Handler\Conditions; +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Util\Protocol\CurlInterface; +use Magento\Mtf\Util\Protocol\CurlTransport; +use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; + +/** + * Curl handler for creating sales rule. + */ +class Curl extends Conditions implements SalesRuleInjectableInterface +{ + /** + * Map of type parameter. + * + * @var array + */ + protected $mapTypeParams = [ + 'Subtotal' => [ + 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'attribute' => 'base_subtotal', + ], + 'Conditions combination' => [ + 'type' => 'Magento\SalesRule\Model\Rule\Condition\Combine', + 'aggregator' => 'all', + 'value' => '1', + ], + 'Shipping Country' => [ + 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'attribute' => 'country_id', + ], + 'Shipping Postcode' => [ + 'type' => 'Magento\SalesRule\Model\Rule\Condition\Address', + 'attribute' => 'postcode', + ], + 'Category' => [ + 'type' => 'Magento\SalesRule\Model\Rule\Condition\Product', + 'attribute' => 'category_ids', + ] + ]; + + /** + * Map of type additional parameter. + * + * @var array + */ + protected $additionalMapTypeParams = []; + + /** + * Mapping values for data. + * + * @var array + */ + protected $mappingData = [ + 'is_active' => [ + 'Active' => 1, + 'Inactive' => 0, + ], + 'coupon_type' => [ + 'No Coupon' => 1, + 'Specific Coupon' => 2, + 'Auto' => 3, + ], + 'is_rss' => [ + 'Yes' => 1, + 'No' => 2, + ], + 'simple_action' => [ + 'Percent of product price discount' => 'by_percent', + 'Fixed amount discount' => 'by_fixed', + 'Fixed amount discount for whole cart' => 'cart_fixed', + 'Buy X get Y free (discount amount is Y)' => 'buy_x_get_y', + ], + 'apply_to_shipping' => [ + 'Yes' => 1, + 'No' => 2, + ], + 'stop_rules_processing' => [ + 'Yes' => 1, + 'No' => 2, + ], + 'simple_free_shipping' => [ + 'No' => 0, + 'For matching items only' => 1, + 'For shipment with matching items' => 2, + ], + ]; + + /** + * Mapping values for Websites. + * + * @var array + */ + protected $websiteIds = [ + 'Main Website' => 1, + ]; + + /** + * Mapping values for customer group. + * + * @var array + */ + protected $customerIds = [ + 'NOT LOGGED IN' => 0, + 'General' => 1, + 'Wholesale' => 2, + 'Retailer' => 3, + ]; + + /** + * Post request for creating sales rule. + * + * @param FixtureInterface $fixture + * @return array + * @throws \Exception + */ + public function persist(FixtureInterface $fixture = null) + { + $this->mapTypeParams = array_merge($this->mapTypeParams, $this->additionalMapTypeParams); + $url = $_ENV['app_backend_url'] . 'sales_rule/promo_quote/save/'; + $data = $this->replaceMappingData($fixture->getData()); + $data['rule'] = []; + if (isset($data['conditions_serialized'])) { + $data['rule']['conditions'] = $this->prepareCondition($data['conditions_serialized']); + unset($data['conditions_serialized']); + } + + $data['website_ids'] = $this->prepareWebsites($data); + $data['customer_group_ids'] = $this->prepareCustomerGroup($data); + + if (isset($data['actions_serialized'])) { + $this->mapTypeParams['Conditions combination']['type'] = + 'Magento\SalesRule\Model\Rule\Condition\Product\Combine'; + $data['rule']['actions'] = $this->prepareCondition($data['actions_serialized']); + unset($data['actions_serialized']); + } + $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("Sales rule entity creating by curl handler was not successful! Response: $response"); + } + + preg_match('`<tr.*title=".*sales_rule\/promo_quote\/edit\/id\/([\d]+)`ims', $response, $matches); + if (empty($matches)) { + throw new \Exception('Cannot find Sales Rule id'); + } + + return ['id' => $matches[1]]; + } + + /** + * Prepare website data for curl. + * + * @param array $data + * @return array + */ + protected function prepareWebsites(array $data) + { + $websiteIds = []; + if (!empty($data['website_ids'])) { + foreach ($data['website_ids'] as $name) { + $websiteIds[] = isset($this->websiteIds[$name]) ? $this->websiteIds[$name] : $name; + } + } + + return $websiteIds; + } + + /** + * Prepare customer group data for curl. + * + * @param array $data + * @return array + */ + protected function prepareCustomerGroup(array $data) + { + $groupIds = []; + if (!empty($data['customer_group_ids'])) { + foreach ($data['customer_group_ids'] as $name) { + $groupIds[] = isset($this->customerIds[$name]) ? $this->customerIds[$name] : $name; + } + } + + return $groupIds; + } +} 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/SalesRuleInjectable/SalesRuleInjectableInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..0a9c2598e8c49b16841c1efd0fda60e4d1d1d248 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRuleInjectable/SalesRuleInjectableInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\Handler\SalesRuleInjectable; + +use Magento\Mtf\Handler\HandlerInterface; + +/** + * Interface SalesRuleInterface. + */ +interface SalesRuleInjectableInterface extends HandlerInterface +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml new file mode 100644 index 0000000000000000000000000000000000000000..23b3fe8d67b3aa5d93acb24f2f156893daff2730 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="PromoQuoteEdit" area="Adminhtml" mca="sales_rule/promo_quote/edit" module="Magento_SalesRule"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="salesRuleForm" class="Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\PromoQuoteForm" locator="[id='page:main-container']" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteIndex.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteIndex.xml new file mode 100644 index 0000000000000000000000000000000000000000..3c65c8a4ced63aff55114c7e1a47188d2539f65d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteIndex.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="PromoQuoteIndex" area="Adminhtml" mca="sales_rule/promo_quote/index" module="Magento_SalesRule"> + <block name="promoQuoteGrid" class="Magento\SalesRule\Test\Block\Adminhtml\Promo\Grid" locator="#promo_quote_grid" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + <block name="gridPageActions" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="systemMessageDialog" class="Magento\AdminNotification\Test\Block\System\Messages" locator='[role="dialog"].ui-popup-message' strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteNew.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteNew.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b2fa68cfa4f2d53f2babbba07dc8a99fe829bc0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteNew.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="PromoQuoteNew" area="Adminhtml" mca="sales_rule/promo_quote/new" module="Magento_SalesRule"> + <block name="salesRuleForm" class="Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\PromoQuoteForm" locator="[id='page:main-container']" strategy="css selector" /> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/SalesGuestPrint.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/SalesGuestPrint.xml new file mode 100644 index 0000000000000000000000000000000000000000..db17a5c1271975c0e2da482d7173f9d90e527724 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/SalesGuestPrint.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="SalesGuestPrint" mca="sales/guest/print"> + <block name="viewSalesRule" class="Magento\SalesRule\Test\Block\Order\View" locator=".order-details-items" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml new file mode 100644 index 0000000000000000000000000000000000000000..02d81f565a253de17ec04662a14bf162c330b256 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRuleInjectable.xml @@ -0,0 +1,176 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\SalesRule\Test\Repository\SalesRuleInjectable"> + <dataset name="active_sales_rule_with_percent_price_discount_coupon"> + <field name="name" xsi:type="string">Shopping Cart Price Rule with Specific Coupon %isolation%</field> + <field name="description" xsi:type="string">Description for Cart Price Rule</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + </field> + <field name="coupon_type" xsi:type="string">Specific Coupon</field> + <field name="coupon_code" xsi:type="string">123-abc-ABC-987-%isolation%</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + <field name="store_labels" xsi:type="array"> + <item name="0" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + <item name="1" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + </field> + </dataset> + + <dataset name="active_sales_rule_with_coupon_10"> + <field name="name" xsi:type="string">10% Off Coupon</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + </field> + <field name="coupon_type" xsi:type="string">Specific Coupon</field> + <field name="coupon_code" xsi:type="string">1234</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">10</field> + </dataset> + + <dataset name="active_sales_rule_with_fixed_price_discount_coupon"> + <field name="name" xsi:type="string">Shopping Cart Price Rule with Specific Coupon %isolation%</field> + <field name="description" xsi:type="string">Description for Cart Price Rule</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + </field> + <field name="coupon_type" xsi:type="string">Specific Coupon</field> + <field name="coupon_code" xsi:type="string">123-abc-ABC-987-%isolation%</field> + <field name="simple_action" xsi:type="string">Fixed amount discount</field> + <field name="discount_amount" xsi:type="string">50</field> + <field name="store_labels" xsi:type="array"> + <item name="0" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + <item name="1" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + </field> + </dataset> + + <dataset name="active_sales_rule_for_retailer"> + <field name="name" xsi:type="string">Shopping Cart Price Rule %isolation%</field> + <field name="description" xsi:type="string">Description for Cart Price Rule</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">Retailer</item> + </field> + <field name="coupon_type" xsi:type="string">No Coupon</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + <field name="stop_rules_processing" xsi:type="string">Yes</field> + </dataset> + + <dataset name="active_sales_rule_with_complex_conditions"> + <field name="name" xsi:type="string">Shopping Cart Price Rule with with complex conditions %isolation%</field> + <field name="description" xsi:type="string">Shopping Cart Price Rule with with complex conditions</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + <item name="2" xsi:type="string">Wholesale</item> + <item name="3" xsi:type="string">Retailer</item> + </field> + <field name="coupon_type" xsi:type="string">Specific Coupon</field> + <field name="coupon_code" xsi:type="string">123-abc-ABC-987-%isolation%</field> + <field name="uses_per_coupon" xsi:type="string">13</field> + <field name="uses_per_customer" xsi:type="string">63</field> + <field name="from_date" xsi:type="array"> + <item name="pattern" xsi:type="string">3/25/2014</item> + </field> + <field name="to_date" xsi:type="array"> + <item name="pattern" xsi:type="string">6/29/2024</item> + </field> + <field name="sort_order" xsi:type="string">1</field> + <field name="is_rss" xsi:type="string">Yes</field> + <field name="conditions_serialized" xsi:type="string">[Subtotal|is|300]{Conditions combination:[[Shipping Country|is|United States][Shipping Postcode|is|123456789a]]}</field> + <field name="actions_serialized" xsi:type="string">[Category|is|2]</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + <field name="discount_step" xsi:type="string">0</field> + <field name="apply_to_shipping" xsi:type="string">Yes</field> + <field name="stop_rules_processing" xsi:type="string">Yes</field> + <field name="simple_free_shipping" xsi:type="string">For matching items only</field> + <field name="store_labels" xsi:type="array"> + <item name="0" xsi:type="string">Shopping Cart Price Rule with with complex conditions</item> + <item name="1" xsi:type="string">Shopping Cart Price Rule with with complex conditions</item> + </field> + </dataset> + + <dataset name="inactive_sales_rule"> + <field name="name" xsi:type="string">Inactive Cart Price Rule %isolation%</field> + <field name="is_active" xsi:type="string">Inactive</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + </field> + <field name="coupon_type" xsi:type="string">No Coupon</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + </dataset> + + <dataset name="active_sales_rule_for_all_groups"> + <field name="name" xsi:type="string">Shopping Cart Price Rule with Specific Coupon %isolation%</field> + <field name="description" xsi:type="string">Description for Cart Price Rule</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + <item name="2" xsi:type="string">Wholesale</item> + <item name="3" xsi:type="string">Retailer</item> + </field> + <field name="coupon_type" xsi:type="string">Specific Coupon</field> + <field name="coupon_code" xsi:type="string">123-abc-ABC-987-%isolation%</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + <field name="store_labels" xsi:type="array"> + <item name="0" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + <item name="1" xsi:type="string">Shopping Cart price Rule with Specific Coupon</item> + </field> + </dataset> + + <dataset name="active_sales_rule_for_all_groups_no_coupon"> + <field name="name" xsi:type="string">Shopping Cart Price Rule with Specific Coupon %isolation%</field> + <field name="description" xsi:type="string">Description for Cart Price Rule</field> + <field name="is_active" xsi:type="string">Active</field> + <field name="website_ids" xsi:type="array"> + <item name="0" xsi:type="string">Main Website</item> + </field> + <field name="customer_group_ids" xsi:type="array"> + <item name="0" xsi:type="string">NOT LOGGED IN</item> + <item name="1" xsi:type="string">General</item> + <item name="2" xsi:type="string">Wholesale</item> + <item name="3" xsi:type="string">Retailer</item> + </field> + <field name="coupon_type" xsi:type="string">No Coupon</field> + <field name="simple_action" xsi:type="string">Percent of product price discount</field> + <field name="discount_amount" xsi:type="string">50</field> + </dataset> + </repository> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..24bafea36fbe42b87673f83accf39b5a70ddc666 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php @@ -0,0 +1,147 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestCase; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteNew; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestCase\Injectable; + +/** + * Precondition: + * 1. 2 sub categories in Default Category are created. + * 2. 2 simple products are created and assigned to different subcategories by one for each. + * 3. Default customer are created. + * + * Steps: + * 1. Login to backend as admin. + * 2. Navigate to MARKETING > Cart Price Rule. + * 3. Create Cart Price rule according to dataset and click "Save" button. + * 4. Perform asserts. + * + * @group Shopping_Cart_Price_Rules_(CS) + * @ZephyrId MAGETWO-24855 + */ +class CreateSalesRuleEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Page PromoQuoteNew. + * + * @var PromoQuoteNew + */ + protected $promoQuoteNew; + + /** + * Page PromoQuoteEdit. + * + * @var PromoQuoteEdit + */ + protected $promoQuoteEdit; + + /** + * Page PromoQuoteIndex. + * + * @var PromoQuoteIndex + */ + protected $promoQuoteIndex; + + /** + * Sales rule name. + * + * @var string + */ + protected $salesRuleName; + + /** + * Inject pages. + * + * @param PromoQuoteNew $promoQuoteNew + * @param PromoQuoteIndex $promoQuoteIndex + * @param PromoQuoteEdit $promoQuoteEdit + * @return void + */ + public function __inject( + PromoQuoteNew $promoQuoteNew, + PromoQuoteIndex $promoQuoteIndex, + PromoQuoteEdit $promoQuoteEdit + ) { + $this->promoQuoteNew = $promoQuoteNew; + $this->promoQuoteIndex = $promoQuoteIndex; + $this->promoQuoteEdit = $promoQuoteEdit; + } + + /** + * Create customer and 2 simple products with categories before run test. + * + * @param FixtureFactory $fixtureFactory + * @return array + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $customer = $fixtureFactory->createByCode('customer', ['dataSet' => 'default']); + $customer->persist(); + + $productForSalesRule1 = $fixtureFactory->createByCode( + 'catalogProductSimple', + ['dataSet' => 'simple_for_salesrule_1'] + ); + $productForSalesRule1->persist(); + + $productForSalesRule2 = $fixtureFactory->createByCode( + 'catalogProductSimple', + ['dataSet' => 'simple_for_salesrule_2'] + ); + $productForSalesRule2->persist(); + + return [ + 'customer' => $customer, + 'productForSalesRule1' => $productForSalesRule1, + 'productForSalesRule2' => $productForSalesRule2 + ]; + } + + /** + * Create Sales Rule Entity. + * + * @param SalesRuleInjectable $salesRule + * @return void + */ + public function testCreateSalesRule(SalesRuleInjectable $salesRule) + { + // Preconditions + $this->salesRuleName = $salesRule->getName(); + + // Steps + $this->promoQuoteNew->open(); + $this->promoQuoteNew->getSalesRuleForm()->fill($salesRule); + $this->promoQuoteNew->getFormPageActions()->save(); + } + + /** + * Delete current sales rule. + * + * @return void + */ + public function tearDown() + { + $filter = [ + 'name' => $this->salesRuleName, + ]; + + $this->promoQuoteIndex->open(); + $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); + $this->promoQuoteEdit->getFormPageActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..0ff2064ad79fba1554e4e82552471a3c81422704 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\SalesRule\Test\TestCase\CreateSalesRuleEntityTest"> + <variation name="CreateSalesRuleEntityTestVariation1"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule1 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Sales Cart Rule labels</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation2"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule2 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">Specific Coupon</data> + <data name="salesRule/data/coupon_code" xsi:type="string">1A2B3C-456-zxc-%isolation%</data> + <data name="salesRule/data/simple_action" xsi:type="string">Fixed amount discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">35</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Coupon code+fixed amount discount</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">2</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation3"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule3 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">Specific Coupon</data> + <data name="salesRule/data/coupon_code" xsi:type="string">Lorem ipsum dolor sit amet, consectetur adipiscing elit - %isolation%</data> + <data name="salesRule/data/simple_action" xsi:type="string">Fixed amount discount for whole cart</data> + <data name="salesRule/data/discount_amount" xsi:type="string">60</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Coupon code+Fixed amount discount for whole cart</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">3</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation4"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule4 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">Specific Coupon</data> + <data name="salesRule/data/coupon_code" xsi:type="string">1A2B3C-456-zxc-%isolation%</data> + <data name="salesRule/data/simple_action" xsi:type="string">Buy X get Y free (discount amount is Y)</data> + <data name="salesRule/data/discount_amount" xsi:type="string">1</data> + <data name="salesRule/data/discount_step" xsi:type="string">3</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Buy X get Y free</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">4</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation5"> + <data name="isLoggedIn" xsi:type="string">1</data> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule5 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">General</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/discount_qty" xsi:type="string">2</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">3</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation6"> + <data name="address/data/country_id" xsi:type="string">United States</data> + <data name="address/data/region_id" xsi:type="string">California</data> + <data name="address/data/postcode" xsi:type="string">95814</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule6 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">Yes</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Apply discount to Shipping Amount</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <data name="productQuantity/productForSalesRule2" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation7"> + <data name="address/data/country_id" xsi:type="string">United States</data> + <data name="address/data/region_id" xsi:type="string">California</data> + <data name="address/data/postcode" xsi:type="string">95814</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule7 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">For matching items only</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Free Shipping in conditions</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <data name="productQuantity/productForSalesRule2" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleFreeShippingIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation8"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule8 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">[Subtotal|is|150]</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Sales Cart Rule labels</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <data name="productQuantity/productForSalesRule2" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation9"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule9 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">[Subtotal|is|150]</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Subtotal Action-Condition test</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">2</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsNotApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation10"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule10 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">[Total Items Quantity|is|2]</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Total Items Quantity is 2</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">2</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation11"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule11 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">[Total Weight|is|150]</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Total Weight is 150</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <data name="productQuantity/productForSalesRule2" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation12"> + <data name="address/data/country_id" xsi:type="string">United States</data> + <data name="address/data/region_id" xsi:type="string">California</data> + <data name="address/data/postcode" xsi:type="string">95814</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule12 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">{Conditions combination:[[Shipping Method|is|\[flatrate\] Fixed][Shipping Postcode|is|95814][Shipping State/Province|is|California][Shipping Country|is|United States]]}</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Rule applied conditions combination</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <data name="productQuantity/productForSalesRule2" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + <variation name="CreateSalesRuleEntityTestVariation13"> + <data name="salesRule/data/name" xsi:type="string">Shopping Cart Price Rule13 %isolation%</data> + <data name="salesRule/data/description" xsi:type="string">Shopping Cart Price Rule Description %isolation%</data> + <data name="salesRule/data/is_active" xsi:type="string">Active</data> + <data name="salesRule/data/website_ids/website_0" xsi:type="string">Main Website</data> + <data name="salesRule/data/customer_group_ids/group_0" xsi:type="string">NOT LOGGED IN</data> + <data name="salesRule/data/coupon_type" xsi:type="string">No Coupon</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">{Product attribute combination:[Attribute Set|is|Default]}</data> + <data name="salesRule/data/simple_action" xsi:type="string">Percent of product price discount</data> + <data name="salesRule/data/discount_amount" xsi:type="string">50</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="salesRule/data/simple_free_shipping" xsi:type="string">No</data> + <data name="salesRule/data/store_labels/store_labels_0" xsi:type="string">Product attribute discount</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">1</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied" /> + </variation> + </testCase> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..49f3e7655790d8cf6ec4842d2861cc55692e5a72 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestCase; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\TestCase\Injectable; + +/** + * Precondition: + * 1. Several Shopping Cart Price Rules are created. + * + * Steps: + * 1. Login to backend. + * 2. Navigate to MARKETING > Cart Price Rules. + * 3. Open from grid test Rule. + * 4. Click 'Delete' button. + * 5. Perform asserts. + * + * @group Shopping_Cart_Price_Rules_(CS) + * @ZephyrId MAGETWO-24985 + */ +class DeleteSalesRuleEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Page PromoQuoteEdit. + * + * @var PromoQuoteEdit + */ + protected $promoQuoteEdit; + + /** + * Page PromoQuoteIndex. + * + * @var PromoQuoteIndex + */ + protected $promoQuoteIndex; + + /** + * Inject pages. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @param PromoQuoteEdit $promoQuoteEdit + */ + public function __inject( + PromoQuoteIndex $promoQuoteIndex, + PromoQuoteEdit $promoQuoteEdit + ) { + $this->promoQuoteIndex = $promoQuoteIndex; + $this->promoQuoteEdit = $promoQuoteEdit; + } + + /** + * Delete Sales Rule Entity. + * + * @param SalesRuleInjectable $salesRule + * @return void + */ + public function testDeleteSalesRule(SalesRuleInjectable $salesRule) + { + // Preconditions + $salesRule->persist(); + + // Steps + $this->promoQuoteIndex->open(); + $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $salesRule->getName()]); + $this->promoQuoteEdit->getFormPageActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..2d76e09d87b8cdfb29e6b3b8b1ca4236a4a9a3dd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\SalesRule\Test\TestCase\DeleteSalesRuleEntityTest"> + <variation name="DeleteSalesRuleEntityTestVariation1"> + <data name="salesRule/dataSet" xsi:type="string">active_sales_rule_with_percent_price_discount_coupon</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessDeleteMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleIsNotPresentedInGrid" /> + </variation> + <variation name="DeleteSalesRuleEntityTestVariation2"> + <data name="salesRule/dataSet" xsi:type="string">active_sales_rule_with_complex_conditions</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessDeleteMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleIsNotPresentedInGrid" /> + </variation> + <variation name="DeleteSalesRuleEntityTestVariation3"> + <data name="salesRule/dataSet" xsi:type="string">inactive_sales_rule</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessDeleteMessage" /> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleIsNotPresentedInGrid" /> + </variation> + </testCase> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..ed72d923f05b1911611a38244d9f5e2b79c5d669 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php @@ -0,0 +1,132 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestCase; + +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestCase\Injectable; + +/** + * Precondition: + * 1. Cart Price Rule is created. + * + * Steps: + * 1. Login to backend. + * 2. Navigate to MARKETING > Cart Price Rules. + * 3. Click Cart Price Rule from grid. + * 4. Edit test value(s) according to dataset. + * 5. Click 'Save' button. + * 6. Perform asserts. + * + * @group Shopping_Cart_Price_Rules_(CS) + * @ZephyrId MAGETWO-24860 + */ +class UpdateSalesRuleEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TO_MAINTAIN = 'yes'; + /* end tags */ + + /** + * Page PromoQuoteEdit. + * + * @var PromoQuoteEdit + */ + protected $promoQuoteEdit; + + /** + * Page PromoQuoteIndex. + * + * @var PromoQuoteIndex + */ + protected $promoQuoteIndex; + + /** + * Sales rule name. + * + * @var string + */ + protected $salesRuleName; + + /** + * Create simple product with category. + * + * @param FixtureFactory $fixtureFactory + * @return array + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $productForSalesRule1 = $fixtureFactory->createByCode( + 'catalogProductSimple', + ['dataSet' => 'simple_for_salesrule_1'] + ); + $productForSalesRule1->persist(); + return [ + 'productForSalesRule1' => $productForSalesRule1, + ]; + } + + /** + * Inject pages. + * + * @param PromoQuoteIndex $promoQuoteIndex + * @param PromoQuoteEdit $promoQuoteEdit + * @return void + */ + public function __inject( + PromoQuoteIndex $promoQuoteIndex, + PromoQuoteEdit $promoQuoteEdit + ) { + $this->promoQuoteIndex = $promoQuoteIndex; + $this->promoQuoteEdit = $promoQuoteEdit; + } + + /** + * Update Sales Rule Entity. + * + * @param SalesRuleInjectable $salesRule + * @param SalesRuleInjectable $salesRuleOrigin + * @return void + */ + public function testUpdateSalesRule( + SalesRuleInjectable $salesRule, + SalesRuleInjectable $salesRuleOrigin + ) { + // Preconditions + $salesRuleOrigin->persist(); + $filter = [ + 'name' => $salesRuleOrigin->getName(), + ]; + $this->salesRuleName = $salesRule->hasData('name') ? $salesRule->getName() : $salesRuleOrigin->getName(); + + // Steps + $this->promoQuoteIndex->open(); + $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); + $this->promoQuoteEdit->getSalesRuleForm()->fill($salesRule); + $this->promoQuoteEdit->getFormPageActions()->save(); + } + + /** + * Delete current sales rule. + * + * @return void + */ + public function tearDown() + { + $filter = [ + 'name' => $this->salesRuleName, + ]; + + $this->promoQuoteIndex->open(); + $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); + $this->promoQuoteEdit->getFormPageActions()->delete(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..f4f2c01eeccecd1c2ca4136cf63606d93f27d4ca --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\SalesRule\Test\TestCase\UpdateSalesRuleEntityTest"> + <variation name="UpdateSalesRuleEntityTestVariation1"> + <data name="salesRuleOrigin/dataSet" xsi:type="string">active_sales_rule_with_complex_conditions</data> + <data name="salesRule/data/conditions_serialized" xsi:type="string">{Conditions combination:[[Shipping Method|is|\[flatrate\] Fixed][Shipping Postcode|is|95814][Shipping State/Province|is|California][Shipping Country|is|United States]]}</data> + <data name="salesRule/data/simple_action" xsi:type="string">Buy X get Y free (discount amount is Y)</data> + <data name="salesRule/data/discount_amount" xsi:type="string">1</data> + <data name="salesRule/data/discount_step" xsi:type="string">3</data> + <data name="salesRule/data/apply_to_shipping" xsi:type="string">No</data> + <data name="productQuantity/productForSalesRule1" xsi:type="string">4</data> + <data name="address/data/country_id" xsi:type="string">United States</data> + <data name="address/data/region_id" xsi:type="string">California</data> + <data name="address/data/postcode" xsi:type="string">95814</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleSuccessSaveMessage"/> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleForm"/> + <constraint name="Magento\SalesRule\Test\Constraint\AssertCartPriceRuleConditionIsApplied"/> + </variation> + </testCase> +</config> 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 new file mode 100644 index 0000000000000000000000000000000000000000..7e193a4d0ab1cc570bbbebad6dedda8c57946c6d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnBackendStep.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestStep; + +use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex; +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Apply Sales Rule on backend. + */ +class ApplySalesRuleOnBackendStep implements TestStepInterface +{ + /** + * Order Create Index. + * + * @var OrderCreateIndex + */ + protected $orderCreateIndex; + + /** + * SalesRule fixture. + * + * @var SalesRuleInjectable + */ + protected $salesRule; + + /** + * @constructor + * @param OrderCreateIndex $orderCreateIndex + * @param SalesRuleInjectable $salesRule + */ + public function __construct(OrderCreateIndex $orderCreateIndex, SalesRuleInjectable $salesRule = null) + { + $this->orderCreateIndex = $orderCreateIndex; + $this->salesRule = $salesRule; + } + + /** + * Apply gift card before one page checkout. + * + * @return void + */ + public function run() + { + if ($this->salesRule !== null) { + $this->orderCreateIndex->getCouponsBlock()->applyCouponCode($this->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 new file mode 100644 index 0000000000000000000000000000000000000000..6bff54ec11dee9b17a78f52478fff86e8652457d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestStep; + +use Magento\Checkout\Test\Page\CheckoutCart; +use Magento\SalesRule\Test\Fixture\SalesRuleInjectable; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Apply Sales Rule before one page checkout. + */ +class ApplySalesRuleOnFrontendStep implements TestStepInterface +{ + /** + * Checkout cart page. + * + * @var CheckoutCart + */ + protected $checkoutCart; + + /** + * SalesRule fixture. + * + * @var SalesRuleInjectable + */ + protected $salesRule; + + /** + * @constructor + * @param CheckoutCart $checkoutCart + * @param SalesRuleInjectable $salesRule + */ + public function __construct(CheckoutCart $checkoutCart, SalesRuleInjectable $salesRule = null) + { + $this->checkoutCart = $checkoutCart; + $this->salesRule = $salesRule; + } + + /** + * Apply coupon before one page checkout. + * + * @return void + */ + public function run() + { + if ($this->salesRule !== null) { + $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($this->salesRule->getCouponCode()); + } + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..c458bed8659ad8e8b3d2d381a1601ecfade3e163 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestStep; + +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Creating sales rule. + */ +class CreateSalesRuleStep implements TestStepInterface +{ + /** + * Sales Rule coupon. + * + * @var string + */ + protected $salesRule; + + /** + * Factory for Fixture. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Preparing step properties. + * + * @constructor + * @param FixtureFactory $fixtureFactory + * @param string $salesRule + */ + public function __construct(FixtureFactory $fixtureFactory, $salesRule = null) + { + $this->fixtureFactory = $fixtureFactory; + $this->salesRule = $salesRule; + } + + /** + * Create sales rule. + * + * @return array + */ + public function run() + { + $result['salesRule'] = null; + if ($this->salesRule !== null) { + $salesRule = $this->fixtureFactory->createByCode( + 'salesRuleInjectable', + ['dataSet' => $this->salesRule] + ); + $salesRule->persist(); + $result['salesRule'] = $salesRule; + } + + return $result; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..0141a0506fd6e926987234027c894c7462c01245 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\SalesRule\Test\TestStep; + +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteEdit; +use Magento\SalesRule\Test\Page\Adminhtml\PromoQuoteIndex; +use Magento\Mtf\TestStep\TestStepInterface; + +/** + * Delete all Sales Rule on backend. + */ +class DeleteAllSalesRuleStep implements TestStepInterface +{ + /** + * Promo Quote index page. + * + * @var PromoQuoteIndex + */ + protected $promoQuoteIndex; + + /** + * Promo Quote edit page. + * + * @var PromoQuoteEdit + */ + protected $promoQuoteEdit; + + /** + * @construct + * @param PromoQuoteIndex $promoQuoteIndex + * @param PromoQuoteEdit $promoQuoteEdit + */ + public function __construct( + PromoQuoteIndex $promoQuoteIndex, + PromoQuoteEdit $promoQuoteEdit + ) { + $this->promoQuoteIndex = $promoQuoteIndex; + $this->promoQuoteEdit = $promoQuoteEdit; + } + + /** + * Delete Sales Rule on backend. + * + * @return array + */ + public function run() + { + $this->promoQuoteIndex->open(); + while ($this->promoQuoteIndex->getPromoQuoteGrid()->isFirstRowVisible()) { + $this->promoQuoteIndex->getPromoQuoteGrid()->openFirstRow(); + $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteIndex->getSystemMessageDialog()->closePopup(); + } + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..2591249e9e02850c5123b9c66a0652a7bd5cfa00 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/curl/di.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> + <preference for="Magento\SalesRule\Test\Handler\SalesRuleInjectable\SalesRuleInjectableInterface" type="\Magento\SalesRule\Test\Handler\SalesRuleInjectable\Curl" /> +</config> diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/testcase.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee5c69ad94715ea590bd880b56e73c54d815872e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/etc/testcase.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> + <scenario name="OnePageCheckoutTest"> + <step name="createSalesRule" module="Magento_SalesRule" prev="estimateShippingAndTax" next="applySalesRuleOnFrontend"/> + <step name="applySalesRuleOnFrontend" module="Magento_SalesRule" prev="createSalesRule" next="proceedToCheckout"/> + </scenario> + <scenario name="ReorderOrderEntityTest"> + <step name="createSalesRule" module="Magento_SalesRule" next="applySalesRuleOnBackend"/> + <step name="applySalesRuleOnBackend" module="Magento_SalesRule" next="fillBillingAddress"/> + </scenario> + <scenario name="CreateOrderBackendTest"> + <step name="createSalesRule" module="Magento_SalesRule" next="applySalesRuleOnBackend"/> + <step name="applySalesRuleOnBackend" module="Magento_SalesRule" next="fillBillingAddress"/> + </scenario> + <scenario name="CreateOrderFromCustomerPageTest"> + <step name="createSalesRule" module="Magento_SalesRule" next="openCustomerOnBackend"/> + <step name="applySalesRuleOnBackend" module="Magento_SalesRule" next="fillBillingAddress"/> + </scenario> + <scenario name="PrintOrderFrontendGuestTest"> + <step name="createSalesRule" module="Magento_SalesRule" next="applySalesRuleOnBackend"/> + <step name="applySalesRuleOnBackend" module="Magento_SalesRule" next="fillBillingAddress"/> + </scenario> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php new file mode 100644 index 0000000000000000000000000000000000000000..01c8abab19d6a8456a07e91145ce901957609c86 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php @@ -0,0 +1,81 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Shipping\Test\Block\Adminhtml; + +use Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm; +use Magento\Shipping\Test\Block\Adminhtml\Form\Items; +use Magento\Shipping\Test\Block\Adminhtml\Order\Tracking; + +/** + * Shipment create form. + */ +class Form extends AbstractForm +{ + /** + * Items block css selector. + * + * @var string + */ + protected $items = '#ship_items_container'; + + /** + * Tracking block css selector. + * + * @var string + */ + protected $tracking = '#tracking_numbers_table'; + + /** + * Get items block. + * + * @return Items + */ + protected function getItemsBlock() + { + return $this->blockFactory->create( + 'Magento\Shipping\Test\Block\Adminhtml\Form\Items', + ['element' => $this->_rootElement->find($this->items)] + ); + } + + /** + * Get tracking block. + * + * @return Tracking + */ + protected function getTrackingBlock() + { + return $this->blockFactory->create( + 'Magento\Shipping\Test\Block\Adminhtml\Order\Tracking', + ['element' => $this->_rootElement->find($this->tracking)] + ); + } + + /** + * Fill form data. + * + * @param array $data + * @param array|null $products [optional] + * @return void + */ + public function fillData(array $data, $products = null) + { + $data = $this->prepareData($data); + if (isset($data['form_data'])) { + if (isset($data['form_data']['tracking'])) { + $this->getTrackingBlock()->fill($data['form_data']['tracking']); + unset($data['form_data']['tracking']); + } + $this->_fill($this->dataMapping($data['form_data'])); + } + if (isset($data['items_data']) && $products !== null) { + foreach ($products as $key => $product) { + $this->getItemsBlock()->getItemProductBlock($product)->fillProduct($data['items_data'][$key]); + } + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml new file mode 100644 index 0000000000000000000000000000000000000000..7e75ac518b8e7a2e66c38e5d9798c220d281e39f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <wrapper>creditmemo</wrapper> + <fields> + <comment_text /> + <shipping_amount /> + <adjustment_positive /> + <adjustment_negative /> + <comment_customer_notify> + <input>checkbox</input> + </comment_customer_notify> + <send_email> + <input>checkbox</input> + </send_email> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php new file mode 100644 index 0000000000000000000000000000000000000000..64b61d1a5ef7bcf90f1bc0712c5101e16287d41c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Shipping\Test\Block\Adminhtml\Form; + +use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItemsNewBlock; +use Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product; +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; + +/** + * Adminhtml items to ship block. + */ +class Items extends AbstractItemsNewBlock +{ + /** + * Get item product block. + * + * @param FixtureInterface $product + * @return Product + */ + public function getItemProductBlock(FixtureInterface $product) + { + $selector = sprintf($this->productItem, $product->getSku()); + return $this->blockFactory->create( + 'Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product', + ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] + ); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.php new file mode 100644 index 0000000000000000000000000000000000000000..ea14abdae485087e28c4eb728e8273161fb426b7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Shipping\Test\Block\Adminhtml\Form\Items; + +/** + * Item product form on shipment items block. + */ +class Product extends \Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Product +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.xml new file mode 100644 index 0000000000000000000000000000000000000000..c7fff42f107e3901ca16dc791b77a27194229976 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items/Product.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <fields> + <qty> + <selector>input.qty-item</selector> + </qty> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4391265ca5bb52050392431e47f82ae69c2fbd1c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Shipping\Test\TestCase; + +use Magento\Sales\Test\Fixture\OrderInjectable; +use Magento\Mtf\TestCase\Injectable; + +/** + * Preconditions: + * 1. Enable payment method "Check/Money Order". + * 2. Enable shipping method one of "Flat Rate/Free Shipping". + * 3. Create order. + * + * Steps: + * 1. Go to Sales > Orders. + * 2. Select created order in the grid and open it. + * 3. Click 'Ship' button. + * 4. Fill data according to dataSet. + * 5. Click 'Submit Shipment' button. + * 6. Perform all asserts. + * + * @group Order_Management_(CS) + * @ZephyrId MAGETWO-28708 + */ +class CreateShipmentEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Set up configuration. + * + * @return void + */ + public function __prepare() + { + $this->objectManager->create( + 'Magento\Config\Test\TestStep\SetupConfigurationStep', + ['configData' => "checkmo,flatrate"] + )->run(); + } + + /** + * Create shipment. + * + * @param OrderInjectable $order + * @param array $data + * @return array + */ + public function test(OrderInjectable $order, array $data) + { + // Preconditions + $order->persist(); + + // Steps + $createShipping = $this->objectManager->create( + 'Magento\Sales\Test\TestStep\CreateShipmentStep', + ['order' => $order, 'data' => $data] + ); + + return ['ids' => $createShipping->run()]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..aeb61fe1fc158c20a7d238ef8487dd56417c255d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Shipping\Test\TestCase\CreateShipmentEntityTest"> + <variation name="CreateShipmentEntityTestVariation1"> + <data name="description" xsi:type="string">shipment with tracking number</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::default</data> + <data name="order/data/total_qty_ordered/0" xsi:type="string">1</data> + <data name="data/items_data/0/qty" xsi:type="string">-</data> + <data name="data/form_data/comment_text" xsi:type="string">comments for shipment</data> + <data name="data/form_data/tracking/0/carrier_code" xsi:type="string">Custom Value</data> + <data name="data/form_data/tracking/0/title" xsi:type="string">title</data> + <data name="data/form_data/tracking/0/number" xsi:type="string">199</data> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentInShipmentsTab" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentInShipmentsGrid" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentItems" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertNoShipButton" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipTotalQuantity" /> + </variation> + <variation name="CreateShipmentEntityTestVariation2"> + <data name="description" xsi:type="string">partial shipment</data> + <data name="order/dataSet" xsi:type="string">default</data> + <data name="order/data/entity_id/products" xsi:type="string">catalogProductSimple::product_100_dollar</data> + <data name="order/data/total_qty_ordered/0" xsi:type="string">1</data> + <data name="data/items_data/0/qty" xsi:type="string">1</data> + <data name="data/form_data/comment_text" xsi:type="string">comments for shipment</data> + <data name="data/form_data/tracking/0/carrier_code" xsi:type="string">-</data> + <data name="data/form_data/tracking/0/title" xsi:type="string">-</data> + <data name="data/form_data/tracking/0/number" xsi:type="string">-</data> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentSuccessCreateMessage" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentInShipmentsTab" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentInShipmentsGrid" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipmentItems" /> + <constraint name="Magento\Shipping\Test\Constraint\AssertShipTotalQuantity" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php index 64ec7938f66cdaa860638795869c3e55997f3b49..227831ea819eae4d3844f1354e69a6dd8f79786e 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductsToCartFromCustomerWishlistOnFrontendTest.php @@ -10,8 +10,6 @@ use Magento\Checkout\Test\Fixture\Cart; use Magento\Customer\Test\Fixture\Customer; /** - * Test Flow: - * * Preconditions: * 1. Create customer and login to frontend * 2. Create products @@ -43,7 +41,6 @@ class AddProductsToCartFromCustomerWishlistOnFrontendTest extends AbstractWishli */ public function test(Customer $customer, $products, $qty) { - $this->markTestIncomplete('Bug: MAGETWO-34757'); // Preconditions $customer->persist(); $this->loginCustomer($customer); @@ -71,11 +68,13 @@ class AddProductsToCartFromCustomerWishlistOnFrontendTest extends AbstractWishli $productBlock = $this->wishlistIndex->getWishlistBlock()->getProductItemsBlock(); foreach ($products as $product) { $this->cmsIndex->getLinksBlock()->openLink("My Wish List"); + $this->cmsIndex->getCmsPageBlock()->waitPageInit(); if ($qty != '-') { $productBlock->getItemProduct($product)->fillProduct(['qty' => $qty]); $this->wishlistIndex->getWishlistBlock()->clickUpdateWishlist(); } $productBlock->getItemProduct($product)->clickAddToCart(); + $this->cmsIndex->getCmsPageBlock()->waitPageInit(); if (!$this->wishlistIndex->getWishlistBlock()->isVisible()) { $this->catalogProductView->getViewBlock()->addToCart($product); $this->catalogProductView->getMessagesBlock()->waitSuccessMessage(); 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 fe86f41997e58a8a52dbabf86db8742cbcf7c600..066996237682324629b01255adc02af4a05a67af 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 @@ -6,54 +6,59 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Wishlist\Test\TestCase\AddProductsToCartFromCustomerWishlistOnFrontendTest"> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation1" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">catalogProductSimple::product_100_dollar</data> - <data name="qty" xsi:type="string">2</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation2" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">catalogProductVirtual::product_50_dollar</data> - <data name="qty" xsi:type="string">1</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation3" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">catalogProductSimple::default,catalogProductVirtual::product_50_dollar,catalogProductSimple::default,catalogProductVirtual::product_50_dollar</data> - <data name="qty" xsi:type="string">-</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertWishlistIsEmpty"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertWishlistIsEmpty" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation4" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">groupedProduct::three_simple_products</data> - <data name="qty" xsi:type="string">-</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation5" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">downloadableProduct::with_two_separately_links</data> - <data name="qty" xsi:type="string">-</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation6" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">configurableProduct::default</data> - <data name="qty" xsi:type="string">3</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation7" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">bundleProduct::bundle_dynamic_product</data> - <data name="qty" xsi:type="string">2</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation8" firstConstraint="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" method="test"> - <data name="products" xsi:type="string">bundleProduct::bundle_fixed_product</data> - <data name="qty" xsi:type="string">2</data> - <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" next="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist"/> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" prev="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"/> - </variation> - </testCase> + <testCase name="Magento\Wishlist\Test\TestCase\AddProductsToCartFromCustomerWishlistOnFrontendTest"> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation1"> + <data name="products" xsi:type="string">catalogProductSimple::product_100_dollar</data> + <data name="qty" xsi:type="string">2</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation2"> + <data name="products" xsi:type="string">catalogProductVirtual::product_50_dollar</data> + <data name="qty" xsi:type="string">1</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation3"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36215</data> + <data name="products" xsi:type="string">catalogProductSimple::default,catalogProductVirtual::product_50_dollar,catalogProductSimple::default,catalogProductVirtual::product_50_dollar</data> + <data name="qty" xsi:type="string">-</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertWishlistIsEmpty" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation4"> + <data name="products" xsi:type="string">groupedProduct::three_simple_products_default_qty</data> + <data name="qty" xsi:type="string">-</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation5"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36224</data> + <data name="products" xsi:type="string">downloadableProduct::with_two_separately_links</data> + <data name="qty" xsi:type="string">-</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation6"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36224</data> + <data name="products" xsi:type="string">configurableProduct::default</data> + <data name="qty" xsi:type="string">3</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation7"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36224</data> + <data name="products" xsi:type="string">bundleProduct::bundle_dynamic_product</data> + <data name="qty" xsi:type="string">2</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + <variation name="AddProductsToCartFromCustomerWishlistOnFrontendTestVariation8"> + <data name="issue" xsi:type="string">Bug: MAGETWO-36224</data> + <data name="products" xsi:type="string">bundleProduct::bundle_fixed_product</data> + <data name="qty" xsi:type="string">2</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart" /> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductsIsAbsentInWishlist" /> + </variation> + </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.xml index 3894fece0c5d382961acbf9d1c8cd52c88e46177..0c7a970f47d1b3d68bfc5295ef76dd55c8fcbc54 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.xml @@ -6,26 +6,26 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> - <testCase name="Magento\Wishlist\Test\TestCase\ConfigureProductInCustomerWishlistOnBackendTest"> - <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation1" firstConstraint="Magento\Wishlist\Test\Constraint\AssertProductInCustomerWishlistOnBackendGrid" method="test"> - <data name="product" xsi:type="string">catalogProductSimple::with_two_custom_option</data> - <constraint name="Magento\Wishlist\Test\Constraint\AssertProductInCustomerWishlistOnBackendGrid"/> - </variation> - <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation2" firstConstraint="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInCustomerWishlistOnBackendGrid" method="test"> - <data name="product" xsi:type="string">configurableProduct::default</data> - <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInCustomerWishlistOnBackendGrid"/> - </variation> - <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation3" firstConstraint="Magento\Bundle\Test\Constraint\AssertBundleProductInCustomerWishlistOnBackendGrid" method="test"> - <data name="product" xsi:type="string">bundleProduct::bundle_dynamic_product</data> - <constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductInCustomerWishlistOnBackendGrid"/> - </variation> - <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation4" firstConstraint="Magento\Downloadable\Test\Constraint\AssertDownloadableProductInCustomerWishlistOnBackendGrid" method="test"> - <data name="product" xsi:type="string">downloadableProduct::with_two_separately_links</data> - <constraint name="Magento\Downloadable\Test\Constraint\AssertDownloadableProductInCustomerWishlistOnBackendGrid"/> - </variation> - <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation5" firstConstraint="Magento\GroupedProduct\Test\Constraint\AssertGroupedProductInCustomerWishlistOnBackendGrid" method="test"> - <data name="product" xsi:type="string">groupedProduct::three_simple_products</data> - <constraint name="Magento\GroupedProduct\Test\Constraint\AssertGroupedProductInCustomerWishlistOnBackendGrid"/> - </variation> - </testCase> + <testCase name="Magento\Wishlist\Test\TestCase\ConfigureProductInCustomerWishlistOnBackendTest"> + <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation1"> + <data name="product" xsi:type="string">catalogProductSimple::with_two_custom_option</data> + <constraint name="Magento\Wishlist\Test\Constraint\AssertProductInCustomerWishlistOnBackendGrid" /> + </variation> + <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation2"> + <data name="product" xsi:type="string">configurableProduct::default</data> + <constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductInCustomerWishlistOnBackendGrid" /> + </variation> + <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation3"> + <data name="product" xsi:type="string">bundleProduct::bundle_dynamic_product</data> + <constraint name="Magento\Bundle\Test\Constraint\AssertBundleProductInCustomerWishlistOnBackendGrid" /> + </variation> + <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation4"> + <data name="product" xsi:type="string">downloadableProduct::with_two_separately_links</data> + <constraint name="Magento\Downloadable\Test\Constraint\AssertDownloadableProductInCustomerWishlistOnBackendGrid" /> + </variation> + <variation name="ConfigureProductInCustomerWishlistOnBackendTestVariation5"> + <data name="product" xsi:type="string">groupedProduct::three_simple_products</data> + <constraint name="Magento\GroupedProduct\Test\Constraint\AssertGroupedProductInCustomerWishlistOnBackendGrid" /> + </variation> + </testCase> </config>