From ab1324ecc1d5e2990acfd4f14c7b77765d343a9e Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Fri, 13 Jul 2018 15:12:21 +0300 Subject: [PATCH 01/51] Fix the issue with "Shipping address is not set" exception #16555 --- app/code/Magento/Multishipping/Controller/Checkout.php | 1 + .../Magento/Quote/Model/ShippingMethodManagement.php | 4 +--- .../Test/Unit/Model/ShippingMethodManagementTest.php | 10 ++-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index 1870736a0efd9..161021768ce19 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -84,6 +84,7 @@ protected function _getCheckoutSession() * * @param RequestInterface $request * @return \Magento\Framework\App\ResponseInterface + * @throws \Magento\Framework\Exception\NotFoundException * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index ade2649d0b1b0..ac609e7f435ea 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -171,9 +171,7 @@ public function set($cartId, $carrierCode, $methodCode) * @param string $methodCode The shipping method code. * @return void * @throws InputException The shipping method is not valid for an empty cart. - * @throws CouldNotSaveException The shipping method could not be saved. * @throws NoSuchEntityException CThe Cart includes virtual product(s) only, so a shipping address is not used. - * @throws StateException The billing or shipping address is missing. Set the address and try again. */ public function apply($cartId, $carrierCode, $methodCode) { @@ -191,7 +189,7 @@ public function apply($cartId, $carrierCode, $methodCode) } $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { - throw new StateException(__('The shipping address is missing. Set the address and try again.')); + return; } $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); } diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php index 198f1c54a42b4..6042ab25eef7f 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php @@ -344,10 +344,6 @@ public function testSetMethodWithVirtualProduct() $this->model->set($cartId, $carrierCode, $methodCode); } - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage The shipping address is missing. Set the address and try again. - */ public function testSetMethodWithoutShippingAddress() { $cartId = 12; @@ -361,6 +357,7 @@ public function testSetMethodWithoutShippingAddress() $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); $this->quote->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress)); + $this->quote->expects($this->once())->method('collectTotals')->willReturnSelf(); $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); $this->model->set($cartId, $carrierCode, $methodCode); @@ -402,10 +399,6 @@ public function testSetMethodWithCouldNotSaveException() $this->model->set($cartId, $carrierCode, $methodCode); } - /** - * @expectedException \Magento\Framework\Exception\StateException - * @expectedExceptionMessage The shipping address is missing. Set the address and try again. - */ public function testSetMethodWithoutAddress() { $cartId = 12; @@ -420,6 +413,7 @@ public function testSetMethodWithoutAddress() $this->quote->expects($this->once()) ->method('getShippingAddress') ->willReturn($this->shippingAddress); + $this->quote->expects($this->once())->method('collectTotals')->willReturnSelf(); $this->shippingAddress->expects($this->once())->method('getCountryId'); $this->model->set($cartId, $carrierCode, $methodCode); From b8b6f3814f9d5d497384ee4c07cb93ce9b1db31f Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Fri, 20 Jul 2018 10:34:29 +0200 Subject: [PATCH 02/51] Fixed return value for getGraphQlClient --- .../Magento/TestFramework/TestCase/GraphQlAbstract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php index af01e455fdd9d..ba64a3e9eee8f 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php @@ -93,8 +93,8 @@ private function getGraphQlClient() { if ($this->graphQlClient === null) { return Bootstrap::getObjectManager()->get(\Magento\TestFramework\TestCase\GraphQl\Client::class); - } else { - $this->graphQlClient; } + + return $this->graphQlClient; } } From adbf6473b36e03703aa1fa612a31285abb38008d Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Tue, 24 Jul 2018 10:31:41 +0200 Subject: [PATCH 03/51] Added assignment instead of direct return --- .../Magento/TestFramework/TestCase/GraphQlAbstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php index ba64a3e9eee8f..936cbfdb5106f 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php @@ -92,7 +92,7 @@ private function getAppCache() private function getGraphQlClient() { if ($this->graphQlClient === null) { - return Bootstrap::getObjectManager()->get(\Magento\TestFramework\TestCase\GraphQl\Client::class); + $this->graphQlClient = Bootstrap::getObjectManager()->get(\Magento\TestFramework\TestCase\GraphQl\Client::class); } return $this->graphQlClient; From 3ab543e61ad5118f57d827ad617fdcd66697cf0e Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Thu, 9 Aug 2018 00:28:44 +0300 Subject: [PATCH 04/51] Added unit test for AvailabilityChecker --- .../CreditCard/AvailabilityCheckerTest.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php diff --git a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php new file mode 100644 index 0000000000000..9e3f58f2ffe5c --- /dev/null +++ b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php @@ -0,0 +1,70 @@ +configMock = $this->createMock(Config::class); + $this->availabilityChecker = new AvailabilityChecker($this->configMock); + } + + /** + * Test isAvailable method + * + * @dataProvider isAvailableDataProvider + * + * @param bool $isVerify3DSecure + * @param bool $expected + * + * @return void + */ + public function testIsAvailable(bool $isVerify3DSecure, bool $expected) + { + $this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure); + $actual = $this->availabilityChecker->isAvailable(); + self::assertEquals($expected, $actual); + } + + /** + * Data provider for isAvailable method test + * + * @return array + */ + public function isAvailableDataProvider() + { + return [ + [true, false], + [false, true], + ]; + } +} From 2d85db35a88da101dcbc0318c6c711d8fd3e50a6 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Thu, 9 Aug 2018 09:25:47 +0300 Subject: [PATCH 05/51] Braintree: Add unit test for PaymentAdditionalInformationProvider --- ...ymentAdditionalInformationProviderTest.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php diff --git a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php new file mode 100644 index 0000000000000..1d2aa9df5bcf3 --- /dev/null +++ b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php @@ -0,0 +1,83 @@ +getPaymentNonceCommandMock = $this->createMock(GetPaymentNonceCommand::class); + $this->paymentTokenMock = $this->createMock(PaymentTokenInterface::class); + $this->arrayResultMock = $this->createMock(ArrayResult::class); + $this->paymentAdditionalInformationProvider = new PaymentAdditionalInformationProvider( + $this->getPaymentNonceCommandMock + ); + } + + /** + * Test getAdditionalInformation method + * + * @return void + */ + public function testGetAdditionalInformation() + { + $customerId = 15; + $publicHash = '3n4b7sn48g'; + $paymentMethodNonce = 'test'; + + $this->paymentTokenMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); + $this->paymentTokenMock->expects($this->once())->method('getPublicHash')->willReturn($publicHash); + $this->getPaymentNonceCommandMock->expects($this->once())->method('execute')->with([ + PaymentTokenInterface::CUSTOMER_ID => $customerId, + PaymentTokenInterface::PUBLIC_HASH => $publicHash, + ])->willReturn($this->arrayResultMock); + $this->arrayResultMock->expects($this->once())->method('get') + ->willReturn(['paymentMethodNonce' => $paymentMethodNonce]); + + $expected = [ + 'payment_method_nonce' => $paymentMethodNonce, + ]; + $actual = $this->paymentAdditionalInformationProvider->getAdditionalInformation($this->paymentTokenMock); + self::assertEquals($expected, $actual); + } +} From 13fc94be83d249ebaa903f8887f743a263a14e28 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Thu, 9 Aug 2018 09:31:23 +0300 Subject: [PATCH 06/51] Fix typo --- .../InstantPurchase/CreditCard/AvailabilityCheckerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php index 9e3f58f2ffe5c..2248aab1aad2e 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/AvailabilityCheckerTest.php @@ -28,7 +28,7 @@ class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase private $configMock; /** - * Se Up + * Set Up * * @return void */ From 23f12b960f8ae728c4d5ce6bdf7232a4822dd2ea Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Thu, 9 Aug 2018 09:56:33 +0300 Subject: [PATCH 07/51] Braintree: Add unit test for LocaleResolver --- .../Test/Unit/Model/LocaleResolverTest.php | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php diff --git a/app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php b/app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php new file mode 100644 index 0000000000000..b6ef534c55c29 --- /dev/null +++ b/app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php @@ -0,0 +1,138 @@ +configMock = $this->createMock(Config::class); + $this->resolverMock = $this->createMock(ResolverInterface::class); + $this->localeResolver = new LocaleResolver($this->resolverMock, $this->configMock); + } + + /** + * Test getDefaultLocalePath method + * + * @return void + */ + public function testGetDefaultLocalePath() + { + $expected = 'general/locale/code'; + $this->resolverMock->expects($this->once())->method('getDefaultLocalePath')->willReturn($expected); + $actual = $this->localeResolver->getDefaultLocalePath(); + self::assertEquals($expected, $actual); + } + + /** + * Test setDefaultLocale method + * + * @return void + */ + public function testSetDefaultLocale() + { + $defaultLocale = 'en_US'; + $this->resolverMock->expects($this->once())->method('setDefaultLocale')->with($defaultLocale); + $this->localeResolver->setDefaultLocale($defaultLocale); + } + + /** + * Test getDefaultLocale method + * + * @return void + */ + public function testGetDefaultLocale() + { + $expected = 'fr_FR'; + $this->resolverMock->expects($this->once())->method('getDefaultLocale')->willReturn($expected); + $actual = $this->localeResolver->getDefaultLocale(); + self::assertEquals($expected, $actual); + } + + /** + * Test setLocale method + * + * @return void + */ + public function testSetLocale() + { + $locale = 'en_GB'; + $this->resolverMock->expects($this->once())->method('setLocale')->with($locale); + $this->localeResolver->setLocale($locale); + } + + /** + * Test getLocale method + * + * @return void + */ + public function testGetLocale() + { + $locale = 'en_TEST'; + $allowedLocales = 'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,nl_NL'; + $this->resolverMock->expects($this->once())->method('getLocale')->willReturn($locale); + $this->configMock->expects($this->once())->method('getValue')->with('supported_locales') + ->willReturn($allowedLocales); + + $expected = 'en_US'; + $actual = $this->localeResolver->getLocale(); + self::assertEquals($expected, $actual); + } + + /** + * Test emulate method + * + * @return void + */ + public function testEmulate() + { + $scopeId = 12; + $this->resolverMock->expects($this->once())->method('emulate')->with($scopeId); + $this->localeResolver->emulate($scopeId); + } + + /** + * Test revert method + * + * @return void + */ + public function testRevert() + { + $this->resolverMock->expects($this->once())->method('revert'); + $this->localeResolver->revert(); + } +} From 2892b05146f1e63d5db43df7afea41fded934db4 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Thu, 9 Aug 2018 09:59:25 +0300 Subject: [PATCH 08/51] Update namespace --- .../PaymentAdditionalInformationProviderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php index 1d2aa9df5bcf3..2631fcbe5f5b5 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/PaymentAdditionalInformationProviderTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\CreditCard; +namespace Magento\Braintree\Test\Unit\Model\InstantPurchase; use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand; use Magento\Braintree\Model\InstantPurchase\PaymentAdditionalInformationProvider; From ddf25093d4bef2b522f118279d45caf02b4d0faa Mon Sep 17 00:00:00 2001 From: Glenn Date: Mon, 16 Jul 2018 16:40:05 +0800 Subject: [PATCH 09/51] fix: Doesn't work if use date as condition for Catalog Price Rules --- app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php index 51cb6638af48b..ab650c94a0f08 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Condition/Product.php @@ -99,6 +99,10 @@ protected function _prepareDatetimeValue($value, \Magento\Framework\Model\Abstra { $attribute = $model->getResource()->getAttribute($this->getAttribute()); if ($attribute && $attribute->getBackendType() == 'datetime') { + if (!$value) { + return null; + } + $this->setValue(strtotime($this->getValue())); $value = strtotime($value); } From 9868428966220ddc23fe04f3af985eab2d66ff59 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Sun, 12 Aug 2018 10:16:19 +0300 Subject: [PATCH 10/51] Fix the issue with "Shipping address is not set" exception, Fix the integrity constraint violation error when trying to access Shopping Cart --- .../Multishipping/Controller/Checkout.php | 11 ++++++++++- app/code/Magento/Multishipping/Helper/Url.php | 10 ++++++++++ .../Quote/Model/ShippingMethodManagement.php | 18 ++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index 161021768ce19..92417c7cb3a18 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -8,6 +8,7 @@ use Magento\Customer\Api\AccountManagementInterface; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\Exception\StateException; /** * Multishipping checkout controller @@ -153,7 +154,15 @@ public function dispatch(RequestInterface $request) return parent::dispatch($request); } - $quote = $this->_getCheckout()->getQuote(); + try { + $checkout = $this->_getCheckout(); + } catch (StateException $e) { + $this->getResponse()->setRedirect($this->_getHelper()->getMSNewShippingUrl()); + $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); + return parent::dispatch($request); + } + + $quote = $checkout->getQuote(); if (!$quote->hasItems() || $quote->getHasError() || $quote->isVirtual()) { $this->getResponse()->setRedirect($this->_getHelper()->getCartUrl()); $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); diff --git a/app/code/Magento/Multishipping/Helper/Url.php b/app/code/Magento/Multishipping/Helper/Url.php index e293e3d4d7121..eaefa8fe8bee3 100644 --- a/app/code/Magento/Multishipping/Helper/Url.php +++ b/app/code/Magento/Multishipping/Helper/Url.php @@ -63,6 +63,16 @@ public function getMSShippingAddressSavedUrl() return $this->_getUrl('multishipping/checkout_address/shippingSaved'); } + /** + * Retrieve register url + * + * @return string + */ + public function getMSNewShippingUrl() + { + return $this->_getUrl('multishipping/checkout_address/newShipping'); + } + /** * Retrieve register url * diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index ac609e7f435ea..f62866539c6cc 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -16,6 +16,7 @@ use Magento\Quote\Api\Data\AddressInterface; use Magento\Quote\Api\Data\EstimateAddressInterface; use Magento\Quote\Api\ShipmentEstimationInterface; +use Magento\Quote\Model\ResourceModel\Quote\Address as QuoteAddressResource; /** * Shipping method read service @@ -63,6 +64,11 @@ class ShippingMethodManagement implements */ private $addressFactory; + /** + * @var QuoteAddressResource + */ + private $quoteAddressResource; + /** * Constructor * @@ -71,13 +77,15 @@ class ShippingMethodManagement implements * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository * @param Quote\TotalsCollector $totalsCollector * @param AddressInterfaceFactory|null $addressFactory + * @param QuoteAddressResource|null $quoteAddressResource */ public function __construct( \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, Cart\ShippingMethodConverter $converter, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector, - AddressInterfaceFactory $addressFactory = null + AddressInterfaceFactory $addressFactory = null, + QuoteAddressResource $quoteAddressResource = null ) { $this->quoteRepository = $quoteRepository; $this->converter = $converter; @@ -85,6 +93,8 @@ public function __construct( $this->totalsCollector = $totalsCollector; $this->addressFactory = $addressFactory ?: ObjectManager::getInstance() ->get(AddressInterfaceFactory::class); + $this->quoteAddressResource = $quoteAddressResource ?: ObjectManager::getInstance() + ->get(QuoteAddressResource::class); } /** @@ -172,6 +182,8 @@ public function set($cartId, $carrierCode, $methodCode) * @return void * @throws InputException The shipping method is not valid for an empty cart. * @throws NoSuchEntityException CThe Cart includes virtual product(s) only, so a shipping address is not used. + * @throws StateException The billing or shipping address is not set. + * @throws \Exception */ public function apply($cartId, $carrierCode, $methodCode) { @@ -189,7 +201,9 @@ public function apply($cartId, $carrierCode, $methodCode) } $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { - return; + // Remove empty quote address + $this->quoteAddressResource->delete($shippingAddress); + throw new StateException(__('The shipping address is missing. Set the address and try again.')); } $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); } From 2c546c4d67d1b8434405874f80c02eb898c3dced Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Sun, 12 Aug 2018 10:44:14 +0300 Subject: [PATCH 11/51] Update PHPUnit tests --- .../Model/ShippingMethodManagementTest.php | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php index 6042ab25eef7f..34d7707d31666 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php @@ -15,7 +15,9 @@ use Magento\Quote\Model\Quote\Address\Rate; use Magento\Quote\Model\Quote\TotalsCollector; use Magento\Quote\Model\QuoteRepository; +use Magento\Quote\Model\ResourceModel\Quote\Address as QuoteAddressResource; use Magento\Quote\Model\ShippingMethodManagement; +use Magento\Store\Model\Store; use PHPUnit_Framework_MockObject_MockObject as MockObject; /** @@ -83,6 +85,16 @@ class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase */ private $totalsCollector; + /** + * @var Store|MockObject + */ + private $storeMock; + + /** + * @var QuoteAddressResource|MockObject + */ + private $quoteAddressResource; + protected function setUp() { $this->objectManager = new ObjectManager($this); @@ -98,7 +110,8 @@ protected function setUp() $className = \Magento\Framework\Reflection\DataObjectProcessor::class; $this->dataProcessor = $this->createMock($className); - $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->quoteAddressResource = $this->createMock(QuoteAddressResource::class); + $this->storeMock = $this->createMock(Store::class); $this->quote = $this->getMockBuilder(Quote::class) ->disableOriginalConstructor() ->setMethods([ @@ -150,6 +163,7 @@ protected function setUp() 'converter' => $this->converter, 'totalsCollector' => $this->totalsCollector, 'addressRepository' => $this->addressRepository, + 'quoteAddressResource' => $this->quoteAddressResource, ] ); @@ -344,6 +358,10 @@ public function testSetMethodWithVirtualProduct() $this->model->set($cartId, $carrierCode, $methodCode); } + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage The shipping address is missing. Set the address and try again. + */ public function testSetMethodWithoutShippingAddress() { $cartId = 12; @@ -357,8 +375,8 @@ public function testSetMethodWithoutShippingAddress() $this->quote->expects($this->once())->method('isVirtual')->will($this->returnValue(false)); $this->quote->expects($this->once()) ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress)); - $this->quote->expects($this->once())->method('collectTotals')->willReturnSelf(); $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(null)); + $this->quoteAddressResource->expects($this->once())->method('delete')->with($this->shippingAddress); $this->model->set($cartId, $carrierCode, $methodCode); } @@ -399,6 +417,10 @@ public function testSetMethodWithCouldNotSaveException() $this->model->set($cartId, $carrierCode, $methodCode); } + /** + * @expectedException \Magento\Framework\Exception\StateException + * @expectedExceptionMessage The shipping address is missing. Set the address and try again. + */ public function testSetMethodWithoutAddress() { $cartId = 12; @@ -413,8 +435,8 @@ public function testSetMethodWithoutAddress() $this->quote->expects($this->once()) ->method('getShippingAddress') ->willReturn($this->shippingAddress); - $this->quote->expects($this->once())->method('collectTotals')->willReturnSelf(); $this->shippingAddress->expects($this->once())->method('getCountryId'); + $this->quoteAddressResource->expects($this->once())->method('delete')->with($this->shippingAddress); $this->model->set($cartId, $carrierCode, $methodCode); } From df54a2694092ac50f1a68eebe3731d21f74c6b11 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 14 Feb 2018 11:54:54 +0200 Subject: [PATCH 12/51] bug: Fix possible undefined index when caching config data --- app/code/Magento/Config/App/Config/Type/System.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 4f6d9c14346f0..479b4f5c21732 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -245,7 +245,7 @@ private function cacheData(array $data) ); $scopes = []; foreach (['websites', 'stores'] as $curScopeType) { - foreach ($data[$curScopeType] as $curScopeId => $curScopeData) { + foreach ($data[$curScopeType] ?? [] as $curScopeId => $curScopeData) { $scopes[$curScopeType][$curScopeId] = 1; $this->cache->save( $this->serializer->serialize($curScopeData), From 1c74f5576011cd442dc086e52935c9fe68e7aa3e Mon Sep 17 00:00:00 2001 From: eduard13 Date: Sun, 12 Aug 2018 22:40:08 +0300 Subject: [PATCH 13/51] Adding roles to images array --- .../Catalog/Model/ProductRepository.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 4c0122694285d..d7fbcbcd523f8 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -514,8 +514,13 @@ protected function processMediaGallery(ProductInterface $product, $mediaGalleryE $newEntries = $mediaGalleryEntries; } - $this->getMediaGalleryProcessor()->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); $images = $product->getMediaGallery('images'); + if ($images) { + $images = $this->determineImageRoles($product, $images); + } + + $this->getMediaGalleryProcessor()->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); + if ($images) { foreach ($images as $image) { if (!isset($image['removed']) && !empty($image['types'])) { @@ -758,6 +763,32 @@ public function cleanCache() $this->instancesById = null; } + /** + * Ascertain image roles, if they are not set against the gallery entries + * + * @param ProductInterface $product + * @param array $images + * @return array + */ + private function determineImageRoles(ProductInterface $product, array $images) + { + $imagesWithRoles = []; + foreach ($images as $image) { + if (!isset($image['types'])) { + $image['types'] = []; + if (isset($image['file'])) { + foreach (array_keys($product->getMediaAttributes()) as $attribute) { + if ($image['file'] == $product->getData($attribute)) { + $image['types'][] = $attribute; + } + } + } + } + $imagesWithRoles[] = $image; + } + return $imagesWithRoles; + } + /** * @return Product\Gallery\Processor */ From 897e7df9441d121af626cace56cbc2a53e35c38d Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Mon, 13 Aug 2018 09:42:40 +0300 Subject: [PATCH 14/51] Fix wrong return type in StockRegistryInterface API --- .../Magento/CatalogInventory/Api/StockRegistryInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php index c9b6abeb72e23..2d011e24f4105 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php @@ -72,7 +72,7 @@ public function getProductStockStatusBySku($productSku, $scopeId = null); * @param float $qty * @param int $currentPage * @param int $pageSize - * @return \Magento\CatalogInventory\Api\Data\StockStatusCollectionInterface + * @return \Magento\CatalogInventory\Api\Data\StockItemCollectionInterface */ public function getLowStockItems($scopeId, $qty, $currentPage = 1, $pageSize = 0); From bcdd5986606b06ab93127ec11f6f09b27d0a2a45 Mon Sep 17 00:00:00 2001 From: Arnoud Beekman Date: Fri, 10 Aug 2018 22:04:25 +0200 Subject: [PATCH 15/51] Refactor: remove some code duplication + Complex statement that was executed three times moved to separate method so the logic is only on one place + The calculation for the index of the last record moved to a variable so the calculation is only being done once. This also reduces the amount of times `this.getChildItems()` is being called. --- .../base/web/js/dynamic-rows/dynamic-rows.js | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js index 7537107560cb4..870ad96732014 100644 --- a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js +++ b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js @@ -330,9 +330,7 @@ define([ } if (this.defaultPagesState[this.currentPage()]) { - this.pagesChanged[this.currentPage()] = - !compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems())); - this.changed(_.some(this.pagesChanged)); + this.setChangedForCurrentPage(); } }, @@ -442,13 +440,9 @@ define([ return initialize; })); - this.pagesChanged[this.currentPage()] = - !compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems())); - this.changed(_.some(this.pagesChanged)); + this.setChangedForCurrentPage(); } else if (this.hasInitialPagesState[this.currentPage()]) { - this.pagesChanged[this.currentPage()] = - !compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems())); - this.changed(_.some(this.pagesChanged)); + this.setChangedForCurrentPage(); } }, @@ -848,7 +842,8 @@ define([ deleteRecord: function (index, recordId) { var recordInstance, lastRecord, - recordsData; + recordsData, + lastRecordIndex; if (this.deleteProperty) { recordsData = this.recordData(); @@ -867,12 +862,13 @@ define([ this.update = true; if (~~this.currentPage() === this.pages()) { + lastRecordIndex = (this.startIndex + this.getChildItems().length - 1); lastRecord = _.findWhere(this.elems(), { - index: this.startIndex + this.getChildItems().length - 1 + index: lastRecordIndex }) || _.findWhere(this.elems(), { - index: (this.startIndex + this.getChildItems().length - 1).toString() + index: lastRecordIndex.toString() }); lastRecord.destroy(); @@ -1133,6 +1129,18 @@ define([ }); this.isDifferedFromDefault(!_.isEqual(recordData, this.default)); + }, + + /** + * Set the changed property if the current page is different + * than the default state + * + * @return void + */ + setChangedForCurrentPage: function () { + this.pagesChanged[this.currentPage()] = + !compareArrays(this.defaultPagesState[this.currentPage()], this.arrayFilter(this.getChildItems())); + this.changed(_.some(this.pagesChanged)); } }); }); From 50e74cd04b835760ea5b53cad47f61ec5f83892a Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Mon, 13 Aug 2018 08:52:48 +0300 Subject: [PATCH 16/51] Catalog: Add unit tests for Cron classes --- .../DeleteAbandonedStoreFlatTablesTest.php | 51 +++++++ .../Cron/DeleteOutdatedPriceValuesTest.php | 125 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php create mode 100644 app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php new file mode 100644 index 0000000000000..cd017dbcafbc2 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php @@ -0,0 +1,51 @@ +indexerMock = $this->createMock(Indexer::class); + $this->deleteAbandonedStoreFlatTables = new DeleteAbandonedStoreFlatTables($this->indexerMock); + } + + /** + * Test execute method + * + * @return void + */ + public function testExecute() + { + $this->indexerMock->expects($this->once())->method('deleteAbandonedStoreFlatTables'); + $this->deleteAbandonedStoreFlatTables->execute(); + } +} diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php new file mode 100644 index 0000000000000..304e203f228af --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php @@ -0,0 +1,125 @@ +resourceConnectionMock = $this->createMock(ResourceConnection::class); + $this->attributeRepositoryMock = $this->createMock(AttributeRepository::class); + $this->attributeMock = $this->createMock(Attribute::class); + $this->scopeConfigMock = $this->createMock(ScopeConfig::class); + $this->dbAdapterMock = $this->createMock(AdapterInterface::class); + $this->attributeBackendMock = $this->createMock(BackendInterface::class); + $this->deleteOutdatedPriceValues = new DeleteOutdatedPriceValues( + $this->resourceConnectionMock, + $this->attributeRepositoryMock, + $this->scopeConfigMock + ); + } + + /** + * Test execute method + * + * @return void + */ + public function testExecute() + { + $table = 'catalog_product_entity_decimal'; + $attributeId = 15; + $conditions = ['first', 'second']; + + $this->scopeConfigMock->expects($this->once())->method('getValue')->with(Store::XML_PATH_PRICE_SCOPE) + ->willReturn(Store::XML_PATH_PRICE_SCOPE); + $this->attributeRepositoryMock->expects($this->once())->method('get') + ->with(ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_PRICE) + ->willReturn($this->attributeMock); + $this->attributeMock->expects($this->once())->method('getId')->willReturn($attributeId); + $this->attributeMock->expects($this->once())->method('getBackend')->willReturn($this->attributeBackendMock); + $this->attributeBackendMock->expects($this->once())->method('getTable')->willReturn($table); + $this->resourceConnectionMock->expects($this->once())->method('getConnection')->willReturn($this->dbAdapterMock); + $this->dbAdapterMock->expects($this->exactly(2))->method('quoteInto')->willReturnMap([ + ['attribute_id = ?', $attributeId, null, null, $conditions[0]], + ['store_id != ?', Store::DEFAULT_STORE_ID, null, null, $conditions[1]], + ]); + $this->dbAdapterMock->expects($this->once())->method('delete')->with($table, $conditions); + $this->deleteOutdatedPriceValues->execute(); + } + + /** + * Test execute method + * The price scope config option is not equal to global value + * + * @return void + */ + public function testExecutePriceConfigIsNotSetToGlobal() + { + $this->scopeConfigMock->expects($this->once())->method('getValue')->with(Store::XML_PATH_PRICE_SCOPE) + ->willReturn(null); + $this->attributeRepositoryMock->expects($this->never())->method('get'); + $this->dbAdapterMock->expects($this->never())->method('delete'); + + $this->deleteOutdatedPriceValues->execute(); + } +} From c982b6221b826ae6401ede037575213a91aa74d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:30:30 +0300 Subject: [PATCH 17/51] removed lib-url-check --- lib/web/css/docs/source/_variables.less | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lib/web/css/docs/source/_variables.less b/lib/web/css/docs/source/_variables.less index 326580ead813f..e1845786067c8 100644 --- a/lib/web/css/docs/source/_variables.less +++ b/lib/web/css/docs/source/_variables.less @@ -7375,21 +7375,3 @@ // // // -// -// #### .lib-url-check() mixin variables -//
-//    
-//        
-//            
-//            
-//            
-//            
-//        
-//        
-//            
-//            
-//            
-//            
-//        
-//    
Mixin variableAllowed valuesOutput variableComment
@_path'' | false | value@lib-url-check-outputPassed url to wrap in 'url( ... )'. If the 'false' value passed mixin will return 'false'
-//
From 15fbeb676c503002837c464ecce21a8f37e50839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:35:17 +0300 Subject: [PATCH 18/51] removed lib-url-check --- lib/web/css/docs/docs.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/docs.html b/lib/web/css/docs/docs.html index 164e5a1dfdc21..68e9d98eb2def 100644 --- a/lib/web/css/docs/docs.html +++ b/lib/web/css/docs/docs.html @@ -40,4 +40,4 @@ body { padding: 15px; background-image: none; -}
+}
From ae9d62a6f84feda7662a69b79ae13160702cdcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:37:56 +0300 Subject: [PATCH 19/51] remove lib-url-check --- lib/web/css/docs/actions-toolbar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/actions-toolbar.html b/lib/web/css/docs/actions-toolbar.html index 4a3fbe515ca95..0c2186bf0458c 100644 --- a/lib/web/css/docs/actions-toolbar.html +++ b/lib/web/css/docs/actions-toolbar.html @@ -301,4 +301,4 @@ .example-actions-toolbar-12 { .lib-actions-toolbar-clear-floats(); } -}
+}
From 074bc271490e81d51826d6b60a6989792ef18d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:38:31 +0300 Subject: [PATCH 20/51] remove lib-url-check --- lib/web/css/docs/breadcrumbs.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/breadcrumbs.html b/lib/web/css/docs/breadcrumbs.html index 9ada940b4c0de..e4bfc3a973aa1 100644 --- a/lib/web/css/docs/breadcrumbs.html +++ b/lib/web/css/docs/breadcrumbs.html @@ -502,4 +502,4 @@ border-color: transparent transparent transparent #ccc; } } -}
+}
From a7ddbb7062705b3f8a0fed20e871723addf2e670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:39:14 +0300 Subject: [PATCH 21/51] remove lib-url-check --- lib/web/css/docs/buttons.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/buttons.html b/lib/web/css/docs/buttons.html index 0890701226d3c..502d35da59a99 100644 --- a/lib/web/css/docs/buttons.html +++ b/lib/web/css/docs/buttons.html @@ -875,4 +875,4 @@

