From d0602d1cf9cf83275b2c91b93cab2882d2f2157c Mon Sep 17 00:00:00 2001 From: Iurii Ivashchenko Date: Fri, 14 Jul 2017 18:57:14 +0300 Subject: [PATCH 01/11] MAGETWO-70641: Impossible create Tax Rule in the Mozilla Firefox and IE --- .../tests/lib/mage/multiselect.test.js | 21 +++++++++++++++++++ lib/web/mage/multiselect.js | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/lib/mage/multiselect.test.js b/dev/tests/js/jasmine/tests/lib/mage/multiselect.test.js index 6171b26cc3ece..4b08fd678b116 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/multiselect.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/multiselect.test.js @@ -133,5 +133,26 @@ define([ expect(instance.data('mage-multiselect2').appendOptions).toHaveBeenCalled(); expect(instance.data('mage-multiselect2').setCurrentPage).toHaveBeenCalledWith(2); }); + + it('multiselect2 item click', function () { + var option = '
', + checkbox; + + $('body').append(option); + + checkbox = $(option).find('input[type="checkbox"]'); + checkbox.on('click', instance.data('mage-multiselect2').onCheck); + + spyOn(instance.data('mage-multiselect2'), '_createSelectedOption').and.returnValue(true); + + checkbox.click(); + + expect(instance.data('mage-multiselect2')._createSelectedOption).toHaveBeenCalledWith({ + value: '1', + label: 'Label' + }); + + $(option).remove(); + }); }); }); diff --git a/lib/web/mage/multiselect.js b/lib/web/mage/multiselect.js index 1ddb719868518..d911bf0943336 100644 --- a/lib/web/mage/multiselect.js +++ b/lib/web/mage/multiselect.js @@ -135,7 +135,7 @@ define([ var checkbox = event.target, option = { value: checkbox.value, - label: $(checkbox.labels[0]).text() + label: $(checkbox).parent('label').text() }; checkbox.checked ? this._createSelectedOption(option) : this._removeSelectedOption(option); @@ -275,7 +275,7 @@ define([ * @private */ _createSelectedOption: function (option) { - var selectOption = new Option(option.value, option.value, false, true); + var selectOption = new Option(option.label, option.value, false, true); this.element.append(selectOption); this.selectedValues.push(option.value); From bc76180b1b97a64da384346e7e16a1551d3a7442 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Tue, 18 Jul 2017 19:59:06 +0300 Subject: [PATCH 02/11] MAGETWO-70743: Custom options are not listed in API call --- .../Quote/Item/CartItemProcessorsPool.php | 3 +- .../Quote/Api/CartItemRepositoryTest.php | 53 ++++++++++++------- ...te_with_items_and_custom_options_saved.php | 45 ++++++++++++++++ 3 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php diff --git a/app/code/Magento/Quote/Model/Quote/Item/CartItemProcessorsPool.php b/app/code/Magento/Quote/Model/Quote/Item/CartItemProcessorsPool.php index ec8dcd87a9ddc..206104af7e75a 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/CartItemProcessorsPool.php +++ b/app/code/Magento/Quote/Model/Quote/Item/CartItemProcessorsPool.php @@ -42,7 +42,8 @@ public function getCartItemProcessors() return $this->cartItemProcessors; } - $arguments = $this->objectManagerConfig->getArguments(\Magento\Quote\Model\Quote\Item\Repository::class); + $typePreference = $this->objectManagerConfig->getPreference(Repository::class); + $arguments = $this->objectManagerConfig->getArguments($typePreference); if (isset($arguments['cartItemProcessors'])) { // Workaround for compiled mode. $processors = isset($arguments['cartItemProcessors']['_vac_']) diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php index 5a1b30bc82f8c..15e10196f878d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php @@ -6,6 +6,9 @@ */ namespace Magento\Quote\Api; +use Magento\Catalog\Model\CustomOptions\CustomOptionProcessor; +use Magento\Framework\Webapi\Rest\Request; +use Magento\Quote\Model\Quote; use Magento\TestFramework\TestCase\WebapiAbstract; class CartItemRepositoryTest extends WebapiAbstract @@ -25,33 +28,43 @@ protected function setUp() } /** - * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php */ public function testGetList() { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); - $quote->load('test_order_item_with_items', 'reserved_order_id'); + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); + $quote->load('test_order_item_with_items_and_custom_options', 'reserved_order_id'); $cartId = $quote->getId(); $output = []; + $customOptionProcessor = $this->objectManager->get(CustomOptionProcessor::class); + /** @var \Magento\Quote\Api\Data\CartItemInterface $item */ foreach ($quote->getAllItems() as $item) { + $customOptionProcessor->processOptions($item); $data = [ - 'item_id' => $item->getItemId(), + 'item_id' => (int)$item->getItemId(), 'sku' => $item->getSku(), 'name' => $item->getName(), - 'price' => $item->getPrice(), - 'qty' => $item->getQty(), + 'price' => (float)$item->getPrice(), + 'qty' => (float)$item->getQty(), 'product_type' => $item->getProductType(), - 'quote_id' => $item->getQuoteId() + 'quote_id' => $item->getQuoteId(), ]; + if ($item->getProductOption() !== null) { + $customOptions = $item->getProductOption()->getExtensionAttributes()->getCustomOptions(); + foreach ($customOptions as $option) { + $data['product_option']['extension_attributes']['custom_options'][] = $option->getData(); + } + } + $output[] = $data; } $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + 'httpMethod' => Request::HTTP_METHOD_GET, ], 'soap' => [ 'service' => self::SERVICE_NAME, @@ -73,14 +86,14 @@ public function testAddItem() /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load(2); $productSku = $product->getSku(); - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); $quote->load('test_order_1', 'reserved_order_id'); $cartId = $quote->getId(); $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + 'httpMethod' => Request::HTTP_METHOD_POST, ], 'soap' => [ 'service' => self::SERVICE_NAME, @@ -106,8 +119,8 @@ public function testAddItem() */ public function testRemoveItem() { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); @@ -117,7 +130,7 @@ public function testRemoveItem() $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items/' . $itemId, - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, + 'httpMethod' => Request::HTTP_METHOD_DELETE, ], 'soap' => [ 'service' => self::SERVICE_NAME, @@ -131,7 +144,7 @@ public function testRemoveItem() "itemId" => $itemId, ]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + $quote = $this->objectManager->create(Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertFalse($quote->hasProductId($productId)); } @@ -141,8 +154,8 @@ public function testRemoveItem() */ public function testUpdateItem() { - /** @var \Magento\Quote\Model\Quote $quote */ - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $cartId = $quote->getId(); $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); @@ -152,7 +165,7 @@ public function testUpdateItem() $serviceInfo = [ 'rest' => [ 'resourcePath' => self::RESOURCE_PATH . $cartId . '/items/' . $itemId, - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, + 'httpMethod' => Request::HTTP_METHOD_PUT, ], 'soap' => [ 'service' => self::SERVICE_NAME, @@ -178,7 +191,7 @@ public function testUpdateItem() ]; } $this->_webApiCall($serviceInfo, $requestData); - $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + $quote = $this->objectManager->create(Quote::class); $quote->load('test_order_item_with_items', 'reserved_order_id'); $this->assertTrue($quote->hasProductId(1)); $item = $quote->getItemByProduct($product); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php new file mode 100644 index 0000000000000..f6dc695544d9d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php @@ -0,0 +1,45 @@ +create(\Magento\Catalog\Api\ProductRepositoryInterface::class); +$product = $productRepository->get('simple'); + +$options = []; +/** @var $option \Magento\Catalog\Model\Product\Option */ +foreach ($product->getOptions() as $option) { + switch ($option->getGroupByType()) { + case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE: + $value = ['year' => 2013, 'month' => 8, 'day' => 9, 'hour' => 13, 'minute' => 35]; + break; + case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT: + $value = key($option->getValues()); + break; + default: + $value = 'test'; + break; + } + $options[$option->getId()] = $value; +} + +$requestInfo = new \Magento\Framework\DataObject(['qty' => 1, 'options' => $options]); + +$quote->setReservedOrderId('test_order_item_with_items_and_custom_options') + ->addProduct($product, $requestInfo); +$quote->collectTotals(); +$objectManager->get(\Magento\Quote\Model\QuoteRepository::class)->save($quote); + +/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ +$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) + ->create(); +$quoteIdMask->setQuoteId($quote->getId()); +$quoteIdMask->setDataChanges(true); +$quoteIdMask->save(); From b9b980c6b2add1dce04ab097162528959b318e2c Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Wed, 19 Jul 2017 11:23:06 +0300 Subject: [PATCH 03/11] MAGETWO-70743: Custom options are not listed in API call --- ...tems_and_custom_options_saved_rollback.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php new file mode 100644 index 0000000000000..91b7e80fe6a1d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php @@ -0,0 +1,20 @@ +get(\Magento\Framework\Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); +$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); +$quote->load('test_order_item_with_items_and_custom_options', 'reserved_order_id'); +$quoteId = $quote->getId(); +if ($quote->getId()) { + $quote->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +require __DIR__ . '/../../Checkout/_files/quote_with_address_rollback.php'; From 1b7e4fbe160c5119a53d77402c16d351b2308f93 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Thu, 20 Jul 2017 10:49:57 +0300 Subject: [PATCH 04/11] MAGETWO-70743: Custom options are not listed in API call --- ...te_with_items_and_custom_options_saved_rollback.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php index 91b7e80fe6a1d..cb1fd1f4b15aa 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php @@ -4,17 +4,13 @@ * See COPYING.txt for license details. */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$registry = $objectManager->get(\Magento\Framework\Registry::class); -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); + +/** @var \Magento\Quote\Model\Quote $quote */ $quote = $objectManager->create(\Magento\Quote\Model\Quote::class); $quote->load('test_order_item_with_items_and_custom_options', 'reserved_order_id'); $quoteId = $quote->getId(); if ($quote->getId()) { - $quote->delete(); + $objectManager->get(\Magento\Quote\Model\QuoteRepository::class)->delete($quote); } -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); - require __DIR__ . '/../../Checkout/_files/quote_with_address_rollback.php'; From 1484fa5814b6deca3128bd8340242d08c119b9c1 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Fri, 21 Jul 2017 17:07:30 +0300 Subject: [PATCH 05/11] MAGETWO-70844: DHL provider not available - Fixed issue with \Zend_Measure_Weight \Zend_Measure_Length that throw exception if value argument is string --- app/code/Magento/Dhl/Model/Carrier.php | 10 ++++----- .../Dhl/Test/Unit/Model/CarrierTest.php | 21 +++++++++++++++++-- app/code/Magento/Usps/Model/Carrier.php | 14 ++++++------- .../Usps/Test/Unit/Model/CarrierTest.php | 18 +++++++++++++++- 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 0be528396d4e8..976a74431da31 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -670,7 +670,7 @@ protected function _getWeight($weight, $maxWeight = false, $configWeightUnit = f if ($configWeightUnit != $countryWeightUnit) { $weight = $this->_carrierHelper->convertMeasureWeight( - sprintf('%.3f', $weight), + (float)$weight, $configWeightUnit, $countryWeightUnit ); @@ -870,7 +870,7 @@ protected function _getDimension($dimension, $configWeightUnit = false) if ($configDimensionUnit != $countryDimensionUnit) { $dimension = $this->_carrierHelper->convertMeasureDimension( - sprintf('%.3f', $dimension), + (float)$dimension, $configDimensionUnit, $countryDimensionUnit ); @@ -889,9 +889,9 @@ protected function _addDimension($nodePiece) { $sizeChecker = (string)$this->getConfigData('size'); - $height = $this->_getDimension((string)$this->getConfigData('height')); - $depth = $this->_getDimension((string)$this->getConfigData('depth')); - $width = $this->_getDimension((string)$this->getConfigData('width')); + $height = $this->_getDimension((float)$this->getConfigData('height')); + $depth = $this->_getDimension((float)$this->getConfigData('depth')); + $width = $this->_getDimension((float)$this->getConfigData('width')); if ($sizeChecker && $height && $depth && $width) { $nodePiece->addChild('Height', $height); diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 0dc04ba4fbaca..76721c075a813 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -167,6 +167,15 @@ function ($data) { $this->errorFactory->expects($this->any())->method('create')->willReturn($this->error); + $localeResolver = $this->getMockForAbstractClass(\Magento\Framework\Locale\ResolverInterface::class); + $localeResolver->method('getLocale')->willReturn('fr_FR'); + + $carrierHelper = $this->objectManager->getObject( + \Magento\Shipping\Helper\Carrier::class, + [ + 'localeResolver' => $localeResolver + ] + ); $this->model = $this->objectManager->getObject( \Magento\Dhl\Model\Carrier::class, [ @@ -179,6 +188,7 @@ function ($data) { 'httpClientFactory' => $httpClientFactory, 'readFactory' => $readFactory, 'storeManager' => $storeManager, + 'carrierHelper' => $carrierHelper, 'data' => ['id' => 'dhl', 'store' => '1'] ] ); @@ -205,7 +215,11 @@ public function scopeConfigGetValue($path) 'carriers/dhl/showmethod' => 1, 'carriers/dhl/title' => 'dhl Title', 'carriers/dhl/specificerrmsg' => 'dhl error message', - 'carriers/dhl/unit_of_measure' => 'L', + 'carriers/dhl/unit_of_measure' => 'K', + 'carriers/dhl/size' => '1', + 'carriers/dhl/height' => '1.6', + 'carriers/dhl/width' => '1.6', + 'carriers/dhl/depth' => '1.6', ]; return isset($pathMap[$path]) ? $pathMap[$path] : null; } @@ -280,7 +294,10 @@ public function testCollectRates() $rawPostData->setAccessible(true); self::assertNotEmpty($this->model->collectRates($request)->getAllRates()); - self::assertContains('8.266', $rawPostData->getValue($this->httpClient)); + self::assertContains('18.223', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); } public function testCollectRatesErrorMessage() diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 4fab92e1f3e6a..8cf067899ad61 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -1432,7 +1432,7 @@ protected function _formUsExpressShipmentRequest(\Magento\Framework\DataObject $ if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::OUNCE) { $packageWeight = round( $this->_carrierHelper->convertMeasureWeight( - $request->getPackageWeight(), + (float)$request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::OUNCE ) @@ -1526,7 +1526,7 @@ protected function _formUsSignatureConfirmationShipmentRequest(\Magento\Framewor if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::OUNCE) { $packageWeight = round( $this->_carrierHelper->convertMeasureWeight( - $request->getPackageWeight(), + (float)$request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::OUNCE ) @@ -1609,7 +1609,7 @@ protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $reque $packageWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != \Zend_Measure_Weight::POUND) { $packageWeight = $this->_carrierHelper->convertMeasureWeight( - $request->getPackageWeight(), + (float)$request->getPackageWeight(), $packageParams->getWeightUnits(), \Zend_Measure_Weight::POUND ); @@ -1617,21 +1617,21 @@ protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $reque if ($packageParams->getDimensionUnits() != \Zend_Measure_Length::INCH) { $length = round( $this->_carrierHelper->convertMeasureDimension( - $packageParams->getLength(), + (float)$packageParams->getLength(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH ) ); $width = round( $this->_carrierHelper->convertMeasureDimension( - $packageParams->getWidth(), + (float)$packageParams->getWidth(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH ) ); $height = round( $this->_carrierHelper->convertMeasureDimension( - $packageParams->getHeight(), + (float)$packageParams->getHeight(), $packageParams->getDimensionUnits(), \Zend_Measure_Length::INCH ) @@ -1640,7 +1640,7 @@ protected function _formIntlShipmentRequest(\Magento\Framework\DataObject $reque if ($packageParams->getGirthDimensionUnits() != \Zend_Measure_Length::INCH) { $girth = round( $this->_carrierHelper->convertMeasureDimension( - $packageParams->getGirth(), + (float)$packageParams->getGirth(), $packageParams->getGirthDimensionUnits(), \Zend_Measure_Length::INCH ) diff --git a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php index fb6b68ef1da7e..cb9f7732a2bbe 100644 --- a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php @@ -153,6 +153,15 @@ function ($data) { $this->errorFactory->expects($this->any())->method('create')->willReturn($this->error); + $localeResolver = $this->getMockForAbstractClass(\Magento\Framework\Locale\ResolverInterface::class); + $localeResolver->method('getLocale')->willReturn('fr_FR'); + $carrierHelper = $this->objectManager->getObject( + \Magento\Shipping\Helper\Carrier::class, + [ + 'localeResolver' => $localeResolver + ] + ); + $arguments = [ 'scopeConfig' => $this->scope, 'xmlSecurity' => new \Magento\Framework\Xml\Security(), @@ -162,7 +171,7 @@ function ($data) { 'httpClientFactory' => $httpClientFactory, 'data' => $data, 'rateErrorFactory' => $this->errorFactory, - + 'carrierHelper' => $carrierHelper, ]; $this->dataHelper = $this->getMockBuilder(DataHelper::class) @@ -246,6 +255,13 @@ public function testReturnOfShipment() \Magento\Shipping\Model\Shipment\ReturnShipment::class, require __DIR__ . '/_files/return_shipment_request_data.php' ); + $this->httpClient->expects(self::exactly(2)) + ->method('setParameterGet') + ->withConsecutive( + ['API', 'SignatureConfirmationCertifyV3'], + ['XML', $this->stringContains('80')] + ); + $this->assertNotEmpty($this->carrier->returnOfShipment($request)->getInfo()[0]['tracking_number']); } From 7e822e1438a147c36f19c7b2614cff82d14e8c69 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Mon, 24 Jul 2017 19:31:00 +0300 Subject: [PATCH 06/11] MAGETWO-70743: Custom options are not listed in API call - Extend test to cover all custom options types --- .../Catalog/_files/product_with_options.php | 12 ++++-- .../Checkout/_files/ValidatorFileMock.php | 41 +++++++++++++++++++ ...te_with_items_and_custom_options_saved.php | 15 +++++-- ...tems_and_custom_options_saved_rollback.php | 1 + 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options.php index 5311ddee9072e..6c609a12f1228 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_options.php @@ -35,10 +35,10 @@ true )->setStockData( [ - 'qty' => 0, - 'is_in_stock' => 0 + 'qty' => 100, + 'is_in_stock' => 1 ] -); +)->setHasOptions(true); $options = [ [ @@ -204,4 +204,8 @@ $customOptions[] = $customOption; } -$product->setOptions($customOptions)->save(); +$product->setOptions($customOptions); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryFactory */ +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php new file mode 100644 index 0000000000000..8b4bb76af83c0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php @@ -0,0 +1,41 @@ + 'image/jpeg', + 'title' => "test.jpg", + 'quote_path' => "custom_options/quote/s/t/4624d2.jpg", + 'order_path' => "custom_options/order/s/t/89d25b4624d2.jpg", + "fullpath" => "pub/media/custom_options/quote/s/t/e47389d25b4624d2.jpg", + "size"=> "71901", + "width" => 5, + "height" => 5, + "secret_key" => "10839ec1631b77e5e473", + ]; + $instance = $this->getMockBuilder(ValidatorFile::class) + ->disableOriginalConstructor() + ->getMock(); + $instance->method('SetProduct')->willReturnSelf(); + $instance->method('validate')->willReturn($userValue); + + return $instance; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php index f6dc695544d9d..fc27209ede5ab 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved.php @@ -4,8 +4,11 @@ * See COPYING.txt for license details. */ +use Magento\Checkout\_files\ValidatorFileMock; + require __DIR__ . '/../../Checkout/_files/quote_with_address.php'; -require __DIR__ . '/../../Catalog/_files/product_simple.php'; +require __DIR__ . '/../../Catalog/_files/product_with_options.php'; +require __DIR__ . '/../../Checkout/_files/ValidatorFileMock.php'; $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ @@ -22,6 +25,9 @@ case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT: $value = key($option->getValues()); break; + case \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_FILE: + $value = 'test.jpg'; + break; default: $value = 'test'; break; @@ -30,9 +36,12 @@ } $requestInfo = new \Magento\Framework\DataObject(['qty' => 1, 'options' => $options]); +$validatorFile = (new ValidatorFileMock())->getInstance(); +$objectManager->addSharedInstance($validatorFile, \Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile::class); + -$quote->setReservedOrderId('test_order_item_with_items_and_custom_options') - ->addProduct($product, $requestInfo); +$quote->setReservedOrderId('test_order_item_with_items_and_custom_options'); +$quote->addProduct($product, $requestInfo); $quote->collectTotals(); $objectManager->get(\Magento\Quote\Model\QuoteRepository::class)->save($quote); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php index cb1fd1f4b15aa..ca7467d3fc02b 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_items_and_custom_options_saved_rollback.php @@ -4,6 +4,7 @@ * See COPYING.txt for license details. */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$objectManager->removeSharedInstance(\Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile::class); /** @var \Magento\Quote\Model\Quote $quote */ $quote = $objectManager->create(\Magento\Quote\Model\Quote::class); From cf9ea5ba6e10a5a4d179a3b5778875c3d635277b Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Fri, 14 Jul 2017 13:00:20 +0300 Subject: [PATCH 07/11] MAGETWO-68969: sales_sequence_meta table contents are different depending on whether Magento was upgraded vs installed - Replace InstallData with RecurringData since we need this functionality during install and upgrade flows --- .../Setup/{InstallData.php => RecurringData.php} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename app/code/Magento/SalesSequence/Setup/{InstallData.php => RecurringData.php} (91%) diff --git a/app/code/Magento/SalesSequence/Setup/InstallData.php b/app/code/Magento/SalesSequence/Setup/RecurringData.php similarity index 91% rename from app/code/Magento/SalesSequence/Setup/InstallData.php rename to app/code/Magento/SalesSequence/Setup/RecurringData.php index c5a43361e4333..06f92b75d3fdd 100644 --- a/app/code/Magento/SalesSequence/Setup/InstallData.php +++ b/app/code/Magento/SalesSequence/Setup/RecurringData.php @@ -14,11 +14,9 @@ use Magento\SalesSequence\Model\EntityPool; /** - * Class InstallData - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @codeCoverageIgnore + * Recurring data upgrade for SalesSequence module. */ -class InstallData implements InstallDataInterface +class RecurringData implements InstallDataInterface { /** * Sales setup factory @@ -54,7 +52,6 @@ public function __construct( /** * {@inheritdoc} - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { From 01a7214b1705e2401493550f55a6901829dfc8b5 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Fri, 28 Jul 2017 18:32:26 +0300 Subject: [PATCH 08/11] MAGETWO-68969: sales_sequence_meta table contents are different depending on whether Magento was upgraded vs installed - Add UpgradeData instead RecurringData since we need this functionality during install and upgrade flows --- .../SalesSequence/Setup/InstallData.php | 38 +++++++++++++++++++ ...{RecurringData.php => SequenceCreator.php} | 11 ++---- .../SalesSequence/Setup/UpgradeData.php | 38 +++++++++++++++++++ 3 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 app/code/Magento/SalesSequence/Setup/InstallData.php rename app/code/Magento/SalesSequence/Setup/{RecurringData.php => SequenceCreator.php} (82%) create mode 100644 app/code/Magento/SalesSequence/Setup/UpgradeData.php diff --git a/app/code/Magento/SalesSequence/Setup/InstallData.php b/app/code/Magento/SalesSequence/Setup/InstallData.php new file mode 100644 index 0000000000000..5c07c37908760 --- /dev/null +++ b/app/code/Magento/SalesSequence/Setup/InstallData.php @@ -0,0 +1,38 @@ +sequenceCreator = $sequenceCreator; + } + + /** + * {@inheritdoc} + */ + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + $this->sequenceCreator->create(); + } +} diff --git a/app/code/Magento/SalesSequence/Setup/RecurringData.php b/app/code/Magento/SalesSequence/Setup/SequenceCreator.php similarity index 82% rename from app/code/Magento/SalesSequence/Setup/RecurringData.php rename to app/code/Magento/SalesSequence/Setup/SequenceCreator.php index 06f92b75d3fdd..b0cbf545957bd 100644 --- a/app/code/Magento/SalesSequence/Setup/RecurringData.php +++ b/app/code/Magento/SalesSequence/Setup/SequenceCreator.php @@ -6,17 +6,14 @@ namespace Magento\SalesSequence\Setup; -use Magento\Framework\Setup\InstallDataInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\SalesSequence\Model\Builder; use Magento\SalesSequence\Model\Config as SequenceConfig; use Magento\SalesSequence\Model\EntityPool; /** - * Recurring data upgrade for SalesSequence module. + * Initial creating sequences. */ -class RecurringData implements InstallDataInterface +class SequenceCreator { /** * Sales setup factory @@ -51,9 +48,9 @@ public function __construct( } /** - * {@inheritdoc} + * Creates sales sequences. */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + public function create() { $defaultStoreIds = [0, 1]; foreach ($defaultStoreIds as $storeId) { diff --git a/app/code/Magento/SalesSequence/Setup/UpgradeData.php b/app/code/Magento/SalesSequence/Setup/UpgradeData.php new file mode 100644 index 0000000000000..575ef327ae74c --- /dev/null +++ b/app/code/Magento/SalesSequence/Setup/UpgradeData.php @@ -0,0 +1,38 @@ +sequenceCreator = $sequenceCreator; + } + + /** + * {@inheritdoc} + */ + public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + $this->sequenceCreator->create(); + } +} From 33277b09f5ee0e933a7a1d00fc04f9100105c771 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Mon, 31 Jul 2017 09:53:25 +0300 Subject: [PATCH 09/11] MAGETWO-68969: sales_sequence_meta table contents are different depending on whether Magento was upgraded vs installed - Add RecurringData instead UpgradeData since we need this functionality during install and upgrade flows --- .../Setup/{UpgradeData.php => RecurringData.php} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename app/code/Magento/SalesSequence/Setup/{UpgradeData.php => RecurringData.php} (81%) diff --git a/app/code/Magento/SalesSequence/Setup/UpgradeData.php b/app/code/Magento/SalesSequence/Setup/RecurringData.php similarity index 81% rename from app/code/Magento/SalesSequence/Setup/UpgradeData.php rename to app/code/Magento/SalesSequence/Setup/RecurringData.php index 575ef327ae74c..d190bad6f67c6 100644 --- a/app/code/Magento/SalesSequence/Setup/UpgradeData.php +++ b/app/code/Magento/SalesSequence/Setup/RecurringData.php @@ -5,14 +5,14 @@ */ namespace Magento\SalesSequence\Setup; -use Magento\Framework\Setup\UpgradeDataInterface; +use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; /** * Recurring data upgrade for SalesSequence module. */ -class UpgradeData implements UpgradeDataInterface +class RecurringData implements InstallDataInterface { /** * @var SequenceCreator @@ -31,7 +31,7 @@ public function __construct( /** * {@inheritdoc} */ - public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $this->sequenceCreator->create(); } From c09ce937ed57d79c22ac86532041b90c558b1b62 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Wed, 2 Aug 2017 10:55:20 +0300 Subject: [PATCH 10/11] MAGETWO-71174: Update doc block information in php classes with @deprecated and @since tags - Fix static tests --- .../Model/ResourceModel/Indexer/ActiveTableSwitcher.php | 8 ++++++-- .../Magento/Config/Model/Config/Backend/Admin/Custom.php | 2 +- app/code/Magento/Deploy/Model/Filesystem.php | 3 ++- app/code/Magento/UrlRewrite/Controller/Router.php | 2 +- app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php | 2 +- app/code/Magento/Webapi/Model/Rest/Config.php | 2 +- app/code/Magento/Webapi/Model/Soap/Fault.php | 2 +- .../App/Response/HeaderProvider/XssProtection.php | 2 +- lib/internal/Magento/Framework/Pricing/Render.php | 2 -- lib/internal/Magento/Framework/Setup/FilePermissions.php | 3 ++- lib/internal/Magento/Framework/View/Asset/Source.php | 3 ++- .../Magento/Setup/Console/Command/InfoAdminUriCommand.php | 4 ++-- 12 files changed, 20 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Indexer/ActiveTableSwitcher.php b/app/code/Magento/Catalog/Model/ResourceModel/Indexer/ActiveTableSwitcher.php index fabd629559cf7..de37b68d76503 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Indexer/ActiveTableSwitcher.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Indexer/ActiveTableSwitcher.php @@ -12,13 +12,17 @@ class ActiveTableSwitcher { /** - * @var + * Suffix for replica index table. + * + * @var string * @since 2.2.0 */ private $additionalTableSuffix = '_replica'; /** - * @var + * Suffix for outdated index table. + * + * @var string * @since 2.2.0 */ private $outdatedTableSuffix = '_outdated'; diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php index 04c063700f751..b11197aad0ef6 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php @@ -55,7 +55,7 @@ class Custom extends \Magento\Framework\App\Config\Value const XML_PATH_PAYMENT = 'payment'; /** - * @var + * @var \Magento\Framework\App\Config\Storage\WriterInterface * @since 2.0.0 */ protected $_configWriter; diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 1e07d16bb3018..3314e560fc406 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -350,7 +350,8 @@ protected function changePermissions($directoryCodeList, $dirPermissions, $fileP * Change permissions on static resources * * @return void - * @deprecated 2.1.0 As magento2 doesn't control indirectly the access permissions to the files and directories anymore. + * @deprecated 2.1.0 As magento2 doesn't control indirectly the access permissions to the files + * and directories anymore. * Access permissions to the files and directories are set during deploy Magento 2, directly after * uploading code of Magento. Also it is possible to specify the value * of inverse mask for setting access permissions to files and directories generated by Magento. diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php index 63a0bf11fe44d..27c8af7296894 100644 --- a/app/code/Magento/UrlRewrite/Controller/Router.php +++ b/app/code/Magento/UrlRewrite/Controller/Router.php @@ -19,7 +19,7 @@ class Router implements \Magento\Framework\App\RouterInterface { /** - * @var + * @var \Magento\Framework\App\ActionFactory * @since 2.0.0 */ protected $actionFactory; diff --git a/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php b/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php index 9cc116e991b39..09d863ef46bcb 100644 --- a/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php +++ b/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php @@ -37,7 +37,7 @@ abstract class AbstractSchemaGenerator /** * @var ServiceMetadata - * @since 2.0.0 + * @since 2.0.0 */ protected $serviceMetadata; diff --git a/app/code/Magento/Webapi/Model/Rest/Config.php b/app/code/Magento/Webapi/Model/Rest/Config.php index eb4cf69ef6324..e0d400422fe42 100644 --- a/app/code/Magento/Webapi/Model/Rest/Config.php +++ b/app/code/Magento/Webapi/Model/Rest/Config.php @@ -36,7 +36,7 @@ class Config /*#@-*/ /** - * @var + * @var ModelConfig * @since 2.0.0 */ protected $_config; diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php index 4250c07152624..9b210e208b0d5 100644 --- a/app/code/Magento/Webapi/Model/Soap/Fault.php +++ b/app/code/Magento/Webapi/Model/Soap/Fault.php @@ -45,7 +45,7 @@ class Fault /**#@-*/ /** - * @var + * @var string * @since 2.0.0 */ protected $_soapFaultCode; diff --git a/lib/internal/Magento/Framework/App/Response/HeaderProvider/XssProtection.php b/lib/internal/Magento/Framework/App/Response/HeaderProvider/XssProtection.php index 3c7e18abd2e33..ba2dc23c0e688 100644 --- a/lib/internal/Magento/Framework/App/Response/HeaderProvider/XssProtection.php +++ b/lib/internal/Magento/Framework/App/Response/HeaderProvider/XssProtection.php @@ -16,7 +16,7 @@ class XssProtection extends AbstractHeaderProvider { /** - * @var + * @var string * @since 2.1.0 */ protected $headerName = 'X-XSS-Protection'; diff --git a/lib/internal/Magento/Framework/Pricing/Render.php b/lib/internal/Magento/Framework/Pricing/Render.php index 0863bf310b464..0a966242b6900 100644 --- a/lib/internal/Magento/Framework/Pricing/Render.php +++ b/lib/internal/Magento/Framework/Pricing/Render.php @@ -33,10 +33,8 @@ class Render extends AbstractBlock const ZONE_EMAIL = 'email'; const ZONE_CART = 'cart'; const ZONE_DEFAULT = null; - /**#@-*/ - /** * Default type renderer * diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php index 3c34260e1950d..cc9110b01adba 100644 --- a/lib/internal/Magento/Framework/Setup/FilePermissions.php +++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php @@ -309,7 +309,8 @@ public function getMissingWritableDirectoriesForDbUpgrade() /** * Checks writable directories for installation * - * @deprecated 2.1.0 Use getMissingWritablePathsForInstallation() to get all missing writable paths required for install + * @deprecated 2.1.0 Use getMissingWritablePathsForInstallation() + * to get all missing writable paths required for install. * @return array * @since 2.1.0 */ diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index 3ddeeb302070c..603a884985546 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -290,7 +290,8 @@ private function findFile(LocalInterface $asset, \Magento\Framework\View\Asset\F * @param \Magento\Framework\View\Asset\LocalInterface $asset * * @return bool|string - * @deprecated 2.1.0 If custom vendor directory is outside Magento root, then this method will return unexpected result + * @deprecated 2.1.0 If custom vendor directory is outside Magento root, + * then this method will return unexpected result. * @since 2.0.0 */ public function findRelativeSourceFilePath(LocalInterface $asset) diff --git a/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php b/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php index b4101f38b3a22..75e5275c385a8 100644 --- a/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InfoAdminUriCommand.php @@ -52,9 +52,9 @@ protected function configure() } /** - * {@inheritdoc} + * {@inheritdoc} * @since 2.0.0 - */ + */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln( From f17a1c2c81d6f3aa1c522e4bb5db5c29000ae539 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Wed, 2 Aug 2017 11:50:22 +0300 Subject: [PATCH 11/11] MAGETWO-71174: Update doc block information in php classes with @deprecated and @since tags - Fix static tests --- app/code/Magento/Deploy/Model/Filesystem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 3314e560fc406..7c8600b80519b 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -325,7 +325,8 @@ public function cleanupFilesystem($directoryCodeList) * @param int $dirPermissions * @param int $filePermissions * @return void - * @deprecated 2.1.0 As magento2 doesn't control indirectly the access permissions to the files and directories anymore. + * @deprecated 2.1.0 As magento2 doesn't control indirectly + * the access permissions to the files and directories anymore. * Access permissions to the files and directories are set during deploy Magento 2, directly after * uploading code of Magento. Also it is possible to specify the value * of inverse mask for setting access permissions to files and directories generated by Magento.