From bff262dc6a13da40fadb86d6afc68e4002349bdd Mon Sep 17 00:00:00 2001 From: federeggiani Date: Thu, 19 Sep 2019 15:43:08 +0200 Subject: [PATCH 01/43] Fix error in configurables Problem with configurables when the simple products that were associated did not have a value for the configurable attribute. Fix this issue https://github.com/magento/magento2/issues/14240 --- .../Model/Product/Type/VariationMatrix.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 979587dc500a..691f34ead9d6 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -40,7 +40,9 @@ public function getVariations($usedProductAttributes) for ($attributeIndex = $attributesCount; $attributeIndex--;) { $currentAttribute = $variationalAttributes[$attributeIndex]; $currentVariationValue = $currentVariation[$attributeIndex]; - $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; + if(isset($currentAttribute['id']) && $currentAttribute['id']) { + $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; + } } $variations[] = $filledVariation; From d16dd4cacae81fac4ead4629e32ad85c829c31c0 Mon Sep 17 00:00:00 2001 From: federeggiani Date: Sat, 21 Sep 2019 14:34:53 +0200 Subject: [PATCH 02/43] Improve code, a bit --- .../ConfigurableProduct/Model/Product/Type/VariationMatrix.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 691f34ead9d6..e7da5ccd6cdf 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -40,7 +40,7 @@ public function getVariations($usedProductAttributes) for ($attributeIndex = $attributesCount; $attributeIndex--;) { $currentAttribute = $variationalAttributes[$attributeIndex]; $currentVariationValue = $currentVariation[$attributeIndex]; - if(isset($currentAttribute['id']) && $currentAttribute['id']) { + if(!empty($currentAttribute['id'])) { $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; } } From 81a542b7ed6fc9db6715475f047906767d06775c Mon Sep 17 00:00:00 2001 From: Thomas Klein Date: Thu, 27 Jun 2019 17:46:49 +0200 Subject: [PATCH 03/43] Fix alias in grid massaction for eav collections --- .../Grid/Massaction/AbstractMassaction.php | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 891b2a3ada72..e6a51beedbfb 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -3,26 +3,36 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Backend\Block\Widget\Grid\Massaction; +use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget; +use Magento\Backend\Block\Widget\Grid\Column; +use Magento\Backend\Block\Widget\Grid\ColumnSet; use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\DataObject; +use Magento\Framework\DB\Select; +use Magento\Framework\Json\EncoderInterface; +use Magento\Quote\Model\Quote; +use function count; +use function is_array; /** * Grid widget massaction block * * @api - * @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors + * @method Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() * @deprecated 100.2.0 in favour of UI component implementation * @since 100.0.2 */ -abstract class AbstractMassaction extends \Magento\Backend\Block\Widget +abstract class AbstractMassaction extends Widget { /** - * @var \Magento\Framework\Json\EncoderInterface + * @var EncoderInterface */ protected $_jsonEncoder; @@ -39,13 +49,13 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget protected $_template = 'Magento_Backend::widget/grid/massaction.phtml'; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder + * @param Context $context + * @param EncoderInterface $jsonEncoder * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Json\EncoderInterface $jsonEncoder, + Context $context, + EncoderInterface $jsonEncoder, array $data = [] ) { $this->_jsonEncoder = $jsonEncoder; @@ -118,15 +128,11 @@ private function isVisible(DataObject $item) * Retrieve massaction item with id $itemId * * @param string $itemId - * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item|null + * @return Item|null */ public function getItem($itemId) { - if (isset($this->_items[$itemId])) { - return $this->_items[$itemId]; - } - - return null; + return $this->_items[$itemId] ?? null; } /** @@ -161,7 +167,7 @@ public function getItemsJson() */ public function getCount() { - return sizeof($this->_items); + return count($this->_items); } /** @@ -288,11 +294,11 @@ public function getGridIdsJson() if ($collection instanceof AbstractDb) { $idsSelect = clone $collection->getSelect(); - $idsSelect->reset(\Magento\Framework\DB\Select::ORDER); - $idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT); - $idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET); - $idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS); - $idsSelect->columns($this->getMassactionIdField(), 'main_table'); + $idsSelect->reset(Select::ORDER); + $idsSelect->reset(Select::LIMIT_COUNT); + $idsSelect->reset(Select::LIMIT_OFFSET); + $idsSelect->reset(Select::COLUMNS); + $idsSelect->columns($this->getMassactionIdField()); $idList = $collection->getConnection()->fetchCol($idsSelect); } else { $idList = $collection->setPageSize(0)->getColumnValues($this->getMassactionIdField()); @@ -358,7 +364,7 @@ public function prepareMassactionColumn() { $columnId = 'massaction'; $massactionColumn = $this->getLayout()->createBlock( - \Magento\Backend\Block\Widget\Grid\Column::class + Column::class )->setData( [ 'index' => $this->getMassactionIdField(), @@ -378,7 +384,7 @@ public function prepareMassactionColumn() $gridBlock = $this->getParentBlock(); $massactionColumn->setSelected($this->getSelected())->setGrid($gridBlock)->setId($columnId); - /** @var $columnSetBlock \Magento\Backend\Block\Widget\Grid\ColumnSet */ + /** @var $columnSetBlock ColumnSet */ $columnSetBlock = $gridBlock->getColumnSet(); $childNames = $columnSetBlock->getChildNames(); $siblingElement = count($childNames) ? current($childNames) : 0; From 218c16459e07c0b072c2949cae1a9f0b9f0a7754 Mon Sep 17 00:00:00 2001 From: Ivan Koliadynskyy Date: Fri, 27 Sep 2019 17:35:07 +0300 Subject: [PATCH 04/43] https://github.com/magento/magento2/issues/24716 Not Able to set Rest API oAuth admin token expire in minutes or seconds. #24716 --- app/code/Magento/Integration/Helper/Oauth/Data.php | 12 ++++++------ .../Webapi/Model/Authorization/TokenUserContext.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Integration/Helper/Oauth/Data.php b/app/code/Magento/Integration/Helper/Oauth/Data.php index de074055efa2..5bceec83366e 100644 --- a/app/code/Magento/Integration/Helper/Oauth/Data.php +++ b/app/code/Magento/Integration/Helper/Oauth/Data.php @@ -116,22 +116,22 @@ public function getConsumerPostTimeout() /** * Get customer token lifetime from config. * - * @return int hours + * @return string hours */ public function getCustomerTokenLifetime() { - $hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); - return $hours > 0 ? $hours : 0; + $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); + return is_numeric($hours) ? $hours : 0; } /** * Get customer token lifetime from config. * - * @return int hours + * @return string hours */ public function getAdminTokenLifetime() { - $hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/admin'); - return $hours > 0 ? $hours : 0; + $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/admin'); + return is_numeric($hours) ? $hours : 0; } } diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php index d89513b50c9c..cc8da17e7f52 100644 --- a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php +++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php @@ -137,7 +137,7 @@ private function isTokenExpired(Token $token): bool return false; } - if ($this->dateTime->strToTime($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { + if ($this->date->timestamp($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { return true; } From c283bba9d737ffc426d2f24fa60b4d9743063aed Mon Sep 17 00:00:00 2001 From: Ivan Koliadynskyy Date: Sat, 28 Sep 2019 00:10:18 +0300 Subject: [PATCH 05/43] Fix return type in comments --- app/code/Magento/Integration/Helper/Oauth/Data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Integration/Helper/Oauth/Data.php b/app/code/Magento/Integration/Helper/Oauth/Data.php index 5bceec83366e..d14bc0f9355a 100644 --- a/app/code/Magento/Integration/Helper/Oauth/Data.php +++ b/app/code/Magento/Integration/Helper/Oauth/Data.php @@ -116,7 +116,7 @@ public function getConsumerPostTimeout() /** * Get customer token lifetime from config. * - * @return string hours + * @return numeric hours */ public function getCustomerTokenLifetime() { @@ -127,7 +127,7 @@ public function getCustomerTokenLifetime() /** * Get customer token lifetime from config. * - * @return string hours + * @return numeric hours */ public function getAdminTokenLifetime() { From 13ca551d457546c5b9e2d95ddefd66fb3eead53d Mon Sep 17 00:00:00 2001 From: Valerii Naida Date: Mon, 30 Sep 2019 11:41:54 -0500 Subject: [PATCH 06/43] #async-import/issues/207: Provide the ability to check errors in WebAPI tests in a single approach for different adapters (SOAP/REST) --- .../TestFramework/TestCase/WebapiAbstract.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php index 9ad051b686d4..eecca0a396a0 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php @@ -7,6 +7,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; +use Magento\Framework\Webapi\Exception as WebapiException; use Magento\Webapi\Model\Soap\Fault; use Magento\TestFramework\Helper\Bootstrap; @@ -671,6 +672,12 @@ protected function _checkWrappedErrors($expectedWrappedErrors, $errorDetails) */ private function getActualWrappedErrors(\stdClass $errorNode) { + if (!isset($errorNode->parameters)) { + return [ + 'message' => $errorNode->message, + ]; + } + $actualParameters = []; $parameterNode = $errorNode->parameters->parameter; if (is_array($parameterNode)) { @@ -686,4 +693,40 @@ private function getActualWrappedErrors(\stdClass $errorNode) 'params' => $actualParameters, ]; } + + /** + * @param array $serviceInfo + * @param array $data + * @param array $expectedErrorData + * @return void + * @throws \Exception + */ + protected function assertWebApiCallErrors(array $serviceInfo, array $data, array $expectedErrorData) + { + try { + $this->_webApiCall($serviceInfo, $data); + $this->fail('Expected throwing exception'); + } catch (\Exception $e) { + if (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST) { + self::assertEquals($expectedErrorData, $this->processRestExceptionResult($e)); + self::assertEquals(WebapiException::HTTP_BAD_REQUEST, $e->getCode()); + } elseif (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) { + $this->assertInstanceOf('SoapFault', $e); + $expectedWrappedErrors = []; + foreach ($expectedErrorData['errors'] as $error) { + // @see \Magento\TestFramework\TestCase\WebapiAbstract::getActualWrappedErrors() + $expectedWrappedError = [ + 'message' => $error['message'], + ]; + if (isset($error['parameters'])) { + $expectedWrappedError['params'] = $error['parameters']; + } + $expectedWrappedErrors[] = $expectedWrappedError; + } + $this->checkSoapFault($e, $expectedErrorData['message'], 'env:Sender', [], $expectedWrappedErrors); + } else { + throw $e; + } + } + } } From 0bda8d0248923c9409e76fe4378667e26f030a86 Mon Sep 17 00:00:00 2001 From: Ivan Koliadynskyy Date: Mon, 30 Sep 2019 22:05:40 +0300 Subject: [PATCH 07/43] Minor updates for resolving errors on tests run --- .../Webapi/Model/Authorization/TokenUserContext.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php index cc8da17e7f52..5c54c8b8660d 100644 --- a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php +++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php @@ -99,7 +99,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getUserId() { @@ -108,7 +108,7 @@ public function getUserId() } /** - * {@inheritdoc} + * @inheritdoc */ public function getUserType() { @@ -137,7 +137,7 @@ private function isTokenExpired(Token $token): bool return false; } - if ($this->date->timestamp($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { + if (strtotime($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { return true; } @@ -187,6 +187,8 @@ protected function processRequest() } /** + * Set user data based on user type received from token data. + * * @param Token $token * @return void */ From f15b76fcf0342b2b320037b5f913ba274f4f3d6d Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Mon, 30 Sep 2019 14:29:15 -0500 Subject: [PATCH 08/43] Minor changes --- .../Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index e6a51beedbfb..524261bd88e6 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -17,8 +17,6 @@ use Magento\Framework\DB\Select; use Magento\Framework\Json\EncoderInterface; use Magento\Quote\Model\Quote; -use function count; -use function is_array; /** * Grid widget massaction block From a6cec0ae32858439c2812ca32e4711be44e7a8a2 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 1 Oct 2019 12:15:01 +0300 Subject: [PATCH 09/43] magento/magento2#23452: Static test fix. --- .../Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 524261bd88e6..79597e07be76 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -21,6 +21,7 @@ /** * Grid widget massaction block * + * phpcs:disable Magento2.Classes.AbstractApi * @api * @method Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() From ab04d7e7a79aa2ac15075243cc450a38baea3f74 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 1 Oct 2019 13:51:06 +0300 Subject: [PATCH 10/43] magento/magento2#23452: Added unit test. --- .../Unit/Block/Widget/Grid/MassactionTest.php | 73 ++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index e62b73f39241..51411ce04aac 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -4,14 +4,19 @@ * See COPYING.txt for license details. */ -/** - * Test class for \Magento\Backend\Block\Widget\Grid\Massaction - */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; use Magento\Framework\Authorization; +use Magento\Framework\Data\Collection\AbstractDb as Collection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Select; +/** + * Test class for \Magento\Backend\Block\Widget\Grid\Massaction + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MassactionTest extends \PHPUnit\Framework\TestCase { /** @@ -54,6 +59,21 @@ class MassactionTest extends \PHPUnit\Framework\TestCase */ private $visibilityCheckerMock; + /** + * @var Collection|\PHPUnit\Framework\MockObject\MockObject + */ + private $gridCollectionMock; + + /** + * @var Select|\PHPUnit\Framework\MockObject\MockObject + */ + private $gridCollectionSelectMock; + + /** + * @var AdapterInterface|\PHPUnit\Framework\MockObject\MockObject + */ + private $connectionMock; + protected function setUp() { $this->_gridMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid::class) @@ -97,6 +117,18 @@ protected function setUp() ->setMethods(['isAllowed']) ->getMock(); + $this->gridCollectionMock = $this->createMock(Collection::class); + $this->gridCollectionSelectMock = $this->createMock(Select::class); + $this->connectionMock = $this->createMock(AdapterInterface::class); + + $this->gridCollectionMock->expects($this->any()) + ->method('getSelect') + ->willReturn($this->gridCollectionSelectMock); + + $this->gridCollectionMock->expects($this->any()) + ->method('getConnection') + ->willReturn($this->connectionMock); + $arguments = [ 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, @@ -269,6 +301,41 @@ public function testGetGridIdsJsonWithoutUseSelectAll() $this->assertEmpty($this->_block->getGridIdsJson()); } + /** + * Test for getGridIdsJson when select all functionality flag set to true. + */ + public function testGetGridIdsJsonWithUseSelectAll() + { + $this->_block->setUseSelectAll(true); + + $this->_gridMock->expects($this->once()) + ->method('getCollection') + ->willReturn($this->gridCollectionMock); + + $this->gridCollectionSelectMock->expects($this->exactly(4)) + ->method('reset') + ->withConsecutive( + [Select::ORDER], + [Select::LIMIT_COUNT], + [Select::LIMIT_OFFSET], + [Select::COLUMNS] + ); + + $this->gridCollectionSelectMock->expects($this->once()) + ->method('columns') + ->with('test_id'); + + $this->connectionMock->expects($this->once()) + ->method('fetchCol') + ->with($this->gridCollectionSelectMock) + ->willReturn([1, 2, 3]); + + $this->assertEquals( + '1,2,3', + $this->_block->getGridIdsJson() + ); + } + /** * @param string $itemId * @param array|\Magento\Framework\DataObject $item From fc5ff1266c548e09af2e6fc3db4d2c469aecf55c Mon Sep 17 00:00:00 2001 From: Ivan Koliadynskyy Date: Wed, 2 Oct 2019 10:26:43 +0300 Subject: [PATCH 11/43] Reverted change for time compression to use \Magento\Framework\Stdlib\DateTime::strToTime instead of php strtotime. Updated helpers to get token expire time to check if value is positive before response. --- app/code/Magento/Integration/Helper/Oauth/Data.php | 4 ++-- .../Magento/Webapi/Model/Authorization/TokenUserContext.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Integration/Helper/Oauth/Data.php b/app/code/Magento/Integration/Helper/Oauth/Data.php index d14bc0f9355a..93fab35c1f40 100644 --- a/app/code/Magento/Integration/Helper/Oauth/Data.php +++ b/app/code/Magento/Integration/Helper/Oauth/Data.php @@ -121,7 +121,7 @@ public function getConsumerPostTimeout() public function getCustomerTokenLifetime() { $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); - return is_numeric($hours) ? $hours : 0; + return is_numeric($hours) && $hours > 0 ? $hours : 0; } /** @@ -132,6 +132,6 @@ public function getCustomerTokenLifetime() public function getAdminTokenLifetime() { $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/admin'); - return is_numeric($hours) ? $hours : 0; + return is_numeric($hours) && $hours > 0 ? $hours : 0; } } diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php index 5c54c8b8660d..8dcaabda93aa 100644 --- a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php +++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php @@ -137,7 +137,7 @@ private function isTokenExpired(Token $token): bool return false; } - if (strtotime($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { + if ($this->dateTime->strToTime($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) { return true; } From 9598e577c0f5091390fd72e14dccdc3bada0792d Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Wed, 2 Oct 2019 14:19:39 +0300 Subject: [PATCH 12/43] Static test fix. --- .../TestFramework/TestCase/WebapiAbstract.php | 47 ++++++++++++++++--- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php index eecca0a396a0..6400a61b3ef3 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php @@ -103,9 +103,11 @@ abstract class WebapiAbstract extends \PHPUnit\Framework\TestCase /** * Initialize fixture namespaces. + * //phpcs:disable */ public static function setUpBeforeClass() { + //phpcs:enable parent::setUpBeforeClass(); self::_setFixtureNamespace(); } @@ -114,9 +116,11 @@ public static function setUpBeforeClass() * Run garbage collector for cleaning memory * * @return void + * //phpcs:disable */ public static function tearDownAfterClass() { + //phpcs:enable //clear garbage in memory gc_collect_cycles(); @@ -134,8 +138,7 @@ public static function tearDownAfterClass() } /** - * Call safe delete for models which added to delete list - * Restore config values changed during the test + * Call safe delete for models which added to delete list, Restore config values changed during the test * * @return void */ @@ -179,6 +182,8 @@ protected function _webApiCall( /** * Mark test to be executed for SOAP adapter only. + * + * @param ?string $message */ protected function _markTestAsSoapOnly($message = null) { @@ -189,6 +194,8 @@ protected function _markTestAsSoapOnly($message = null) /** * Mark test to be executed for REST adapter only. + * + * @param ?string $message */ protected function _markTestAsRestOnly($message = null) { @@ -204,9 +211,11 @@ protected function _markTestAsRestOnly($message = null) * @param mixed $fixture * @param int $tearDown * @return void + * //phpcs:disable */ public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DOWN_AFTER_METHOD) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (!isset(self::$_fixtures[$fixturesNamespace])) { self::$_fixtures[$fixturesNamespace] = []; @@ -232,9 +241,11 @@ public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DO * * @param string $key * @return mixed + * //phpcs:disable */ public static function getFixture($key) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) { return self::$_fixtures[$fixturesNamespace][$key]; @@ -248,9 +259,11 @@ public static function getFixture($key) * @param \Magento\Framework\Model\AbstractModel $model * @param bool $secure * @return \Magento\TestFramework\TestCase\WebapiAbstract + * //phpcs:disable */ public static function callModelDelete($model, $secure = false) { + //phpcs:enable if ($model instanceof \Magento\Framework\Model\AbstractModel && $model->getId()) { if ($secure) { self::_enableSecureArea(); @@ -301,9 +314,11 @@ protected function _getWebApiAdapter($webApiAdapterCode) * Set fixtures namespace * * @throws \RuntimeException + * //phpcs:disable */ protected static function _setFixtureNamespace() { + //phpcs:enable if (self::$_fixturesNamespace !== null) { throw new \RuntimeException('Fixture namespace is already set.'); } @@ -312,9 +327,11 @@ protected static function _setFixtureNamespace() /** * Unset fixtures namespace + * //phpcs:disable */ protected static function _unsetFixtureNamespace() { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); unset(self::$_fixtures[$fixturesNamespace]); self::$_fixturesNamespace = null; @@ -325,9 +342,12 @@ protected static function _unsetFixtureNamespace() * * @throws \RuntimeException * @return string + * //phpcs:disable */ protected static function _getFixtureNamespace() { + //phpcs:enable + $fixtureNamespace = self::$_fixturesNamespace; if ($fixtureNamespace === null) { throw new \RuntimeException('Fixture namespace must be set.'); @@ -340,9 +360,12 @@ protected static function _getFixtureNamespace() * * @param bool $flag * @return void + * //phpcs:disable */ protected static function _enableSecureArea($flag = true) { + //phpcs:enable + /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -389,9 +412,11 @@ protected function _assertMessagesEqual($expectedMessages, $receivedMessages) * Delete array of fixtures * * @param array $fixtures + * //phpcs:disable */ protected static function _deleteFixtures($fixtures) { + //phpcs:enable foreach ($fixtures as $fixture) { self::deleteFixture($fixture, true); } @@ -403,9 +428,11 @@ protected static function _deleteFixtures($fixtures) * @param string $key * @param bool $secure * @return void + * //phpcs:disable */ public static function deleteFixture($key, $secure = false) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) { self::callModelDelete(self::$_fixtures[$fixturesNamespace][$key], $secure); @@ -457,11 +484,11 @@ protected function _cleanAppConfigCache() /** * Update application config data * - * @param string $path Config path with the form "section/group/node" - * @param string|int|null $value Value of config item - * @param bool $cleanAppCache If TRUE application cache will be refreshed - * @param bool $updateLocalConfig If TRUE local config object will be updated too - * @param bool $restore If TRUE config value will be restored after test run + * @param string $path Config path with the form "section/group/node" + * @param string|int|null $value Value of config item + * @param bool $cleanAppCache If TRUE application cache will be refreshed + * @param bool $updateLocalConfig If TRUE local config object will be updated too + * @param bool $restore If TRUE config value will be restored after test run * @return \Magento\TestFramework\TestCase\WebapiAbstract * @throws \RuntimeException */ @@ -521,6 +548,8 @@ protected function _restoreAppConfig() } /** + * Process rest exception result. + * * @param \Exception $e * @return array *
 ex.