Primary button big

-
+
From 9872e741a9f78dc5ffa81018529d93bf850d8ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:39:53 +0300 Subject: [PATCH 22/51] remove lib-url-check --- lib/web/css/docs/components.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/components.html b/lib/web/css/docs/components.html index 609bd4d3ffa00..9e0b149c989a9 100644 --- a/lib/web/css/docs/components.html +++ b/lib/web/css/docs/components.html @@ -147,4 +147,4 @@

Modal Slide

-
+
From 358cbdfc76667f1fa2ed9411efcd977471e96c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:40:32 +0300 Subject: [PATCH 23/51] remove lib-url-check --- lib/web/css/docs/dropdowns.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/dropdowns.html b/lib/web/css/docs/dropdowns.html index 6f0c95a723beb..eb9efc9a65078 100644 --- a/lib/web/css/docs/dropdowns.html +++ b/lib/web/css/docs/dropdowns.html @@ -876,4 +876,4 @@

Split button: button+button

@_dropdown-split-list-shadow: none, @_dropdown-split-button-border-radius-fix: true ); -}
+}
From 96af19cd0f52d1bc014e45c18effe601b32477fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:41:10 +0300 Subject: [PATCH 24/51] remove lib-url-check --- lib/web/css/docs/forms.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/forms.html b/lib/web/css/docs/forms.html index ca3e2e6184677..211a9bd650ba0 100644 --- a/lib/web/css/docs/forms.html +++ b/lib/web/css/docs/forms.html @@ -1133,4 +1133,4 @@

