From e6342cbbc572c29d5d12dcba8a77ec0fef740420 Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Fri, 22 Jul 2016 16:56:36 +0300 Subject: [PATCH 01/21] MAGETWO-55327: [FT] Filter not applied on current page in test. --- .../Review/Test/Block/Adminhtml/Product/Grid.php | 11 +++++++++-- .../Review/Test/Block/Adminhtml/ReviewForm.xml | 2 +- .../TestCase/CreateProductReviewBackendEntityTest.php | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Grid.php index 55060e7a85db9..e1aa3b9d5a9a5 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Grid.php @@ -6,13 +6,20 @@ namespace Magento\Review\Test\Block\Adminhtml\Product; -use Magento\Ui\Test\Block\Adminhtml\DataGrid; +use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; /** * Review catalog product grid. */ -class Grid extends DataGrid +class Grid extends AbstractGrid { + /** + * First row selector + * + * @var string + */ + protected $firstRowSelector = './/tbody/tr[1]'; + /** * Grid filter selectors * diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.xml index 1832618a7da64..348cd3429149a 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/ReviewForm.xml @@ -20,7 +20,7 @@ textarea - #detailed_rating + #rating_detail Magento\Review\Test\Block\Adminhtml\Edit\RatingElement diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php index d7de5f52103d8..aa8e9d5dc8146 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php @@ -110,13 +110,14 @@ public function test(Review $review) { // Precondition: $product = $review->getDataFieldConfig('entity_id')['source']->getEntity(); - $filter = ['id' => $product->getId()]; + $filter = ['sku' => $product->getSku()]; $this->review = $review; // Steps: $this->reviewIndex->open(); $this->reviewIndex->getReviewActions()->addNew(); - $this->reviewEdit->getProductGrid()->searchAndOpen($filter); + $this->reviewEdit->getProductGrid()->search($filter); + $this->reviewEdit->getProductGrid()->openFirstRow(); $this->reviewEdit->getReviewForm()->fill($this->review); $this->reviewEdit->getPageActions()->save(); From 2127efc46fa132f572f09d3d20febac11c603eea Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Tue, 16 Aug 2016 15:25:29 +0300 Subject: [PATCH 02/21] MAGETWO-55327: [FT] Filter not applied on current page in test. --- .../Block/Adminhtml/Edit/Product/Grid.php | 29 +++++++++++++++++++ .../Block/Adminhtml/Edit/RatingElement.php | 2 +- .../Product/Edit/Section/Reviews.php | 4 +-- .../Magento/Review/Test/Block/ReviewForm.php | 4 +-- 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/Product/Grid.php diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/Product/Grid.php new file mode 100644 index 0000000000000..9f7cc54fe88ca --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/Product/Grid.php @@ -0,0 +1,29 @@ + [ + 'selector' => 'input[name="title"]', + ], + 'sku' => [ + 'selector' => 'input[name="sku"]', + ], + ]; +} diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/RatingElement.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/RatingElement.php index 3ba4369fb0fcc..afadc1b0858ae 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/RatingElement.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Edit/RatingElement.php @@ -34,7 +34,7 @@ class RatingElement extends SimpleElement * * @var string */ - protected $ratingByNumber = './/*[@id="rating_detail"]//*[contains(@class,"field-rating")][%d]'; + protected $ratingByNumber = './/*[contains(@class,"field-rating")][%d]'; /** * Set rating value diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php index 0f5a646fcefae..91fc2f465ce00 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/Adminhtml/Product/Edit/Section/Reviews.php @@ -23,12 +23,12 @@ class Reviews extends Section /** * Returns product reviews grid. * - * @return \Magento\Review\Test\Block\Adminhtml\Product\Grid + * @return \Magento\Review\Test\Block\Adminhtml\Edit\Product\Grid */ public function getReviewsGrid() { return $this->blockFactory->create( - 'Magento\Review\Test\Block\Adminhtml\Product\Grid', + 'Magento\Review\Test\Block\Adminhtml\Edit\Product\Grid', ['element' => $this->_rootElement->find($this->reviews)] ); } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php b/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php index 6bb20785adf91..91ab33e5ca321 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Block/ReviewForm.php @@ -37,14 +37,14 @@ class ReviewForm extends AbstractForm * * @var string */ - protected $rating = './/*[@id="%s_rating_label"]/span'; + protected $rating = './/*[@id="%s_rating_label"]'; /** * Selector for label of rating vote. * * @var string */ - protected $ratingVoteLabel = './div[contains(@class,"vote")]/label[contains(@id,"_%d_label")]'; + protected $ratingVoteLabel = './following-sibling::div[contains(@class,"vote")]/label[contains(@id,"_%d_label")]'; /** * Submit review form. From 22c459b9e17ce0bc221c45ec9ab9f9ae4ec71e16 Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Tue, 16 Aug 2016 19:18:14 +0300 Subject: [PATCH 03/21] MAGETWO-55975: [FT] Cannot set date of birth in customer form --- .../Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml | 3 +++ .../Test/TestCase/CreateCustomerBackendEntityTest.xml | 2 +- .../Test/TestCase/UpdateCustomerBackendEntityTest.xml | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml index 664f96cd4b42f..bb56a9edaf9a1 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -24,6 +24,9 @@ select + + datepicker + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml index 6997cca28fac0..248b26561af3a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml @@ -27,7 +27,7 @@ Doe%isolation% S JohnDoe%isolation%@example.com - Mar 16, 2004 + 03/16/2004 Male diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest.xml index ac63dcaf2805e..c2132672d900a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerBackendEntityTest.xml @@ -16,7 +16,7 @@ Doe%isolation% _Suffix%isolation% JohnDoe%isolation%@example.com - Aug 1, 1986 + 08/01/1986 123456789001 Male @@ -52,7 +52,7 @@ Doe%isolation% _JaneSuffix%isolation% Jane%isolation%@example.com - Dec 1, 2000 + 01/12/2000 987654321 Female Prefix%isolation%_ From 3d17044755065fe0670b4a29430c3f4f784a1f26 Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Wed, 17 Aug 2016 12:16:58 +0300 Subject: [PATCH 04/21] MAGETWO-56753: [FT] Cannot click on action-select button in customers grid block --- .../tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index eae09d72a47b9..3fc6f044f8852 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -135,7 +135,7 @@ class DataGrid extends Grid * * @var string */ - protected $sortLink = "//th[contains(@class, '%s')]/span[contains(text(), '%s')]"; + protected $sortLink = './/div[@data-role="grid-wrapper"]//th[contains(@class, "%s")]/span[contains(text(), "%s")]'; /** * Current page input. From 7fc2a1f2164f02ecdb632aae73af5d4c9c04e37a Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Thu, 18 Aug 2016 15:22:55 +0300 Subject: [PATCH 05/21] MAGETWO-55782: [FT] Threre is no "schedule update" section in "New Category" form --- .../Test/Block/Adminhtml/Category/Edit/CategoryForm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml index 593ab70e100ff..42f490d76191a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.xml @@ -134,11 +134,11 @@ xpath - text + datepicker input[name='custom_design_from'] - text + datepicker input[name='custom_design_to'] From 6b0bea9e039ef559e3debef27b9a266099c0f466 Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Fri, 19 Aug 2016 15:03:47 +0300 Subject: [PATCH 06/21] MAGETWO-56584: [FT] Custom options are not created for product in test --- .../Handler/CatalogProductSimple/Curl.php | 4 +- .../Handler/CatalogProductSimple/Webapi.php | 103 ------------------ .../Test/Handler/ConfigurableProduct/Curl.php | 18 +++ 3 files changed, 20 insertions(+), 105 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php index e660b0ea05fab..2ccb804b073f9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Curl.php @@ -413,12 +413,12 @@ protected function prepareWebsites() { if (!empty($this->fields['product']['website_ids'])) { foreach ($this->fixture->getDataFieldConfig('website_ids')['source']->getWebsites() as $key => $website) { - $this->fields['product']['website_ids'][$key] = $website->getWebsiteId(); + $this->fields['product']['extension_attributes']['website_ids'][$key] = $website->getWebsiteId(); } } else { $website = \Magento\Mtf\ObjectManagerFactory::getObjectManager() ->create(\Magento\Store\Test\Fixture\Website::class, ['dataset' => 'default']); - $this->fields['product']['website_ids'][] = $website->getWebsiteId(); + $this->fields['product']['extension_attributes']['website_ids'][] = $website->getWebsiteId(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php index f3d839ecf8a8e..e03c45766289c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php @@ -102,8 +102,6 @@ public function persist(FixtureInterface $fixture = null) $this->prepareData(); $this->convertData(); - //TODO: Change create and assign product to website flow using 1 request after MAGETWO-52812 delivery. - /** @var CatalogProductSimple $fixture */ $url = $_ENV['app_frontend_url'] . 'rest/all/V1/products'; $this->webapiTransport->write($url, $this->fields, CurlInterface::POST); @@ -116,110 +114,9 @@ public function persist(FixtureInterface $fixture = null) throw new \Exception("Product creation by webapi handler was not successful! Response: {$encodedResponse}"); } - $this->assignToWebsites($response); - return $this->parseResponse($response); } - /** - * Assign appropriate Websites to Product and unset all other. - * - * @param array $product - * @return void - */ - private function assignToWebsites($product) - { - $this->setWebsites($product); - $this->unsetWebsites($product); - } - - /** - * Get all Websites. - * - * @return array - * @throws \Exception - */ - private function getAllWebsites() - { - $url = $_ENV['app_frontend_url'] . 'rest/V1/store/websites'; - $this->webapiTransport->write($url, [], CurlInterface::GET); - $encodedResponse = $this->webapiTransport->read(); - $response = json_decode($encodedResponse, true); - $this->webapiTransport->close(); - - if (!isset($response[0]['id'])) { - $this->eventManager->dispatchEvent(['webapi_failed'], [$response]); - throw new \Exception( - "Attempt to get all Websites by webapi handler was not successful! Response: {$encodedResponse}" - ); - } - - return $response; - } - - /** - * Set appropriate Websites to Product. - * - * @param array $product - * @return void - * @throws \Exception - */ - private function setWebsites($product) - { - foreach ($this->websiteIds as $id) { - $url = $_ENV['app_frontend_url'] . 'rest/V1/products/' . $product['sku'] . '/websites'; - $productWebsiteLink = ['productWebsiteLink' => ['website_id' => $id, 'sku' => $product['sku']]]; - $this->webapiTransport->write($url, $productWebsiteLink, CurlInterface::POST); - $encodedResponse = $this->webapiTransport->read(); - $response = json_decode($encodedResponse, true); - $this->webapiTransport->close(); - - if ($response !== true) { - $this->eventManager->dispatchEvent(['webapi_failed'], [$response]); - throw new \Exception( - "Product addition to Website by webapi handler was not successful! Response: {$encodedResponse}" - ); - } - } - } - - /** - * Unset all Websites from Product except appropriate. - * - * @param array $product - * @return void - * @throws \Exception - */ - private function unsetWebsites($product) - { - $allWebsites = $this->getAllWebsites(); - $websiteIds = []; - - foreach ($allWebsites as $website) { - if ($website['code'] == 'admin') { - continue; - } - $websiteIds[] = $website['id']; - } - - $websiteIds = array_diff($websiteIds, $this->websiteIds); - - foreach ($websiteIds as $id) { - $url = $_ENV['app_frontend_url'] . 'rest/V1/products/' . $product['sku'] . '/websites/' . $id; - $this->webapiTransport->write($url, [], CurlInterface::DELETE); - $encodedResponse = $this->webapiTransport->read(); - $response = json_decode($encodedResponse, true); - $this->webapiTransport->close(); - - if ($response !== true) { - $this->eventManager->dispatchEvent(['webapi_failed'], [$response]); - throw new \Exception( - "Product deduction from Website by webapi handler was not successful! Response: {$encodedResponse}" - ); - } - } - } - /** * Prepare data for creating product request. * diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php index 402aa6ba0d318..bf5d5944aa3da 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Handler/ConfigurableProduct/Curl.php @@ -61,6 +61,24 @@ public function prepareData(FixtureInterface $fixture) return $data; } + /** + * Preparation of websites data. + * + * @return void + */ + protected function prepareWebsites() + { + if (!empty($this->fields['product']['website_ids'])) { + foreach ($this->fixture->getDataFieldConfig('website_ids')['source']->getWebsites() as $key => $website) { + $this->fields['product']['website_ids'][$key] = $website->getWebsiteId(); + } + } else { + $website = \Magento\Mtf\ObjectManagerFactory::getObjectManager() + ->create(\Magento\Store\Test\Fixture\Website::class, ['dataset' => 'default']); + $this->fields['product']['website_ids'][] = $website->getWebsiteId(); + } + } + /** * Preparation of attribute set data. * From 556fb3e4026dfd6ad62f2bf9d56e9f748ca9f4fa Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Fri, 19 Aug 2016 16:50:17 +0300 Subject: [PATCH 07/21] MAGETWO-56584: [FT] Custom options are not created for product in test --- .../Catalog/Test/Handler/CatalogProductSimple/Webapi.php | 1 - .../Magento/Catalog/Test/Repository/CatalogProductSimple.xml | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php index e03c45766289c..192cba43d5131 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php @@ -141,7 +141,6 @@ protected function prepareData() protected function convertData() { $fields = []; - $this->websiteIds = $this->fields['product']['website_ids']; unset($this->fields['product']['website_ids']); unset($this->fields['product']['checkout_data']); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index 23c13fb1206df..ecd68593b08cc 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -1215,7 +1215,9 @@ taxable_goods - Main Website + + default + Catalog, Search simple-product-%isolation% From a7cfa3ff97083249741d11e6db68010b4c6acd74 Mon Sep 17 00:00:00 2001 From: Sergey Kovalenko Date: Thu, 25 Aug 2016 15:31:52 +0300 Subject: [PATCH 08/21] MAGETWO-57205: CLONE - CLONE - Attribute for Send Welcome Email From shows wrong store ID --- .../Magento/Customer/view/base/ui_component/customer_form.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml index 41ffb74184bad..fdb9c3f317a4c 100644 --- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml +++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml @@ -256,6 +256,10 @@ Send Welcome Email From number select + customer + + ${ $.provider }:data.customer.store_id + From 4f4521ed424300bd1c5ef66c72eb7839883532b2 Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Fri, 26 Aug 2016 02:49:28 -0700 Subject: [PATCH 09/21] MAGETWO-57535: L2 Plan fails on mainline develop branch --- .../Magento/Theme/Model/Config/ValidatorTest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php b/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php index 16ca335beea7b..bb899fa6af598 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Model/Config/ValidatorTest.php @@ -12,7 +12,7 @@ */ class ValidatorTest extends \PHPUnit_Framework_TestCase { - const TEMPLATE_CODE = 'fixture'; + const TEMPLATE_CODE = 'email_exception_fixture'; /** * @var \Magento\Theme\Model\Design\Config\Validator @@ -44,7 +44,9 @@ protected function setUp() $this->templateModel = $objectManager->create(\Magento\Email\Model\Template::class); $this->templateModel->load(self::TEMPLATE_CODE, 'template_code'); - + $this->templateFactoryMock->expects($this->once()) + ->method("create") + ->willReturn($this->templateModel); $this->model = $objectManager->create( \Magento\Theme\Model\Design\Config\Validator::class, [ 'templateFactory' => $this->templateFactoryMock ] @@ -58,9 +60,9 @@ protected function setUp() */ public function testValidateHasRecursiveReference() { - $this->templateFactoryMock->expects($this->once()) - ->method("create") - ->willReturn($this->templateModel); + if (!$this->templateModel->getId()) { + $this->fail('Cannot load Template model'); + } $fieldConfig = [ 'path' => 'design/email/header_template', @@ -90,7 +92,7 @@ public function testValidateHasRecursiveReference() ->willReturn([$designElementMock]); $designElementMock->expects($this->any())->method('getFieldConfig')->willReturn($fieldConfig); $designElementMock->expects($this->once())->method('getPath')->willReturn($fieldConfig['path']); - $designElementMock->expects($this->once())->method('getValue')->willReturn(1); + $designElementMock->expects($this->once())->method('getValue')->willReturn($this->templateModel->getId()); $this->model->validate($designConfigMock); } @@ -132,7 +134,7 @@ public function testValidateNoRecursiveReference() ->willReturn([$designElementMock]); $designElementMock->expects($this->any())->method('getFieldConfig')->willReturn($fieldConfig); $designElementMock->expects($this->once())->method('getPath')->willReturn($fieldConfig['path']); - $designElementMock->expects($this->once())->method('getValue')->willReturn(1); + $designElementMock->expects($this->once())->method('getValue')->willReturn($this->templateModel->getId()); $this->model->validate($designConfigMock); } From 10fc55ce7245cdca9721124eba67206313d22062 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 30 Aug 2016 18:05:27 +0300 Subject: [PATCH 10/21] MAGETWO-52925: Simple child product without a special price still shown as "was (original price)" #4442 #5097 --- .../Pricing/Render/FinalPriceBox.php | 60 +++++++++++++++++++ .../base/layout/catalog_product_prices.xml | 21 +++++++ .../templates/product/price/final_price.phtml | 60 +++++++++++++++++++ .../view/frontend/web/js/configurable.js | 21 ++++++- 4 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/ConfigurableProduct/Pricing/Render/FinalPriceBox.php create mode 100644 app/code/Magento/ConfigurableProduct/view/base/layout/catalog_product_prices.xml create mode 100644 app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Render/FinalPriceBox.php b/app/code/Magento/ConfigurableProduct/Pricing/Render/FinalPriceBox.php new file mode 100644 index 0000000000000..16a296a355454 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Pricing/Render/FinalPriceBox.php @@ -0,0 +1,60 @@ +configurableOptionsProvider = $configurableOptionsProvider; + parent::__construct($context, $saleableItem, $price, $rendererPool, $data); + } + + /** + * Define if the special price should be shown + * + * @return bool + */ + public function hasSpecialPrice() + { + $product = $this->getSaleableItem(); + foreach ($this->configurableOptionsProvider->getProducts($product) as $subProduct) { + $regularPrice = $subProduct->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getValue(); + $finalPrice = $subProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue(); + if ($finalPrice < $regularPrice) { + return true; + } + } + return false; + } +} diff --git a/app/code/Magento/ConfigurableProduct/view/base/layout/catalog_product_prices.xml b/app/code/Magento/ConfigurableProduct/view/base/layout/catalog_product_prices.xml new file mode 100644 index 0000000000000..47fe31681b5bf --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/base/layout/catalog_product_prices.xml @@ -0,0 +1,21 @@ + + + + + + + + + Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox + Magento_ConfigurableProduct::product/price/final_price.phtml + + + + + + diff --git a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml new file mode 100644 index 0000000000000..84383d95c1741 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml @@ -0,0 +1,60 @@ + + +getPriceType('regular_price'); + +/** @var \Magento\Framework\Pricing\Price\PriceInterface $finalPriceModel */ +$finalPriceModel = $block->getPriceType('final_price'); +$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : ''; +$schema = ($block->getZone() == 'item_view') ? true : false; +?> +hasSpecialPrice()): ?> + + renderAmount($finalPriceModel->getAmount(), [ + 'display_label' => __('Special Price'), + 'price_id' => $block->getPriceId('product-price-' . $idSuffix), + 'price_type' => 'finalPrice', + 'include_container' => true, + 'schema' => $schema + ]); ?> + + + renderAmount($priceModel->getAmount(), [ + 'display_label' => __('Regular Price'), + 'price_id' => $block->getPriceId('old-price-' . $idSuffix), + 'price_type' => 'oldPrice', + 'include_container' => true, + 'skip_adjustments' => true + ]); ?> + + + renderAmount($finalPriceModel->getAmount(), [ + 'price_id' => $block->getPriceId('product-price-' . $idSuffix), + 'price_type' => 'finalPrice', + 'include_container' => true, + 'schema' => $schema + ]); ?> + + +showMinimalPrice()): ?> + getUseLinkForAsLowAs()):?> + + renderAmountMinimal(); ?> + + + + renderAmountMinimal(); ?> + + + diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js index d38e2760f1dc7..572b2ac3ff503 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js @@ -28,6 +28,7 @@ define([ '<% } %>', mediaGallerySelector: '[data-gallery-role=gallery-placeholder]', mediaGalleryInitial: null, + regularPriceSelector: '.old-price', onlyMainImg: false }, @@ -246,6 +247,7 @@ define([ this._resetChildren(element); } this._reloadPrice(); + this._displayRegularPriceBlock(this.simpleProduct); this._changeProductImage(); }, @@ -442,7 +444,7 @@ define([ }, /** - * Returns pracies for configured products + * Returns prices for configured products * * @param {*} config - Products configuration * @returns {*} @@ -485,6 +487,23 @@ define([ undefined : _.first(config.allowedProducts); + }, + + /** + * Show or hide regular price block + * + * @param {*} optionId + * @private + */ + _displayRegularPriceBlock: function (optionId) { + if (typeof optionId != 'undefined' + && this.options.spConfig.optionPrices[optionId].oldPrice.amount + != this.options.spConfig.optionPrices[optionId].finalPrice.amount + ) { + $(this.options.regularPriceSelector).show(); + } else { + $(this.options.regularPriceSelector).hide(); + } } }); From 73dfa14b7e117250902e6d7fc9cca21deca511a3 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 30 Aug 2016 19:06:23 +0300 Subject: [PATCH 11/21] MAGETWO-52925: Simple child product without a special price still shown as "was (original price)" #4442 #5097 --- .../Unit/Pricing/Render/FinalPriceBoxTest.php | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php new file mode 100644 index 0000000000000..58f8f773dfd41 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -0,0 +1,137 @@ +context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->saleableItem = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->price = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + ->getMockForAbstractClass(); + + $this->rendererPool = $this->getMockBuilder(\Magento\Framework\Pricing\Render\RendererPool::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->configurableOptionsProvider = $this->getMockBuilder(ConfigurableOptionsProviderInterface::class) + ->getMockForAbstractClass(); + + $this->model = new FinalPriceBox( + $this->context, + $this->saleableItem, + $this->price, + $this->rendererPool, + $this->configurableOptionsProvider + ); + } + + /** + * @param float $regularPrice + * @param float $finalPrice + * @param bool $expected + * @dataProvider DataProviderHasSpecialPrice + */ + public function testHasSpecialPrice( + $regularPrice, + $finalPrice, + $expected + ) { + $priceMockOne = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + ->getMockForAbstractClass(); + + $priceMockOne->expects($this->once()) + ->method('getValue') + ->willReturn($regularPrice); + + $priceMockTwo = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + ->getMockForAbstractClass(); + + $priceMockTwo->expects($this->once()) + ->method('getValue') + ->willReturn($finalPrice); + + $priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo\Base::class) + ->disableOriginalConstructor() + ->getMock(); + + $priceInfoMock->expects($this->exactly(2)) + ->method('getPrice') + ->willReturnMap([ + [RegularPrice::PRICE_CODE, $priceMockOne], + [FinalPrice::PRICE_CODE, $priceMockTwo], + ]); + + $productMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class) + ->setMethods(['getPriceInfo']) + ->getMockForAbstractClass(); + + $productMock->expects($this->exactly(2)) + ->method('getPriceInfo') + ->willReturn($priceInfoMock); + + $this->configurableOptionsProvider->expects($this->once()) + ->method('getProducts') + ->with($this->saleableItem) + ->willReturn([$productMock]); + + $this->assertEquals($expected, $this->model->hasSpecialPrice()); + } + + /** + * @return array + */ + public function DataProviderHasSpecialPrice() + { + return [ + [10., 20., false], + [10., 10., false], + [20., 10., true], + ]; + } +} From 38c85a6be113aa78b198dada502060bf9c9c01e4 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 30 Aug 2016 19:35:13 +0300 Subject: [PATCH 12/21] MAGETWO-52925: Simple child product without a special price still shown as "was (original price)" #4442 #5097 --- .../Test/Unit/Pricing/Render/FinalPriceBoxTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index 58f8f773dfd41..4dbcfed531525 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -75,7 +75,7 @@ protected function setUp() * @param float $regularPrice * @param float $finalPrice * @param bool $expected - * @dataProvider DataProviderHasSpecialPrice + * @dataProvider hasSpecialPriceDataProvider */ public function testHasSpecialPrice( $regularPrice, @@ -126,7 +126,7 @@ public function testHasSpecialPrice( /** * @return array */ - public function DataProviderHasSpecialPrice() + public function hasSpecialPriceDataProvider() { return [ [10., 20., false], From 5e4616f658421c302a61969e92df283d9e55ccc8 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Wed, 31 Aug 2016 20:50:27 +0300 Subject: [PATCH 13/21] MAGETWO-52925: Simple child product without a special price still shown as "was (original price)" #4442 #5097 --- .../view/base/templates/product/price/final_price.phtml | 2 +- .../view/frontend/web/js/configurable.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml index 84383d95c1741..5943b1ea2af5b 100644 --- a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml +++ b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/final_price.phtml @@ -29,7 +29,7 @@ $schema = ($block->getZone() == 'item_view') ? true : false; 'schema' => $schema ]); ?> - + renderAmount($priceModel->getAmount(), [ 'display_label' => __('Regular Price'), 'price_id' => $block->getPriceId('old-price-' . $idSuffix), diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js index 572b2ac3ff503..87b9b34be387b 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js @@ -28,7 +28,7 @@ define([ '<% } %>', mediaGallerySelector: '[data-gallery-role=gallery-placeholder]', mediaGalleryInitial: null, - regularPriceSelector: '.old-price', + slyOldPriceSelector: '.sly-old-price', onlyMainImg: false }, @@ -500,9 +500,9 @@ define([ && this.options.spConfig.optionPrices[optionId].oldPrice.amount != this.options.spConfig.optionPrices[optionId].finalPrice.amount ) { - $(this.options.regularPriceSelector).show(); + $(this.options.slyOldPriceSelector).show(); } else { - $(this.options.regularPriceSelector).hide(); + $(this.options.slyOldPriceSelector).hide(); } } From 0b05d4da623807689ff9e08bfd7a0a22f7a7582b Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Tue, 6 Sep 2016 01:45:08 -0700 Subject: [PATCH 14/21] MAGETWO-56341: Maximum error count when importing because issue URL key for specified store already exists --- .../Model/Import/Product.php | 39 ++++++++++++++++++- .../Model/Import/ProductTest.php | 3 +- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 21c12bf0a8b1a..4b52230f688bb 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1317,7 +1317,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp) $select = $this->_connection->select()->from( $entityTable, - $this->getNewSkuFieldsForSelect() + array_merge($this->getNewSkuFieldsForSelect(), $this->getOldSkuFieldsForSelect()) )->where( 'sku IN (?)', array_keys($entityRowsIn) @@ -1330,10 +1330,44 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp) $this->skuProcessor->setNewSkuData($sku, $key, $value); } } + + $this->_oldSku = $this->prepareUpdatedOldSkus($newProducts); } + return $this; } + /** + * Return additional data, needed to select. + * @return array + */ + private function getOldSkuFieldsForSelect() + { + return ['type_id', 'attribute_set_id', 'sku']; + } + + /** + * @param array $newProducts + * @return array + */ + private function prepareUpdatedOldSkus(array $newProducts) + { + $oldSkus = []; + foreach ($newProducts as $info) { + $typeId = $info['type_id']; + $sku = $info['sku']; + $oldSkus[$sku] = [ + 'type_id' => $typeId, + 'attr_set_id' => $info['attribute_set_id'], + 'entity_id' => $info['entity_id'], + 'supported_type' => isset($this->_productTypeModels[$typeId]), + $this->getProductEntityLinkField() => $info[$this->getProductEntityLinkField()], + ]; + } + + return array_replace($this->_oldSku, $oldSkus); + } + /** * Get new SKU fields for select * @@ -1718,6 +1752,7 @@ protected function _saveProducts() ['adapter' => $this, 'bunch' => $bunch] ); } + return $this; } @@ -2452,6 +2487,7 @@ protected function _saveValidatedBunches() { $source = $this->_getSource(); $source->rewind(); + while ($source->valid()) { try { $rowData = $source->current(); @@ -2465,6 +2501,7 @@ protected function _saveValidatedBunches() $rowData = $this->_customFieldsMapping($rowData); $this->validateRow($rowData, $source->key()); + $source->next(); } $this->checkUrlKeyDuplicates(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index a1762a065ba88..cf416154450c7 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -557,7 +557,7 @@ protected function getOptionValues(\Magento\Catalog\Model\Product\Option $option /** * @magentoDataIsolation enabled * @magentoDataFixture mediaImportImageFixture - * + * @magentoAppIsolation enabled * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testSaveMediaImage() @@ -732,6 +732,7 @@ public function testInvalidSkuLink() /** * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute.php * @magentoAppIsolation enabled + * @magentoDbIsolation enabled */ public function testValidateInvalidMultiselectValues() { From d48f1e221afddb026234bc1cf26af53a2e62167b Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Tue, 6 Sep 2016 02:58:53 -0700 Subject: [PATCH 15/21] MAGETWO-56341: Maximum error count when importing because issue URL key for specified store already exists --- .../Magento/CatalogImportExport/Model/Import/Product.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 4b52230f688bb..77ce0dc40edcf 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1331,7 +1331,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp) } } - $this->_oldSku = $this->prepareUpdatedOldSkus($newProducts); + $this->updateOldSku($newProducts); } return $this; @@ -1347,10 +1347,11 @@ private function getOldSkuFieldsForSelect() } /** + * Adds newly created products to _oldSku * @param array $newProducts - * @return array + * @return void */ - private function prepareUpdatedOldSkus(array $newProducts) + private function updateOldSku(array $newProducts) { $oldSkus = []; foreach ($newProducts as $info) { @@ -1365,7 +1366,7 @@ private function prepareUpdatedOldSkus(array $newProducts) ]; } - return array_replace($this->_oldSku, $oldSkus); + $this->_oldSku = array_replace($this->_oldSku, $oldSkus); } /** From 091925690886dba4301afe66cce0d774aece0026 Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Tue, 6 Sep 2016 03:14:13 -0700 Subject: [PATCH 16/21] MAGETWO-56341: Maximum error count when importing because issue URL key for specified store already exists --- app/code/Magento/CatalogImportExport/Model/Import/Product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 77ce0dc40edcf..75ec58ff90876 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -1343,7 +1343,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp) */ private function getOldSkuFieldsForSelect() { - return ['type_id', 'attribute_set_id', 'sku']; + return ['type_id', 'attribute_set_id']; } /** @@ -1360,7 +1360,7 @@ private function updateOldSku(array $newProducts) $oldSkus[$sku] = [ 'type_id' => $typeId, 'attr_set_id' => $info['attribute_set_id'], - 'entity_id' => $info['entity_id'], + $this->getProductIdentifierField() => $info[$this->getProductIdentifierField()], 'supported_type' => isset($this->_productTypeModels[$typeId]), $this->getProductEntityLinkField() => $info[$this->getProductEntityLinkField()], ]; From a4c72610951b5acc21fd294948a022d91ffb74a8 Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Tue, 6 Sep 2016 05:12:36 -0700 Subject: [PATCH 17/21] MAGETWO-56341: Maximum error count when importing because issue URL key for specified store already exists --- .../Model/Import/ProductTest.php | 61 +++++++++++++++++++ ...products_to_import_with_multiple_store.csv | 6 ++ 2 files changed, 67 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_multiple_store.csv diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index cf416154450c7..416ae8ecafcf6 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -14,6 +14,7 @@ */ namespace Magento\CatalogImportExport\Model\Import; +use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Category; use Magento\Framework\App\Bootstrap; @@ -38,6 +39,8 @@ class ProductTest extends \Magento\TestFramework\Indexer\TestCase */ protected $_uploader; + protected $importExport; + /** * @var \Magento\CatalogImportExport\Model\Import\UploaderFactory */ @@ -1269,4 +1272,62 @@ public function testProductWithUseConfigSettings() $this->assertEquals($manageStockUseConfig, $stockItem->getUseConfigManageStock()); } } + + /** + * @magentoDataFixture Magento/Store/_files/website.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ + public function testProductWithMultipleStoresInDifferentBunches() + { + $products = [ + 'simple1', + 'simple2', + 'simple3' + ]; + + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $importExportData = $this->getMockBuilder(\Magento\ImportExport\Helper\Data::class) + ->disableOriginalConstructor() + ->getMock(); + $importExportData->expects($this->atLeastOnce()) + ->method('getBunchSize') + ->willReturn(1); + $this->_model = $objectManager->create( + \Magento\CatalogImportExport\Model\Import\Product::class, + ['importExportData' => $importExportData] + ); + + $filesystem = $objectManager->create(\Magento\Framework\Filesystem::class); + $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); + $source = $this->objectManager->create( + \Magento\ImportExport\Model\Import\Source\Csv::class, + [ + 'file' => __DIR__ . '/_files/products_to_import_with_multiple_store.csv', + 'directory' => $directory + ] + ); + $errors = $this->_model->setParameters( + ['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product'] + )->setSource( + $source + )->validateData(); + + $this->assertTrue($errors->getErrorsCount() == 0); + + $this->_model->importData(); + $productCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); + $this->assertCount(3, $productCollection->getItems()); + $actualProductSkus = array_map( + function(ProductInterface $item) { + return $item->getSku(); + }, + $productCollection->getItems() + ); + $this->assertEquals( + $products, + array_values($actualProductSkus) + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_multiple_store.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_multiple_store.csv new file mode 100644 index 0000000000000..a4ad5adb7b0f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_multiple_store.csv @@ -0,0 +1,6 @@ +sku,product_type,store_view_code,name,price,attribute_set_code,categories +simple1,simple,fixturestore,"simple 1",25,Default,"Default Category/Category 1" +simple1,simple,,"simple 1",25,Default,"Default Category/Category 1" +simple2,simple,fixturestore,"simple 2",34,Default,"Default Category/Category 1" +simple2,simple,,"simple 2",34,Default,"Default Category/Category 1" +simple3,simple,,"simple 3",58,Default,"Default Category/Category 1" From 7796729a9cd6b37ac191dcfee129c4b671bdca2b Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko Date: Tue, 6 Sep 2016 05:32:40 -0700 Subject: [PATCH 18/21] MAGETWO-56341: Maximum error count when importing because issue URL key for specified store already exists --- .../CatalogImportExport/Model/Import/ProductTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 416ae8ecafcf6..db5511bf9d8ff 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -39,8 +39,6 @@ class ProductTest extends \Magento\TestFramework\Indexer\TestCase */ protected $_uploader; - protected $importExport; - /** * @var \Magento\CatalogImportExport\Model\Import\UploaderFactory */ @@ -1287,19 +1285,18 @@ public function testProductWithMultipleStoresInDifferentBunches() 'simple3' ]; - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $importExportData = $this->getMockBuilder(\Magento\ImportExport\Helper\Data::class) ->disableOriginalConstructor() ->getMock(); $importExportData->expects($this->atLeastOnce()) ->method('getBunchSize') ->willReturn(1); - $this->_model = $objectManager->create( + $this->_model = $this->objectManager->create( \Magento\CatalogImportExport\Model\Import\Product::class, ['importExportData' => $importExportData] ); - $filesystem = $objectManager->create(\Magento\Framework\Filesystem::class); + $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create( \Magento\ImportExport\Model\Import\Source\Csv::class, @@ -1317,7 +1314,8 @@ public function testProductWithMultipleStoresInDifferentBunches() $this->assertTrue($errors->getErrorsCount() == 0); $this->_model->importData(); - $productCollection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); + $productCollection = $this->objectManager + ->create(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); $this->assertCount(3, $productCollection->getItems()); $actualProductSkus = array_map( function(ProductInterface $item) { From 9de26061096fd0ab9467e068278c7b234809b80c Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 6 Sep 2016 18:54:44 +0300 Subject: [PATCH 19/21] MAGETWO-56077: [GitHub] Unable to add more than 1 product to a cart from Wishlist #5282 --- app/code/Magento/Wishlist/Helper/Data.php | 8 ++++- .../Wishlist/Test/Unit/Helper/DataTest.php | 32 +++++++++++++++++-- .../Wishlist/view/frontend/web/wishlist.js | 22 +++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index d64d1a185f0a2..292f66a71baa0 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -446,7 +446,13 @@ public function getSharedAddAllToCartUrl() */ protected function _getCartUrlParameters($item) { - return ['item' => is_string($item) ? $item : $item->getWishlistItemId()]; + $params = [ + 'item' => is_string($item) ? $item : $item->getWishlistItemId(), + ]; + if (is_object($item)) { + $params['qty'] = $item->getQty(); + } + return $params; } /** diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php index 46054445620ac..ec6e959a3d4ca 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php @@ -124,6 +124,7 @@ protected function setUp() ->setMethods([ 'getProduct', 'getWishlistItemId', + 'getQty', ]) ->getMock(); @@ -217,6 +218,7 @@ public function testGetAddToCartParams() $url = 'result url'; $storeId = 1; $wishlistItemId = 1; + $wishlistItemQty = 1; $this->wishlistItem->expects($this->once()) ->method('getProduct') @@ -224,6 +226,9 @@ public function testGetAddToCartParams() $this->wishlistItem->expects($this->once()) ->method('getWishlistItemId') ->willReturn($wishlistItemId); + $this->wishlistItem->expects($this->once()) + ->method('getQty') + ->willReturn($wishlistItemQty); $this->product->expects($this->once()) ->method('isVisibleInSiteVisibility') @@ -243,9 +248,13 @@ public function testGetAddToCartParams() ->with('wishlist/index/cart') ->willReturn($url); + $expected = [ + 'item' => $wishlistItemId, + 'qty' => $wishlistItemQty, + ]; $this->postDataHelper->expects($this->once()) ->method('getPostData') - ->with($url, ['item' => $wishlistItemId]) + ->with($url, $expected) ->willReturn($url); $this->assertEquals($url, $this->model->getAddToCartParams($this->wishlistItem)); @@ -256,6 +265,7 @@ public function testGetAddToCartParamsWithReferer() $url = 'result url'; $storeId = 1; $wishlistItemId = 1; + $wishlistItemQty = 1; $referer = 'referer'; $refererEncoded = 'referer_encoded'; @@ -265,6 +275,9 @@ public function testGetAddToCartParamsWithReferer() $this->wishlistItem->expects($this->once()) ->method('getWishlistItemId') ->willReturn($wishlistItemId); + $this->wishlistItem->expects($this->once()) + ->method('getQty') + ->willReturn($wishlistItemQty); $this->product->expects($this->once()) ->method('isVisibleInSiteVisibility') @@ -288,9 +301,14 @@ public function testGetAddToCartParamsWithReferer() ->with('wishlist/index/cart') ->willReturn($url); + $expected = [ + 'item' => $wishlistItemId, + ActionInterface::PARAM_NAME_URL_ENCODED => $refererEncoded, + 'qty' => $wishlistItemQty, + ]; $this->postDataHelper->expects($this->once()) ->method('getPostData') - ->with($url, ['item' => $wishlistItemId, ActionInterface::PARAM_NAME_URL_ENCODED => $refererEncoded]) + ->with($url, $expected) ->willReturn($url); $this->assertEquals($url, $this->model->getAddToCartParams($this->wishlistItem, true)); @@ -363,6 +381,7 @@ public function testGetSharedAddToCartUrl() $url = 'result url'; $storeId = 1; $wishlistItemId = 1; + $wishlistItemQty = 1; $this->wishlistItem->expects($this->once()) ->method('getProduct') @@ -370,6 +389,9 @@ public function testGetSharedAddToCartUrl() $this->wishlistItem->expects($this->once()) ->method('getWishlistItemId') ->willReturn($wishlistItemId); + $this->wishlistItem->expects($this->once()) + ->method('getQty') + ->willReturn($wishlistItemQty); $this->product->expects($this->once()) ->method('isVisibleInSiteVisibility') @@ -383,9 +405,13 @@ public function testGetSharedAddToCartUrl() ->with('wishlist/shared/cart') ->willReturn($url); + $exptected = [ + 'item' => $wishlistItemId, + 'qty' => $wishlistItemQty, + ]; $this->postDataHelper->expects($this->once()) ->method('getPostData') - ->with($url, ['item' => $wishlistItemId]) + ->with($url, $exptected) ->willReturn($url); $this->assertEquals($url, $this->model->getSharedAddToCartUrl($this->wishlistItem)); diff --git a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js index a4fdc178c704f..0d6e510e5f5e9 100644 --- a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js +++ b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js @@ -47,6 +47,7 @@ define([ event.preventDefault(); $.mage.dataPost().postData($(event.currentTarget).data('post-remove')); }, this)) + .on('click', this.options.addToCartSelector, $.proxy(this._beforeAddToCart, this)) .on('click', this.options.addAllToCartSelector, $.proxy(this._addAllWItemsToCart, this)) .on('focusin focusout', this.options.commentInputType, $.proxy(this._focusComment, this)); } @@ -59,6 +60,27 @@ define([ }); }, + /** + * Process data before add to cart + * + * - update item's qty value. + * + * @param {Event} event + * @private + */ + _beforeAddToCart: function(event) { + var elem = $(event.currentTarget), + itemId = elem.data(this.options.dataAttribute), + qtyName = $.validator.format(this.options.nameFormat, itemId), + qtyValue = elem.parents().find('[name="' + qtyName + '"]').val(), + params = elem.data('post'); + + if (params) { + params.data = $.extend({}, params.data, {'qty': qtyValue}); + elem.data('post', params); + } + }, + /** * Add wish list items to cart. * @private From 834f8735f67d67a7e05d8fabe3dd430b5a82306b Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Tue, 6 Sep 2016 19:02:52 +0300 Subject: [PATCH 20/21] MAGETWO-56077: [GitHub] Unable to add more than 1 product to a cart from Wishlist #5282 --- app/code/Magento/Wishlist/Helper/Data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index 292f66a71baa0..736786e6e30b3 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -449,7 +449,7 @@ protected function _getCartUrlParameters($item) $params = [ 'item' => is_string($item) ? $item : $item->getWishlistItemId(), ]; - if (is_object($item)) { + if ($item instanceof \Magento\Wishlist\Model\Item) { $params['qty'] = $item->getQty(); } return $params; From 10b2dfb3995596dbae86a9ae983231b41af42006 Mon Sep 17 00:00:00 2001 From: Volodymyr Sevostianov Date: Fri, 9 Sep 2016 17:04:38 +0300 Subject: [PATCH 21/21] MAGETWO-56584: [FT] Custom options are not created for product in test --- .../Catalog/Test/Handler/CatalogProductSimple/Webapi.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php index 192cba43d5131..3584477d3f9e7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductSimple/Webapi.php @@ -64,13 +64,6 @@ class Webapi extends AbstractWebApi implements CatalogProductSimpleInterface 'custom_attributes' ]; - /** - * Website Ids for current Product. - * - * @var array - */ - private $websiteIds = []; - /** * @constructor * @param DataInterface $configuration