@@ -667,6 +696,8 @@ protected function _checkWrappedErrors($expectedWrappedErrors, $errorDetails)
     }
 
     /**
+     * Get actual wrapped errors.
+     *
      * @param \stdClass $errorNode
      * @return array
      */
@@ -695,6 +726,8 @@ private function getActualWrappedErrors(\stdClass $errorNode)
     }
 
     /**
+     * Assert webapi errors.
+     *
      * @param array $serviceInfo
      * @param array $data
      * @param array $expectedErrorData

From 7c5e7178abdb799062b67230589e4b7c70f8213c Mon Sep 17 00:00:00 2001
From: Max Souza 
Date: Wed, 2 Oct 2019 10:49:48 -0300
Subject: [PATCH 13/43] Fix url for back button on multishipping new shipping
 address

---
 .../Multishipping/Controller/Checkout/Address/NewShipping.php   | 2 +-
 .../Test/Unit/Controller/Checkout/Address/NewShippingTest.php   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
index c86caec733a1..c656b3af1447 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
@@ -35,7 +35,7 @@ public function execute()
             if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) {
                 $addressForm->setBackUrl($this->_url->getUrl('*/checkout/addresses'));
             } else {
-                $addressForm->setBackUrl($this->_url->getUrl('*/cart/'));
+                $addressForm->setBackUrl($this->_url->getUrl('checkout/cart/'));
             }
         }
         $this->_view->renderLayout();
diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php
index 9ffef2832a6b..42715d026e9e 100644
--- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php
+++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php
@@ -170,7 +170,7 @@ public function executeDataProvider()
     {
         return [
             'shipping_address_exists' => ['*/checkout/addresses', 'shipping_address', 'back/address'],
-            'shipping_address_not_exist' => ['*/cart/', null, 'back/cart']
+            'shipping_address_not_exist' => ['checkout/cart/', null, 'back/cart']
         ];
     }
 

From d0687d1d68dee57f217495be062e8603b7ed0a59 Mon Sep 17 00:00:00 2001
From: Andrey Legayev 
Date: Wed, 2 Oct 2019 17:10:51 +0300
Subject: [PATCH 14/43] Static Content Deploy - Sort JS Translations to have
 them in the same order on every build

We've faced an issue on BitBucket Pipelines: every build had own unique order of JS translations.
We couldn't see the real diff between builds because of it.
Simple alphabetical sorting of translations resolves this issue.
---
 app/code/Magento/Translation/Model/Js/DataProvider.php   | 2 ++
 .../Translation/Test/Unit/Model/Js/DataProviderTest.php  | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/app/code/Magento/Translation/Model/Js/DataProvider.php b/app/code/Magento/Translation/Model/Js/DataProvider.php
index 7aad7c765bcd..ae388239bc53 100644
--- a/app/code/Magento/Translation/Model/Js/DataProvider.php
+++ b/app/code/Magento/Translation/Model/Js/DataProvider.php
@@ -120,6 +120,8 @@ public function getData($themePath)
             }
         }
 
+        ksort($dictionary);
+
         return $dictionary;
     }
 
diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
index 021709bdda1f..3ebbaf3f6721 100644
--- a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
+++ b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
@@ -90,7 +90,7 @@ public function testGetData()
         $themePath = 'blank';
         $areaCode = 'adminhtml';
 