Simple form with "require -
+
From 917394cc11a3637a1f4b0f5afac79cc42f12dd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:41:49 +0300 Subject: [PATCH 25/51] remove lib-url-check --- lib/web/css/docs/icons.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/icons.html b/lib/web/css/docs/icons.html index 1dca9797fc560..d7eeff7f802ca 100644 --- a/lib/web/css/docs/icons.html +++ b/lib/web/css/docs/icons.html @@ -847,4 +847,4 @@

Icons using sprite

} } } -}
+}
From 3d8d5224bfd90bf834e4f8d6401878888d124429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:43:42 +0300 Subject: [PATCH 26/51] remove lib-url-check --- lib/web/css/docs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/index.html b/lib/web/css/docs/index.html index cbf3de48cdfc7..07cd72e6f823f 100644 --- a/lib/web/css/docs/index.html +++ b/lib/web/css/docs/index.html @@ -608,4 +608,4 @@

Location

Extends that used in more than one theme should be saved in lib lib/source/_abstract.less (will be renamed to _extend.less)

Naming

Extend class names should have prefix .abs- (from abstract)

-
+
From 290fd99bcef8819b30fd092bbd239df8051e1e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:44:10 +0300 Subject: [PATCH 27/51] remove lib-url-check --- lib/web/css/docs/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/layout.html b/lib/web/css/docs/layout.html index a75e366f621ad..77ed0597f0748 100644 --- a/lib/web/css/docs/layout.html +++ b/lib/web/css/docs/layout.html @@ -340,4 +340,4 @@

Three columns page layout

-
+
From da798ae926a3e0e21b2710a776432cfca51dc24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:44:39 +0300 Subject: [PATCH 28/51] remove lib-url-check --- lib/web/css/docs/lib.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/lib.html b/lib/web/css/docs/lib.html index ccd5873e94303..001e8aeecd308 100644 --- a/lib/web/css/docs/lib.html +++ b/lib/web/css/docs/lib.html @@ -10,4 +10,4 @@

The _lib.less file contains the includes of all Magento UI library files. To use Magento UI library in your theme add the following directive to the theme’s styles.less:

  @import 'source/lib/_lib';

The lib.less file is designed to avoid manual adding of each Magento UI library file import instruction to your theme.

-
+
From ddfb194a71f3a96529f9e67bbc4b670ca3bd2190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:45:36 +0300 Subject: [PATCH 29/51] remove lib-url-check --- lib/web/css/docs/loaders.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/loaders.html b/lib/web/css/docs/loaders.html index 6d63110cfafea..884b71c782905 100644 --- a/lib/web/css/docs/loaders.html +++ b/lib/web/css/docs/loaders.html @@ -182,4 +182,4 @@ -
+
From 183c998e555312b075cc776e2fc4ec96f611e936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:46:04 +0300 Subject: [PATCH 30/51] remove lib-url-check --- lib/web/css/docs/messages.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/messages.html b/lib/web/css/docs/messages.html index 305266906e3d0..287bf1b0d3aa4 100644 --- a/lib/web/css/docs/messages.html +++ b/lib/web/css/docs/messages.html @@ -711,4 +711,4 @@ -
+
From 373cbae1aede4027d2ba494d43c5d8ffd642b2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:47:01 +0300 Subject: [PATCH 31/51] remove lib-url-check --- lib/web/css/docs/pages.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/pages.html b/lib/web/css/docs/pages.html index 8b7335d86b8da..1bbcac94c56f8 100644 --- a/lib/web/css/docs/pages.html +++ b/lib/web/css/docs/pages.html @@ -826,4 +826,4 @@ @_pager-action-color-hover: #fff, @_pager-action-color-active: #fff ); -}
+}
From f550c9b25810df37a8678bf4e4a63bc54c0d8db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:47:51 +0300 Subject: [PATCH 32/51] remove lib-url-check --- lib/web/css/docs/popups.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/popups.html b/lib/web/css/docs/popups.html index d31d50f6ed7c6..9f7aff4c6569b 100644 --- a/lib/web/css/docs/popups.html +++ b/lib/web/css/docs/popups.html @@ -750,4 +750,4 @@