-        $filePaths = [['path1'], ['path2'], ['path3'], ['path4']];
+        $filePaths = [['path1'], ['path2'], ['path4'], ['path3']];
 
         $jsFilesMap = [
             ['base', $themePath, '*', '*', [$filePaths[0]]],
@@ -111,8 +111,8 @@ public function testGetData()
         $contentsMap = [
             'content1$.mage.__("hello1")content1',
             'content2$.mage.__("hello2")content2',
+            'content2$.mage.__("hello4")content4', // this value should be last after running data provider
             'content2$.mage.__("hello3")content3',
-            'content2$.mage.__("hello4")content4'
         ];
 
         $translateMap = [
@@ -147,7 +147,10 @@ public function testGetData()
             ->method('render')
             ->willReturnMap($translateMap);
 
-        $this->assertEquals($expectedResult, $this->model->getData($themePath));
+        $actualResult = $this->model->getData($themePath);
+        $this->assertEquals($expectedResult, $actualResult);
+        $this->assertEquals(json_encode($expectedResult), json_encode($actualResult),
+            "Translations should be sorted by key");
     }
 
     /**

From b52dc0cf8ae48ce91fbd6d9da2f9a45aa4c5961a Mon Sep 17 00:00:00 2001
From: Andrey Legayev 
Date: Wed, 2 Oct 2019 17:41:34 +0300
Subject: [PATCH 15/43] Fix code style

---
 .../Translation/Test/Unit/Model/Js/DataProviderTest.php    | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
index 3ebbaf3f6721..b5bfbbc29a60 100644
--- a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
+++ b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php
@@ -149,8 +149,11 @@ public function testGetData()
 
         $actualResult = $this->model->getData($themePath);
         $this->assertEquals($expectedResult, $actualResult);
-        $this->assertEquals(json_encode($expectedResult), json_encode($actualResult),
-            "Translations should be sorted by key");
+        $this->assertEquals(
+            json_encode($expectedResult),
+            json_encode($actualResult),
+            "Translations should be sorted by key"
+        );
     }
 
     /**

From 224fa3d53dfed3d1e0181bd35394e7a6afd4ba16 Mon Sep 17 00:00:00 2001
From: eduard13 
Date: Wed, 2 Oct 2019 17:45:56 +0300
Subject: [PATCH 16/43] Covering the CaptchaValidator by Unit Tests

---
 .../Test/Unit/Model/CaptchaValidatorTest.php  | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php

diff --git a/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php b/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php
new file mode 100644
index 000000000000..22377897e564
--- /dev/null
+++ b/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php
@@ -0,0 +1,161 @@
+captchaHelperMock = $this->createMock(Data::class);
+        $this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class);
+        $this->currentUserMock = $this->getMockBuilder(UserContextInterface::class)
+            ->getMockForAbstractClass();
+        $this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class);
+        $this->captchaMock = $this->createMock(DefaultModel::class);
+        $this->requestMock = $this->getMockBuilder(RequestInterface::class)->getMock();
+
+        $this->model = $objectManager->getObject(
+            CaptchaValidator::class,
+            [
+                'captchaHelper' => $this->captchaHelperMock,
+                'captchaStringResolver' => $this->captchaStringResolverMock,
+                'currentUser' => $this->currentUserMock,
+                'customerRepository' => $this->customerRepositoryMock,
+            ]
+        );
+    }
+
+    /**
+     * Testing the captcha validation before sending the email
+     *
+     * @dataProvider captchaProvider
+     *
+     * @param bool $captchaIsRequired
+     * @param bool $captchaWordIsValid
+     *
+     * @throws LocalizedException
+     * @throws NoSuchEntityException
+     */
+    public function testCaptchaValidationOnSend(bool $captchaIsRequired, bool $captchaWordIsValid)
+    {
+        $word = 'test-word';
+        $this->captchaHelperMock->expects($this->once())->method('getCaptcha')->with(static::FORM_ID)
+            ->will($this->returnValue($this->captchaMock));
+        $this->captchaMock->expects($this->once())->method('isRequired')
+            ->will($this->returnValue($captchaIsRequired));
+
+        if ($captchaIsRequired) {
+            $this->captchaStringResolverMock->expects($this->once())->method('resolve')
+                ->with($this->requestMock, static::FORM_ID)->will($this->returnValue($word));
+            $this->captchaMock->expects($this->once())->method('isCorrect')->with($word)
+                ->will($this->returnValue($captchaWordIsValid));
+        }
+
+        $this->model->validateSending($this->requestMock);
+    }
+
+    /**
+     * Testing the wrong used word for captcha
+     *
+     * @expectedException \Magento\Framework\Exception\LocalizedException
+     * @expectedExceptionMessage  Incorrect CAPTCHA
+     */
+    public function testWrongCaptcha()
+    {
+        $word = 'test-word';
+        $captchaIsRequired = true;
+        $captchaWordIsCorrect = false;
+        $this->captchaHelperMock->expects($this->once())->method('getCaptcha')->with(static::FORM_ID)
+            ->will($this->returnValue($this->captchaMock));
+        $this->captchaMock->expects($this->once())->method('isRequired')
+            ->will($this->returnValue($captchaIsRequired));
+        $this->captchaStringResolverMock->expects($this->any())->method('resolve')
+            ->with($this->requestMock, static::FORM_ID)->will($this->returnValue($word));
+        $this->captchaMock->expects($this->any())->method('isCorrect')->with($word)
+            ->will($this->returnValue($captchaWordIsCorrect));
+
+        $this->model->validateSending($this->requestMock);
+    }
+
+    /**
+     * Providing captcha settings
+     *
+     * @return array
+     */
+    public function captchaProvider(): array
+    {
+        return [
+            [
+                true,
+                true
+            ], [
+                false,
+                false
+            ]
+        ];
+    }
+}

From a528841c676f188824ca30479ca3e1d801b729c4 Mon Sep 17 00:00:00 2001
From: Max Souza 
Date: Wed, 2 Oct 2019 11:53:34 -0300
Subject: [PATCH 17/43] Fix annotations

---
 .../Controller/Checkout/Address/NewShipping.php              | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
index c656b3af1447..1f14b52da42c 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
@@ -1,11 +1,14 @@
 
Date: Wed, 2 Oct 2019 12:49:36 -0300
Subject: [PATCH 18/43] Fix line blank

---
 .../Multishipping/Controller/Checkout/Address/NewShipping.php   | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
index 1f14b52da42c..3e2b5eec52fc 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
@@ -6,6 +6,8 @@
 namespace Magento\Multishipping\Controller\Checkout\Address;
 
 /**
+ * New Shipping
+ * 
  * Class NewShipping
  * @package Magento\Multishipping\Controller\Checkout\Address
  */

From 867925dc92a51fc711275a51bc77b794fe190e0f Mon Sep 17 00:00:00 2001
From: Stanislav Idolov 
Date: Wed, 2 Oct 2019 11:23:30 -0500
Subject: [PATCH 19/43] Fixed docblock type hint

---
 app/code/Magento/Integration/Helper/Oauth/Data.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Integration/Helper/Oauth/Data.php b/app/code/Magento/Integration/Helper/Oauth/Data.php