Simple popup

@_overlay-opacity: .8, @_overlay-opacity-old: 80 ); -}
+}
From e886063dff3858e8bf6907348525062f49bb280f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:48:43 +0300 Subject: [PATCH 33/51] remove lib-url-check --- lib/web/css/docs/rating.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/rating.html b/lib/web/css/docs/rating.html index bf74c47c22f11..3cfe1a864dd98 100644 --- a/lib/web/css/docs/rating.html +++ b/lib/web/css/docs/rating.html @@ -343,4 +343,4 @@
.example-rating-summary-7 {
     .lib-rating-summary();
     .lib-rating-summary-label-hide();
-}
+}
From 5e7b9e710c906c286f6cbd6cfdef081d7692da61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:49:19 +0300 Subject: [PATCH 34/51] remove lib-url-check --- lib/web/css/docs/resets.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/resets.html b/lib/web/css/docs/resets.html index f2eb5ee9b48db..fc1cb092422c0 100644 --- a/lib/web/css/docs/resets.html +++ b/lib/web/css/docs/resets.html @@ -34,4 +34,4 @@

Global border-box

To set box-sizing: border-box globally, use mixin:

  .lib-set-default-border-box();

 

-
+
From 7f173f6707b31832902f1b1fb102c5d677e15290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:49:43 +0300 Subject: [PATCH 35/51] remove lib-url-check --- lib/web/css/docs/responsive.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/responsive.html b/lib/web/css/docs/responsive.html index 5e9d3b38eddd0..48d0bd551bd92 100644 --- a/lib/web/css/docs/responsive.html +++ b/lib/web/css/docs/responsive.html @@ -80,4 +80,4 @@

Gathering

@screen__l: 1024px; @screen__xl: 1440px;

 

-
+
From 988820bc60842ec2f9b3706e0b75c4d2378bccbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:50:20 +0300 Subject: [PATCH 36/51] remove lib-url-check --- lib/web/css/docs/sections.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/sections.html b/lib/web/css/docs/sections.html index c433216775ef4..8ed121578757a 100644 --- a/lib/web/css/docs/sections.html +++ b/lib/web/css/docs/sections.html @@ -643,4 +643,4 @@ </dl>
.example-sections-6 {
     .lib-data-accordion__base();
-}
+}
From 3fe56763fc8798933678704fa2cfc9a2fd175a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:50:56 +0300 Subject: [PATCH 37/51] remove lib-url-check --- lib/web/css/docs/tables.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/tables.html b/lib/web/css/docs/tables.html index 5a5067ebd0e4b..280f32135de62 100644 --- a/lib/web/css/docs/tables.html +++ b/lib/web/css/docs/tables.html @@ -1498,4 +1498,4 @@ -
+
From 475ee79dd365e5d4f14aea50c760d5cb1c965733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:51:55 +0300 Subject: [PATCH 38/51] remove lib-url-check --- lib/web/css/docs/tooltips.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/tooltips.html b/lib/web/css/docs/tooltips.html index 20158046859f6..2b38aa0a55aef 100644 --- a/lib/web/css/docs/tooltips.html +++ b/lib/web/css/docs/tooltips.html @@ -186,4 +186,4 @@ -
+
From 904b16819171fdc654215742f15bd08b6a51b8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:53:06 +0300 Subject: [PATCH 39/51] remove lib-url-check --- lib/web/css/docs/typography.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/typography.html b/lib/web/css/docs/typography.html index 76f704c17c1bd..a933bcb46bf64 100644 --- a/lib/web/css/docs/typography.html +++ b/lib/web/css/docs/typography.html @@ -1686,4 +1686,4 @@ -
+
From f34491b2e4e5b223697575f820fbb37facc76778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:54:05 +0300 Subject: [PATCH 40/51] remove lib-url-check --- lib/web/css/docs/variables.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/css/docs/variables.html b/lib/web/css/docs/variables.html index 4423d682d0f80..4f353dc1554a4 100644 --- a/lib/web/css/docs/variables.html +++ b/lib/web/css/docs/variables.html @@ -7391,4 +7391,4 @@