index 93fab35c1f40..107583a9e70a 100644
--- a/app/code/Magento/Integration/Helper/Oauth/Data.php
+++ b/app/code/Magento/Integration/Helper/Oauth/Data.php
@@ -116,7 +116,7 @@ public function getConsumerPostTimeout()
     /**
      * Get customer token lifetime from config.
      *
-     * @return numeric hours
+     * @return float hours
      */
     public function getCustomerTokenLifetime()
     {
@@ -127,7 +127,7 @@ public function getCustomerTokenLifetime()
     /**
      * Get customer token lifetime from config.
      *
-     * @return numeric hours
+     * @return float hours
      */
     public function getAdminTokenLifetime()
     {

From ecb2249fd67ce4d489e81c131349191c7256268b Mon Sep 17 00:00:00 2001
From: Max Souza 
Date: Wed, 2 Oct 2019 13:28:32 -0300
Subject: [PATCH 20/43] Fix annotations

---
 .../Multishipping/Controller/Checkout/Address/NewShipping.php  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
index 3e2b5eec52fc..a484dfbf1797 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
@@ -6,9 +6,8 @@
 namespace Magento\Multishipping\Controller\Checkout\Address;
 
 /**
- * New Shipping
- * 
  * Class NewShipping
+ *
  * @package Magento\Multishipping\Controller\Checkout\Address
  */
 class NewShipping extends \Magento\Multishipping\Controller\Checkout\Address

From 0c102bb6ed2f5511e364d9bcd38b243343c17a2b Mon Sep 17 00:00:00 2001
From: Mahesh Singh 
Date: Wed, 2 Oct 2019 22:35:11 +0530
Subject: [PATCH 21/43] Fixed #24722 with suggestion

---
 .../AdvancedPricingImportExport/Model/Export/AdvancedPricing.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
index 31b99bf71d11..39009e5c7b4e 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php
@@ -216,6 +216,7 @@ public function export()
             if ($entityCollection->count() == 0) {
                 break;
             }
+            $entityCollection->clear();
             $exportData = $this->getExportData();
             foreach ($exportData as $dataRow) {
                 $writer->writeRow($dataRow);

From fded460ee1bc92156ff479e29115fe06fbbaffaa Mon Sep 17 00:00:00 2001
From: Max Souza 
Date: Wed, 2 Oct 2019 15:18:05 -0300
Subject: [PATCH 22/43] Implements HttpGetActionInterface

---
 .../Controller/Checkout/Address/NewShipping.php            | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
index a484dfbf1797..38a30c1ee49e 100644
--- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
+++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php
@@ -5,12 +5,15 @@
  */
 namespace Magento\Multishipping\Controller\Checkout\Address;
 
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Multishipping\Controller\Checkout\Address;
+
 /**
  * Class NewShipping
  *
- * @package Magento\Multishipping\Controller\Checkout\Address
+ * @package Address
  */
-class NewShipping extends \Magento\Multishipping\Controller\Checkout\Address
+class NewShipping extends Address implements HttpGetActionInterface
 {
     /**
      * Create New Shipping address Form

From 39111d677bc98c52c8c0362c79ac1145f1bf738b Mon Sep 17 00:00:00 2001
From: Adarsh Manickam 
Date: Thu, 3 Oct 2019 10:03:37 +0530
Subject: [PATCH 23/43] Fixed inconsistent grammar

---
 app/code/Magento/Newsletter/etc/adminhtml/menu.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/code/Magento/Newsletter/etc/adminhtml/menu.xml b/app/code/Magento/Newsletter/etc/adminhtml/menu.xml
index a9cedf1c7a1e..8fc21494b5de 100644
--- a/app/code/Magento/Newsletter/etc/adminhtml/menu.xml
+++ b/app/code/Magento/Newsletter/etc/adminhtml/menu.xml
@@ -7,7 +7,7 @@
 -->
 
     
-        
+        
         
         
         

From 42e4103ce6765a16f30980dcc19d48b3fbdcc433 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky 
Date: Thu, 3 Oct 2019 12:33:30 +0300
Subject: [PATCH 24/43] magento/magento2#24835: MFTF tests update.

---
 app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml b/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml
index 1df1cd5f8dae..02657340bf34 100644
--- a/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml
+++ b/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml
@@ -19,8 +19,8 @@
         magento-newsletter-newsletter-subscriber
     
     
-        Newsletter Template
-        Newsletter Template
+        Newsletter Templates
+        Newsletter Templates
         magento-newsletter-newsletter-template
     
     

From e5a2b2620786bf58e4fe9c4c2df888f8be0dc64e Mon Sep 17 00:00:00 2001
From: Daniel Ruf 
Date: Fri, 4 Oct 2019 10:16:56 +0200
Subject: [PATCH 25/43] Change array to object

---
 .../view/frontend/web/js/model/cart/estimate-service.js       | 4 ++--
 .../view/frontend/web/js/model/shipping-rate-service.js       | 2 +-
 .../view/frontend/web/js/model/shipping-save-processor.js     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
index 54e496131972..fd12eed76ed5 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
@@ -13,8 +13,8 @@ define([
 ], function (quote, defaultProcessor, totalsDefaultProvider, shippingService, cartCache, customerData) {
     'use strict';
 
-    var rateProcessors = [],
-        totalsProcessors = [],
+    var rateProcessors = {},
+        totalsProcessors = {},
 
         /**
          * Estimate totals for shipping address and update shipping rates.
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js
index 7eddc0d1a58d..be2199961e07 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js
@@ -10,7 +10,7 @@ define([
 ], function (quote, defaultProcessor, customerAddressProcessor) {
     'use strict';
 
-    var processors = [];
+    var processors = {};
 
     processors.default =  defaultProcessor;
     processors['customer-address'] = customerAddressProcessor;
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js
index d506f0a4359c..cf26f682ad3a 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js
@@ -11,7 +11,7 @@ define([
 ], function (defaultProcessor) {
     'use strict';
 
-    var processors = [];
+    var processors = {};
 
     processors['default'] =  defaultProcessor;
 

From 1ea74daaea02b4b2406406aca18c8511a5b37bea Mon Sep 17 00:00:00 2001
From: Daniel Ruf 
Date: Fri, 4 Oct 2019 10:20:58 +0200
Subject: [PATCH 26/43] Remove unnecessary parentheses

---
 lib/web/mage/popup-window.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/web/mage/popup-window.js b/lib/web/mage/popup-window.js
index 37c3b27a4510..194a18ce150b 100644
--- a/lib/web/mage/popup-window.js
+++ b/lib/web/mage/popup-window.js
@@ -57,8 +57,8 @@ define([
             settings.windowURL = settings.windowURL || element.attr('href');
 
             if (settings.centerBrowser) {
-                centeredY = window.screenY + ((window.outerHeight / 2 - settings.height / 2));
-                centeredX = window.screenX + ((window.outerWidth / 2 - settings.width / 2));
+                centeredY = window.screenY + (window.outerHeight / 2 - settings.height / 2);
+                centeredX = window.screenX + (window.outerWidth / 2 - settings.width / 2);
                 windowFeatures += ',left=' + centeredX + ',top=' + centeredY;
             } else if (settings.centerScreen) {
                 centeredY = (screen.height - settings.height) / 2;

From 33b6015edfe77e72102dd266e03a10de863cb561 Mon Sep 17 00:00:00 2001
From: Alex 
Date: Fri, 4 Oct 2019 12:02:39 +0300
Subject: [PATCH 27/43] Update AbstractForm.php

---
 lib/internal/Magento/Framework/Data/Form/AbstractForm.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
index f3b26dc7a9bf..c7ac994501ca 100644
--- a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
+++ b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php
@@ -138,7 +138,7 @@ public function addElement(AbstractElement $element, $after = null)
      * Add child element
      *
      * if $after parameter is false - then element adds to end of collection
-     * if $after parameter is null - then element adds to befin of collection
+     * if $after parameter is null - then element adds to begin of collection
      * if $after parameter is string - then element adds after of the element with some id
      *
      * @param   string $elementId

From 8baeec344c5063d65eff5a79a0ddf7125ecc6951 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam 
Date: Thu, 3 Oct 2019 22:37:40 +0530
Subject: [PATCH 28/43] Fixed issue #24779

---
 .../Checkout/view/frontend/templates/button.phtml      |  5 ++++-
 .../frontend/templates/order/creditmemo/items.phtml    | 10 ++++++----
 .../view/frontend/templates/order/info/buttons.phtml   |  7 ++++---
 .../view/frontend/templates/order/invoice/items.phtml  |  8 +++++---
 .../Shipping/view/frontend/templates/items.phtml       | 10 ++++++----
 5 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/app/code/Magento/Checkout/view/frontend/templates/button.phtml b/app/code/Magento/Checkout/view/frontend/templates/button.phtml
index b0087794ea85..6d1f076e6b26 100644
--- a/app/code/Magento/Checkout/view/frontend/templates/button.phtml
+++ b/app/code/Magento/Checkout/view/frontend/templates/button.phtml
@@ -7,7 +7,10 @@
 
 
 getCanViewOrder() && $block->getCanPrintOrder()) :?>
-    
+    
         escapeHtml(__('Print receipt')) ?>
     
     getChildHtml() ?>
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml
index 019baeea54e2..cb84dcc3fae8 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml
@@ -7,8 +7,9 @@
 getOrder() ?>
 
@@ -16,8 +17,9 @@
     
escapeHtml(__('Refund #')) ?>escapeHtml($_creditmemo->getIncrementId()) ?> + class="action print" + target="_blank" + rel="noopener"> escapeHtml(__('Print Refund')) ?>
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml b/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml index 6b87d3c22331..2872291a0eaa 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml @@ -16,9 +16,10 @@ escapeHtml(__('Reorder')) ?> - + escapeHtml(__('Print Order')) ?> getChildHtml() ?> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml index 419060bfba71..ba3440f03c00 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml @@ -7,8 +7,9 @@ getOrder() ?> @@ -16,8 +17,9 @@
escapeHtml(__('Invoice #')) ?>escapeHtml($_invoice->getIncrementId()) ?> + class="action print" + target="_blank" + rel="noopener"> escapeHtml(__('Print Invoice')) ?>
diff --git a/app/code/Magento/Shipping/view/frontend/templates/items.phtml b/app/code/Magento/Shipping/view/frontend/templates/items.phtml index f0f1423ed47a..177628c6b201 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/items.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/items.phtml @@ -15,8 +15,9 @@ getChildHtml('track-all-link') ?> + class="action print" + target="_blank" + rel="noopener"> escapeHtml(__('Print All Shipments')) ?> @@ -24,8 +25,9 @@
escapeHtml(__('Shipment #')) ?>escapeHtml($_shipment->getIncrementId()) ?> + class="action print" + target="_blank" + rel="noopener"> escapeHtml(__('Print Shipment')) ?> Date: Fri, 4 Oct 2019 13:21:13 +0300 Subject: [PATCH 29/43] Update AbstractForm.php --- .../Magento/Framework/Data/Form/AbstractForm.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php index c7ac994501ca..47ba04bb6898 100644 --- a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php +++ b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php @@ -137,14 +137,14 @@ public function addElement(AbstractElement $element, $after = null) /** * Add child element * - * if $after parameter is false - then element adds to end of collection - * if $after parameter is null - then element adds to begin of collection - * if $after parameter is string - then element adds after of the element with some id + * If $after parameter is false - then element adds to end of collection + * If $after parameter is null - then element adds to befin of collection + * If $after parameter is string - then element adds after of the element with some id * - * @param string $elementId - * @param string $type - * @param array $config - * @param bool|string|null $after + * @param string $elementId + * @param string $type + * @param array $config + * @param bool|string|null $after * @return AbstractElement */ public function addField($elementId, $type, $config, $after = false) From 2b9a7ca6f3e9fee0bd81daddeeb609f40b861df4 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 4 Oct 2019 14:21:01 +0300 Subject: [PATCH 30/43] Update AbstractForm.php --- lib/internal/Magento/Framework/Data/Form/AbstractForm.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php index 47ba04bb6898..4a082d71ddd4 100644 --- a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php +++ b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php @@ -67,9 +67,11 @@ public function __construct(Factory $factoryElement, CollectionFactory $factoryC * Please override this one instead of overriding real __construct constructor * * @return void + * @codingStandardsIgnoreStart */ protected function _construct() { + //@codingStandardsIgnoreEnd } /** From f4bd79ad6b8f7072edd36c2df1451044553b6795 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Fri, 4 Oct 2019 15:30:43 +0300 Subject: [PATCH 31/43] Added integration test for Magento\Sales\Cron\CleanExpiredQuotes class. --- .../Sales/Cron/CleanExpiredQuotesTest.php | 65 +++++++++++++++++++ .../testsuite/Magento/Sales/_files/quotes.php | 35 ++++++++++ .../Magento/Sales/_files/quotes_rollback.php | 36 ++++++++++ 3 files changed, 136 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php new file mode 100644 index 000000000000..1b68bc0520ce --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php @@ -0,0 +1,65 @@ +cleanExpiredQuotes = $objectManager->get(CleanExpiredQuotes::class); + $this->quoteRepository = $objectManager->get(QuoteRepository::class); + $this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); + } + + /** + * Check if outdated quotes are deleted. + * + * @magentoConfigFixture default_store checkout/cart/delete_quote_after -365 + * @magentoDataFixture Magento/Sales/_files/quotes.php + */ + public function testExecute() + { + $this->cleanExpiredQuotes->execute(); + $searchCriteria = $this->searchCriteriaBuilder->create(); + $totalCount = $this->quoteRepository->getList($searchCriteria)->getTotalCount(); + + $this->assertEquals( + 1, + $totalCount + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php new file mode 100644 index 000000000000..b916fc024041 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php @@ -0,0 +1,35 @@ +get(QuoteFactory::class); +/** @var QuoteRepository $quoteRepository */ +$quoteRepository = $objectManager->get(QuoteRepository::class); + +$quotes = [ + 'quote for first store' => [ + 'store' => 1, + ], + 'quote for second store' => [ + 'store' => 2, + ], +]; + +foreach ($quotes as $quoteData) { + $quote = $quoteFactory->create(); + $quote->setStoreId($quoteData['store']); + $quoteRepository->save($quote); +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php new file mode 100644 index 000000000000..7b7fd615e534 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php @@ -0,0 +1,36 @@ +get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var QuoteRepository $quoteRepository */ +$quoteRepository = $objectManager->get(QuoteRepository::class); +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); +$searchCriteria = $searchCriteriaBuilder->create(); +$items = $quoteRepository->getList($searchCriteria) + ->getItems(); +foreach ($items as $item) { + $quoteRepository->delete($item); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +require dirname(dirname(__DIR__)) . '/Store/_files/second_store_rollback.php'; From 506a67390342ba00003492c70ab730e60e495d3f Mon Sep 17 00:00:00 2001 From: Archit <42545374+gargarchit@users.noreply.github.com> Date: Fri, 4 Oct 2019 22:08:19 +0530 Subject: [PATCH 32/43] Update ReadMe --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7662290cc09c..abe9b14ec7ac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a ## Install Magento -* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). +* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). ## Learn More About GraphQL in Magento 2 @@ -18,7 +18,7 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a

Contributing to the Magento 2 Code Base

Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions. -To learn about how to make a contribution, click [here][1]. +To learn about how to contribute, click [here][1]. To learn about issues, click [here][2]. To open an issue, click [here][3]. @@ -30,14 +30,14 @@ To suggest documentation improvements, click [here][4]. [4]: https://devdocs.magento.com

Community Maintainers

-The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions. +The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks to these Community Maintainers for their valuable contributions.

Top Contributors

-Magento is thankful for any contribution that can improve our code base, documentation or increase test coverage. We always recognize our most active members, as their contributions are the foundation of the Magento Open Source platform. +Magento is thankful for any contribution that can improve our codebase, documentation or increase test coverage. We always recognize our most active members, as their contributions are the foundation of the Magento Open Source platform. @@ -48,7 +48,7 @@ Please review the [Code Contributions guide](https://devdocs.magento.com/guides/ ## Reporting Security Issues -To report security vulnerabilities or learn more about reporting security issues in Magento software or web sites visit the [Magento Bug Bounty Program](https://hackerone.com/magento) on hackerone. Please create a hackerone account [there](https://hackerone.com/magento) to submit and follow-up your issue. +To report security vulnerabilities or learn more about reporting security issues in Magento software or web sites visit the [Magento Bug Bounty Program](https://hackerone.com/magento) on hackerone. Please create a hackerone account [there](https://hackerone.com/magento) to submit and follow-up on your issue. Stay up-to-date on the latest security news and patches for Magento by signing up for [Security Alert Notifications](https://magento.com/security/sign-up). @@ -64,7 +64,7 @@ Please see LICENSE_EE.txt for the full text of the MEE License or visit https:// ## Community Engineering Slack -To connect with Magento and the Community, join us on the [Magento Community Engineering Slack](https://magentocommeng.slack.com). If you are interested in joining Slack, or a specific channel, send us request at [engcom@adobe.com](mailto:engcom@adobe.com) or [self signup](https://tinyurl.com/engcom-slack). +To connect with Magento and the Community, join us on the [Magento Community Engineering Slack](https://magentocommeng.slack.com). If you are interested in joining Slack, or a specific channel, send us a request at [engcom@adobe.com](mailto:engcom@adobe.com) or [self signup](https://tinyurl.com/engcom-slack). We have channels for each project. These channels are recommended for new members: From ac375e1a012faffe79a767c8b92fddb11f5d1186 Mon Sep 17 00:00:00 2001 From: Archit <42545374+gargarchit@users.noreply.github.com> Date: Fri, 4 Oct 2019 22:27:24 +0530 Subject: [PATCH 33/43] Update Readme according to Review --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abe9b14ec7ac..91d0d902cb61 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ To suggest documentation improvements, click [here][4]. [4]: https://devdocs.magento.com

Community Maintainers

-The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks to these Community Maintainers for their valuable contributions. +The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions. From fce0447f8ca43d96f9de08386223c2c1e1ac9728 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Fri, 4 Oct 2019 13:14:58 -0500 Subject: [PATCH 34/43] magento-engcom/magento2ce#3317: Reverted method return type --- .../Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 79597e07be76..284cb01148f6 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -127,7 +127,7 @@ private function isVisible(DataObject $item) * Retrieve massaction item with id $itemId * * @param string $itemId - * @return Item|null + * @return \Magento\Backend\Block\Widget\Grid\Massaction\Item|null */ public function getItem($itemId) { From 1ac83c02293088ad3f5e52b5f0d6062a4e197cc3 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Sat, 5 Oct 2019 17:25:41 +0200 Subject: [PATCH 35/43] Remove useless semicolons These ones were not found via the `no_empty_statement` from `php-cs-fixer`. --- .../_files/product_simple_with_non_latin_url_key.php | 4 ++-- .../Fixtures/quote_with_configurable_product.php | 2 +- lib/internal/Magento/Framework/Lock/Backend/Database.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php index 23fd8d7fe324..928c036e8fb4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php @@ -41,7 +41,7 @@ $productRepository->save($product); } catch (\Exception $e) { // problems during save -}; +} /** @var ProductInterface $product */ $product = $objectManager->create(ProductInterface::class); @@ -60,4 +60,4 @@ $productRepository->save($product); } catch (\Exception $e) { // problems during save -}; +} diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php index 2a472371fd19..023421e4cd2b 100644 --- a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php +++ b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php @@ -118,7 +118,7 @@ $item->setQty(1); $address->setTotalQty(1); $address->addItem($item); - }; + } } $billingAddressData = [ diff --git a/lib/internal/Magento/Framework/Lock/Backend/Database.php b/lib/internal/Magento/Framework/Lock/Backend/Database.php index 096e77a11768..a5a76ba60f4e 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Database.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Database.php @@ -76,7 +76,7 @@ public function lock(string $name, int $timeout = -1): bool { if (!$this->deploymentConfig->isDbAvailable()) { return true; - }; + } $name = $this->addPrefix($name); /** @@ -117,7 +117,7 @@ public function unlock(string $name): bool { if (!$this->deploymentConfig->isDbAvailable()) { return true; - }; + } $name = $this->addPrefix($name); @@ -145,7 +145,7 @@ public function isLocked(string $name): bool { if (!$this->deploymentConfig->isDbAvailable()) { return false; - }; + } $name = $this->addPrefix($name); From 38c9db4c210db436d5e0711b627e48c3e31babe1 Mon Sep 17 00:00:00 2001 From: Gabriel Caruso Date: Sun, 6 Oct 2019 16:52:31 +0200 Subject: [PATCH 36/43] Remove unecessaries ternary conditions --- .../testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php | 2 +- .../testsuite/Magento/GraphQl/Catalog/ProductImageTest.php | 2 +- .../lib/Magento/Mtf/Client/Element/LiselectstoreElement.php | 2 +- .../Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php | 2 +- .../Review/Test/TestCase/MassActionsProductReviewEntityTest.php | 2 +- .../Magento/Framework/Acl/AclResource/Config/Converter/Dom.php | 2 +- lib/internal/Magento/Framework/App/MaintenanceMode.php | 2 +- .../Magento/Framework/Code/Reader/NamespaceResolver.php | 2 +- .../Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php | 2 +- lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php | 2 +- lib/internal/Magento/Framework/Url.php | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php index e805bc940704..b6687b4e171d 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php @@ -198,6 +198,6 @@ private function checkImageExists(string $url): bool curl_exec($connection); $responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE); // phpcs:enable Magento2.Functions.DiscouragedFunction - return $responseStatus === 200 ? true : false; + return $responseStatus === 200; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php index b957292a3ac2..52463485a34f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php @@ -144,6 +144,6 @@ private function checkImageExists(string $url): bool curl_exec($connection); $responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE); - return $responseStatus === 200 ? true : false; + return $responseStatus === 200; } } diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php index 49f2577b2621..703744b17e87 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php @@ -133,7 +133,7 @@ public function getValues() */ protected function isSubstring($haystack, $pattern) { - return preg_match("/$pattern/", $haystack) != 0 ? true : false; + return preg_match("/$pattern/", $haystack) != 0; } /** diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index f1ab25501328..a06ee2332704 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -311,7 +311,7 @@ public function fillBundleOptions($bundleOptions) { foreach ($bundleOptions as $option) { $selector = sprintf($this->bundleOptionBlock, $option['title']); - $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true' ? true : false; + $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true'; if (!$useDefault) { /** @var Option $optionBlock */ $optionBlock = $this->blockFactory->create( diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php index e7dd72d1d426..da5e7101e4b3 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php @@ -102,7 +102,7 @@ public function test($gridActions, $gridStatus) $this->reviewIndex->getReviewGrid()->massaction( [['title' => $this->review->getTitle()]], [$gridActions => $gridStatus], - ($gridActions == 'Delete' ? true : false) + ($gridActions == 'Delete') ); } diff --git a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php index 68762a8a6c04..72e2dbd5bf7b 100644 --- a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php +++ b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php @@ -53,7 +53,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode) $sortOrderNode = $resourceAttributes->getNamedItem('sortOrder'); $resourceData['sortOrder'] = $sortOrderNode !== null ? (int)$sortOrderNode->nodeValue : 0; $disabledNode = $resourceAttributes->getNamedItem('disabled'); - $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true' ? true : false; + $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true'; // convert child resource nodes if needed $resourceData['children'] = []; /** @var $childNode \DOMNode */ diff --git a/lib/internal/Magento/Framework/App/MaintenanceMode.php b/lib/internal/Magento/Framework/App/MaintenanceMode.php index e813522a0151..11347e4220c2 100644 --- a/lib/internal/Magento/Framework/App/MaintenanceMode.php +++ b/lib/internal/Magento/Framework/App/MaintenanceMode.php @@ -110,7 +110,7 @@ public function setAddresses($addresses) throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n"); } $result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses); - return false !== $result ? true : false; + return false !== $result; } /** diff --git a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php index 8c22170a126f..b1126e96bec8 100644 --- a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php +++ b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php @@ -50,7 +50,7 @@ public function resolveNamespace($type, array $availableNamespaces) ) { $name = explode(self::NS_SEPARATOR, $type); $unqualifiedName = $name[0]; - $isQualifiedName = count($name) > 1 ? true : false; + $isQualifiedName = count($name) > 1; if (isset($availableNamespaces[$unqualifiedName])) { $namespace = $availableNamespaces[$unqualifiedName]; if ($isQualifiedName) { diff --git a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php index dfb8b748469b..ebcbbeaa04ca 100644 --- a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php +++ b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php @@ -21,7 +21,7 @@ class ScalarTypes public function isScalarType(string $typeName) : bool { $standardTypes = \GraphQL\Type\Definition\Type::getStandardTypes(); - return isset($standardTypes[$typeName]) ? true : false; + return isset($standardTypes[$typeName]); } /** diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php index 2cc2da62e71c..376dfb5d7258 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php @@ -130,7 +130,7 @@ public function setHttpResponseCode($code) throw new \InvalidArgumentException('Invalid HTTP response code'); } - $this->isRedirect = (300 <= $code && 307 >= $code) ? true : false; + $this->isRedirect = (300 <= $code && 307 >= $code); $this->setStatusCode($code); return $this; diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php index 11aeb1c0c79b..2cd6db17a96e 100644 --- a/lib/internal/Magento/Framework/Url.php +++ b/lib/internal/Magento/Framework/Url.php @@ -1067,7 +1067,7 @@ public function sessionUrlVar($html) */ // @codingStandardsIgnoreEnd function ($match) { - if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { + if ($this->useSessionIdForUrl($match[2] == 'S')) { return $match[1] . $this->_sidResolver->getSessionIdQueryParam($this->_session) . '=' . $this->_session->getSessionId() . (isset($match[3]) ? $match[3] : ''); } else { From 5db0a0d6795cd3ba8555bf0576341beee812befc Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Sun, 6 Oct 2019 18:02:35 +0200 Subject: [PATCH 37/43] Fix small typo --- .../Braintree/Controller/Adminhtml/Invoice/CreateTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php index d6ea08a2f7ca..aa5ada3f6586 100644 --- a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php @@ -62,7 +62,7 @@ protected function tearDown() * during creation second partial invoice. * * @return void - * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magneto + * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magento * @magentoConfigFixture current_store payment/braintree/merchant_account_id USA_Merchant * @magentoDataFixture Magento/Braintree/Fixtures/partial_invoice.php */ From 0ec5c7927ca829ba0db86738313452affa169041 Mon Sep 17 00:00:00 2001 From: YevheniiKR <56229166+YevheniiKR@users.noreply.github.com> Date: Sun, 6 Oct 2019 20:54:07 +0300 Subject: [PATCH 38/43] Update bug_report.md Updated sample Magento version from 2.2.5 to 2.3.2 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 33a6ef02ace1..54479c5d99c3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,7 +11,7 @@ Fields marked with (*) are required. Please don't remove the template. ### Preconditions (*) 1. 2. From 44377673d3c7591fd2461bf421d91f9a3a66ae49 Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Mon, 7 Oct 2019 10:28:56 +0300 Subject: [PATCH 39/43] Static test fix, unit test coverage --- .../Model/Product/Type/VariationMatrix.php | 9 +- .../Product/Type/VariationMatrixTest.php | 143 +++++++++++++----- 2 files changed, 113 insertions(+), 39 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index e7da5ccd6cdf..f837444aa45c 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -3,9 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\ConfigurableProduct\Model\Product\Type; /** + * Variation matrix. + * * @api * @since 100.0.2 */ @@ -40,9 +43,9 @@ public function getVariations($usedProductAttributes) for ($attributeIndex = $attributesCount; $attributeIndex--;) { $currentAttribute = $variationalAttributes[$attributeIndex]; $currentVariationValue = $currentVariation[$attributeIndex]; - if(!empty($currentAttribute['id'])) { - $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; - } + if (!empty($currentAttribute['id'])) { + $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; + } } $variations[] = $filledVariation; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php index 41995be41813..29bca356c118 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php @@ -25,46 +25,117 @@ protected function setUp() ); } - public function testGetVariations() + /** + * Variations matrix test. + * + * @param array $expectedResult + * @dataProvider variationProvider + */ + public function testGetVariations($expectedResult) { - $result = [ - [ - 130 => [ - 'value' => '3', - 'label' => 'red', - 'price' => ['value_index' => '3', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',], - ], - ], - [ - 130 => [ - 'value' => '4', - 'label' => 'blue', - 'price' => ['value_index' => '4', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',], - ], - ], - ]; - $input = [ - 130 => [ - 'values' => [ - [ - 'value_index' => '3', - 'pricing_value' => '', - 'is_percent' => '0', - 'include' => '1' - ], - [ - 'value_index' => '4', - 'pricing_value' => '', - 'is_percent' => '0', - 'include' => '1' + $this->assertEquals($expectedResult['result'], $this->model->getVariations($expectedResult['input'])); + } + + /** + * Test data provider. + */ + public function variationProvider() + { + return [ + [ + 'with_attribute_id' => [ + 'result' => [ + [ + 130 => [ + 'value' => '3', + 'label' => 'red', + 'price' => [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], + [ + 130 => [ + 'value' => '4', + 'label' => 'blue', + 'price' => [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], ], + 'input' => [ + 130 => [ + 'values' => [ + [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + 'attribute_id' => '130', + 'options' => [ + [ + 'value' => '3', + 'label' => 'red' + ], + ['value' => '4', + 'label' => 'blue' + ] + ], + ], + ] ], - 'attribute_id' => '130', - 'options' => [['value' => '3', 'label' => 'red',], ['value' => '4', 'label' => 'blue',],], - ], + 'without_attribute_id' => [ + 'result' => [ + [ + 130 => [ + 'value' => '4', + 'label' => 'blue', + 'price' => [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], + ], + 'input' => [ + 130 => [ + 'values' => [ + [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ] + ], + 'attribute_id' => '', + 'options' => [ + [ + 'value' => '3', + 'label' => 'red' + ] + ], + ], + ] + ] + ] ]; - - $this->assertEquals($result, $this->model->getVariations($input)); } } From 279b61b2bfab9b989616f78c2b7d3c69c6b613db Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Mon, 7 Oct 2019 10:57:03 +0300 Subject: [PATCH 40/43] Static test fix --- .../Controller/Adminhtml/Invoice/CreateTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php index aa5ada3f6586..55d8c6a6a217 100644 --- a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php @@ -71,11 +71,14 @@ public function testCreatePartialInvoiceWithNonDefaultMerchantAccount(): void $order = $this->getOrder('100000002'); $this->adapter->method('sale') - ->with(self::callback(function ($request) { - self::assertEquals('USA_Merchant', $request['merchantAccountId']); - return true; - })) - ->willReturn($this->getTransactionStub()); + ->with( + self::callback( + function ($request) { + self::assertEquals('USA_Merchant', $request['merchantAccountId']); + return true; + } + ) + )->willReturn($this->getTransactionStub()); $uri = 'backend/sales/order_invoice/save/order_id/' . $order->getEntityId(); $this->prepareRequest($uri); From 7da6807a1cefa7f688357bf6865f06bd50649a05 Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Mon, 7 Oct 2019 11:58:25 +0300 Subject: [PATCH 41/43] Static test fix --- .../Client/Element/LiselectstoreElement.php | 4 +-- .../Acl/AclResource/Config/Converter/Dom.php | 6 +++- .../Code/Reader/NamespaceResolver.php | 24 +++++++++------ .../HTTP/PhpEnvironment/Response.php | 30 +++++++++++-------- lib/internal/Magento/Framework/Url.php | 3 +- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php index 703744b17e87..bc3ae83643d3 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php @@ -9,7 +9,6 @@ use Magento\Mtf\Client\Locator; /** - * Class LiselectstoreElement * Typified element class for lists selectors */ class LiselectstoreElement extends SimpleElement @@ -76,6 +75,7 @@ public function setValue($value) $option = $this->context->find($optionSelector, Locator::SELECTOR_XPATH); if (!$option->isVisible()) { + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); } $option->click(); @@ -157,8 +157,8 @@ protected function findNearestElement($criteria, $key, array $elements) /** * Get selected store value * - * @throws \Exception * @return string + * @throws \Exception */ public function getValue() { diff --git a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php index 72e2dbd5bf7b..7f7a4761b17a 100644 --- a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php +++ b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php @@ -5,10 +5,13 @@ */ namespace Magento\Framework\Acl\AclResource\Config\Converter; +/** + * @inheritDoc + */ class Dom implements \Magento\Framework\Config\ConverterInterface { /** - * {@inheritdoc} + * @inheritdoc * * @param \DOMDocument $source * @return array @@ -39,6 +42,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode) $resourceAttributes = $resourceNode->attributes; $idNode = $resourceAttributes->getNamedItem('id'); if ($idNode === null) { + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception('Attribute "id" is required for ACL resource.'); } $resourceData['id'] = $idNode->nodeValue; diff --git a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php index b1126e96bec8..4ee80b015549 100644 --- a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php +++ b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php @@ -101,16 +101,22 @@ public function getImportedNamespaces(array $fileContent) $imports[$importsCount][] = $item; } foreach ($imports as $import) { - $import = array_filter($import, function ($token) { - $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS]; - if (isset($token[0]) && in_array($token[0], $whitelist)) { - return true; + $import = array_filter( + $import, + function ($token) { + $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS]; + if (isset($token[0]) && in_array($token[0], $whitelist)) { + return true; + } + return false; } - return false; - }); - $import = array_map(function ($element) { - return $element[1]; - }, $import); + ); + $import = array_map( + function ($element) { + return $element[1]; + }, + import + ); $import = array_values($import); if ($import[0] === self::NS_SEPARATOR) { array_shift($import); diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php index 376dfb5d7258..05358da531d4 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php @@ -1,22 +1,24 @@ Date: Mon, 7 Oct 2019 12:07:30 +0300 Subject: [PATCH 42/43] Static test fix --- .../Magento/Framework/Code/Reader/NamespaceResolver.php | 2 +- lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php | 1 + lib/internal/Magento/Framework/Url.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php index 4ee80b015549..f0ff31964512 100644 --- a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php +++ b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php @@ -115,7 +115,7 @@ function ($token) { function ($element) { return $element[1]; }, - import + $import ); $import = array_values($import); if ($import[0] === self::NS_SEPARATOR) { diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php index 05358da531d4..17d748260762 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php @@ -175,6 +175,7 @@ public function isRedirect() * @inheritDoc * * @return string[] + * @SuppressWarnings(PHPMD.SerializationAware) */ public function __sleep() { diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php index 4d627ea0bd0c..c67a20f0a157 100644 --- a/lib/internal/Magento/Framework/Url.php +++ b/lib/internal/Magento/Framework/Url.php @@ -62,6 +62,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class Url extends \Magento\Framework\DataObject implements \Magento\Framework\UrlInterface { From 5fc4b458e9ef0becfed3abb857cb81c860433b71 Mon Sep 17 00:00:00 2001 From: Nazarn96 Date: Mon, 7 Oct 2019 14:50:29 +0300 Subject: [PATCH 43/43] Cover changes with functional tests. --- ...fStorefrontIsOpenedViaCustomerViewTest.xml | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml new file mode 100644 index 000000000000..d2d3343a3b8d --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml @@ -0,0 +1,75 @@ + + + + + + + + + + <description value="Admin panel is not frozen if Storefront is opened via Customer View"/> + <severity value="MAJOR"/> + <testCaseId value="https://github.com/magento/magento2/pull/24845"/> + <group value="customer"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="simpleCustomer"/> + <createData entity="SimpleSubCategory" stepKey="createSimpleCategory"/> + <createData entity="SimpleProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createSimpleCategory"/> + </createData> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + </before> + <after> + <deleteData createDataKey="createSimpleCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderPage"> + <argument name="customer" value="$simpleCustomer$"/> + </actionGroup> + <actionGroup ref="addSimpleProductToOrder" stepKey="addSecondProduct"> + <argument name="product" value="$createSimpleProduct$"/> + </actionGroup> + <actionGroup ref="fillOrderCustomerInformation" stepKey="fillCustomerInfo"> + <argument name="customer" value="$simpleCustomer$"/> + <argument name="address" value="US_Address_TX"/> + </actionGroup> + <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRate"/> + <actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/> + <grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/> + + <actionGroup ref="StartCreateInvoiceFromOrderPage" stepKey="startCreateInvoice"/> + <actionGroup ref="SubmitInvoice" stepKey="submitInvoice"/> + <actionGroup ref="goToShipmentIntoOrder" stepKey="goToShipment"/> + <actionGroup ref="submitShipmentIntoOrder" stepKey="submitShipment"/> + + <!--Create Credit Memo--> + <actionGroup ref="StartToCreateCreditMemoActionGroup" stepKey="startToCreateCreditMemo"> + <argument name="orderId" value="{$getOrderId}"/> + </actionGroup> + <actionGroup ref="SubmitCreditMemoActionGroup" stepKey="submitCreditMemo"/> + + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="logInCustomer"> + <argument name="Customer" value="$$simpleCustomer$$"/> + </actionGroup> + <actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToMyOrdersPage"> + <argument name="menu" value="My Orders"/> + </actionGroup> + <click selector="{{StorefrontCustomerOrderSection.viewOrder}}" stepKey="clickViewOrder"/> + <click selector="{{StorefrontCustomerOrderViewSection.printOrderLink}}" stepKey="clickPrintOrderLink"/> + <waitForPageLoad stepKey="waitPageReload"/> + <switchToWindow stepKey="switchToWindow"/> + <switchToPreviousTab stepKey="switchToPreviousTab"/> + + <actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToAddressBook"> + <argument name="menu" value="Address Book"/> + </actionGroup> + <see selector="{{CheckoutOrderSummarySection.shippingAddress}}" userInput="{{US_Address_TX.street[0]}} {{US_Address_TX.city}}, {{US_Address_TX.state}}, {{US_Address_TX.postcode}}" stepKey="checkShippingAddress"/> + </test> +</tests>