.lib-url-check() mixin -
+
From 49ddf600e66988f1d0eafb4c24f7fbd5f9db8400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= Date: Thu, 9 Aug 2018 21:59:22 +0300 Subject: [PATCH 41/51] remove lib-url-check --- lib/web/css/docs/utilities.html | 48 +-------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/lib/web/css/docs/utilities.html b/lib/web/css/docs/utilities.html index 29ecce2414e1e..8ab4a1136967e 100644 --- a/lib/web/css/docs/utilities.html +++ b/lib/web/css/docs/utilities.html @@ -261,50 +261,4 @@ -

.lib-url-check()

-

The .lib-url-check() mixin wraps passed value with 'url( ... )' and returns @lib-url-check-output variable. Can be used with .lib-css() mixin.

-

If the variable is set to false, the .lib-url-check() will return false.

- -
.example-url-check {
-    //  Set image path variable
-    @_icon-image: '/images/test.png';
-
-    //  "Call" the mixin
-    .lib-url-check(@_icon-image);
-
-    //  Will return url('/images/test.png')
-    .lib-css(background, #eee @lib-url-check-output no-repeat 0 0);
-}
-
-
-.example-url-check-false {
-    //  Set usage image path to false
-    @_icon-image: false;
-
-    //  "Call" the mixin
-    .lib-url-check(@_icon-image);
-
-    //  Will return 'false' and outputs nothing
-    .lib-css(background, #eee @lib-url-check-output no-repeat 0 0);
-}

.lib-url-check() variables

-
-    
-        
-            
-            
-            
-            
-        
-        
-            
-            
-            
-            
-        
-    
Mixin variableAllowed valuesOutput variableComment
@_path'' | false | value@lib-url-check-outputPassed url to wrap in 'url( ... )'. If the 'false' value passed mixin will return 'false'
-
-
+
From d2ad2b99fc273cbc896e321b925ca9537ec8e9f6 Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Mon, 13 Aug 2018 16:19:24 +0300 Subject: [PATCH 42/51] GraphQL-127: Fixed return value for getGraphQlClient in API-functional tests -- Fix static tests --- .../Magento/TestFramework/TestCase/GraphQlAbstract.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php index 936cbfdb5106f..84ac6360643c4 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php @@ -92,9 +92,10 @@ private function getAppCache() private function getGraphQlClient() { if ($this->graphQlClient === null) { - $this->graphQlClient = Bootstrap::getObjectManager()->get(\Magento\TestFramework\TestCase\GraphQl\Client::class); + $this->graphQlClient = Bootstrap::getObjectManager()->get( + \Magento\TestFramework\TestCase\GraphQl\Client::class + ); } - return $this->graphQlClient; } } From 6bf8b330387c07b62908826228e58d7912a140db Mon Sep 17 00:00:00 2001 From: NazarKlovanych Date: Tue, 14 Aug 2018 10:42:32 +0300 Subject: [PATCH 43/51] Fix wrong class name for Unit test --- .../Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php index cd017dbcafbc2..1a9d7959dda9c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteAbandonedStoreFlatTablesTest.php @@ -13,7 +13,7 @@ /** * @covers \Magento\Catalog\Cron\DeleteAbandonedStoreFlatTables */ -class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase +class DeleteAbandonedStoreFlatTablesTest extends \PHPUnit\Framework\TestCase { /** * Testable Object From 9e1caf991e3c3aa6fd36cba56703c4a4e45f0674 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 14 Aug 2018 15:54:49 +0300 Subject: [PATCH 44/51] Minor code style fixes --- .../Magento/Catalog/Model/ProductRepository.php | 16 ++++++---------- .../Unit/Cron/DeleteOutdatedPriceValuesTest.php | 4 +++- .../base/web/js/dynamic-rows/dynamic-rows.js | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index d7fbcbcd523f8..ef2c99c5cb40e 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -514,18 +514,14 @@ protected function processMediaGallery(ProductInterface $product, $mediaGalleryE $newEntries = $mediaGalleryEntries; } - $images = $product->getMediaGallery('images'); - if ($images) { - $images = $this->determineImageRoles($product, $images); - } + $images = (array)$product->getMediaGallery('images'); + $images = $this->determineImageRoles($product, $images); $this->getMediaGalleryProcessor()->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); - if ($images) { - foreach ($images as $image) { - if (!isset($image['removed']) && !empty($image['types'])) { - $this->getMediaGalleryProcessor()->setMediaAttribute($product, $image['types'], $image['file']); - } + foreach ($images as $image) { + if (!isset($image['removed']) && !empty($image['types'])) { + $this->getMediaGalleryProcessor()->setMediaAttribute($product, $image['types'], $image['file']); } } @@ -770,7 +766,7 @@ public function cleanCache() * @param array $images * @return array */ - private function determineImageRoles(ProductInterface $product, array $images) + private function determineImageRoles(ProductInterface $product, array $images) : array { $imagesWithRoles = []; foreach ($images as $image) { diff --git a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php index 304e203f228af..c59d86aa3d5f1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Cron/DeleteOutdatedPriceValuesTest.php @@ -98,7 +98,9 @@ public function testExecute() $this->attributeMock->expects($this->once())->method('getId')->willReturn($attributeId); $this->attributeMock->expects($this->once())->method('getBackend')->willReturn($this->attributeBackendMock); $this->attributeBackendMock->expects($this->once())->method('getTable')->willReturn($table); - $this->resourceConnectionMock->expects($this->once())->method('getConnection')->willReturn($this->dbAdapterMock); + $this->resourceConnectionMock->expects($this->once()) + ->method('getConnection') + ->willReturn($this->dbAdapterMock); $this->dbAdapterMock->expects($this->exactly(2))->method('quoteInto')->willReturnMap([ ['attribute_id = ?', $attributeId, null, null, $conditions[0]], ['store_id != ?', Store::DEFAULT_STORE_ID, null, null, $conditions[1]], diff --git a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js index 870ad96732014..1d52fc78d7a85 100644 --- a/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js +++ b/app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js @@ -862,7 +862,7 @@ define([ this.update = true; if (~~this.currentPage() === this.pages()) { - lastRecordIndex = (this.startIndex + this.getChildItems().length - 1); + lastRecordIndex = this.startIndex + this.getChildItems().length - 1; lastRecord = _.findWhere(this.elems(), { index: lastRecordIndex From 9a5bfd3f38f09f94553ef79da140291943a5e57a Mon Sep 17 00:00:00 2001 From: eduard13 Date: Tue, 14 Aug 2018 16:07:33 +0300 Subject: [PATCH 45/51] Fixed typo --- app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index 9e095fb6cdec4..dfd55f5346e59 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -567,10 +567,10 @@ public function getThumbnailUrl($filePath, $checkFile = false) * Create thumbnail for image and save it to thumbnails directory * * @param string $source Image path to be resized - * @param bool $keepRation Keep aspect ratio or not + * @param bool $keepRatio Keep aspect ratio or not * @return bool|string Resized filepath or false if errors were occurred */ - public function resizeFile($source, $keepRation = true) + public function resizeFile($source, $keepRatio = true) { $realPath = $this->_directory->getRelativePath($source); if (!$this->_directory->isFile($realPath) || !$this->_directory->isExist($realPath)) { @@ -587,7 +587,7 @@ public function resizeFile($source, $keepRation = true) } $image = $this->_imageFactory->create(); $image->open($source); - $image->keepAspectRatio($keepRation); + $image->keepAspectRatio($keepRatio); $image->resize($this->_resizeParameters['width'], $this->_resizeParameters['height']); $dest = $targetDir . '/' . pathinfo($source, PATHINFO_BASENAME); $image->save($dest); From 382313475339543b5035e137e67ad0caa5eca439 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Tue, 14 Aug 2018 11:39:44 +0300 Subject: [PATCH 46/51] Covering Magento\Braintree\Model\InstantPurchase\CreditCard\TokenFormatter by UnitTest --- .../CreditCard/TokenFormatterTest.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/TokenFormatterTest.php diff --git a/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/TokenFormatterTest.php b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/TokenFormatterTest.php new file mode 100644 index 0000000000000..2a9cf2516dd2b --- /dev/null +++ b/app/code/Magento/Braintree/Test/Unit/Model/InstantPurchase/CreditCard/TokenFormatterTest.php @@ -0,0 +1,122 @@ + 'visa', + 'maskedCC' => '1111************9999', + 'expirationDate' => '01-01-2020' + ]; + + /** + * Set Up + * + * @return void + */ + protected function setUp() + { + $this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class) + ->getMockForAbstractClass(); + + $this->creditCardTokenFormatter = new CreditCardTokenFormatter(); + } + + /** + * Testing the payment format with a known credit card type + * + * @return void + */ + public function testFormatPaymentTokenWithKnownCardType() + { + $this->tokenDetails['type'] = key(CreditCardTokenFormatter::$baseCardTypes); + $this->paymentTokenMock->expects($this->once()) + ->method('getTokenDetails') + ->willReturn(json_encode($this->tokenDetails)); + + $formattedString = sprintf( + '%s: %s, %s: %s (%s: %s)', + __('Credit Card'), + reset(CreditCardTokenFormatter::$baseCardTypes), + __('ending'), + $this->tokenDetails['maskedCC'], + __('expires'), + $this->tokenDetails['expirationDate'] + ); + + self::assertEquals( + $formattedString, + $this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock) + ); + } + + /** + * Testing the payment format with a unknown credit card type + * + * @return void + */ + public function testFormatPaymentTokenWithUnknownCardType() + { + $this->paymentTokenMock->expects($this->once()) + ->method('getTokenDetails') + ->willReturn(json_encode($this->tokenDetails)); + + $formattedString = sprintf( + '%s: %s, %s: %s (%s: %s)', + __('Credit Card'), + $this->tokenDetails['type'], + __('ending'), + $this->tokenDetails['maskedCC'], + __('expires'), + $this->tokenDetails['expirationDate'] + ); + + self::assertEquals( + $formattedString, + $this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock) + ); + } + + /** + * Testing the payment format with wrong card data + * + * @return void + */ + public function testFormatPaymentTokenWithWrongData() + { + unset($this->tokenDetails['type']); + $this->paymentTokenMock->expects($this->once()) + ->method('getTokenDetails') + ->willReturn(json_encode($this->tokenDetails)); + self::expectException('\InvalidArgumentException'); + + $this->creditCardTokenFormatter->formatPaymentToken($this->paymentTokenMock); + } +} From b6df8e7c9046b0125fb3211217572dd26c7cbee7 Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Sat, 11 Aug 2018 17:18:16 +0300 Subject: [PATCH 47/51] UI Component category_form - set default sort order for General fieldset Without the default sort order this fieldset goes to the very bottom after custom fieldset is added to the form --- .../Catalog/view/adminhtml/ui_component/category_form.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index 537932a2d4daa..dafea71f872d0 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -42,7 +42,7 @@ -
+
false