Skip to content

Commit 12ba63d

Browse files
committed
Merge branch 'platform-health' of github.com:magento/magento2 into platform-health
2 parents c27ed28 + 98249a1 commit 12ba63d

File tree

6 files changed

+138
-222
lines changed

6 files changed

+138
-222
lines changed

app/code/Magento/Theme/view/base/requirejs-config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ var config = {
3434
'domReady': 'requirejs/domReady',
3535
'spectrum': 'jquery/spectrum/spectrum',
3636
'tinycolor': 'jquery/spectrum/tinycolor',
37-
'jquery-ui-modules': 'jquery/ui-modules'
37+
'jquery-ui-modules': 'jquery/ui-modules',
38+
'matchMedia': 'mediaCheck'
3839
},
3940
deps: [
4041
'jquery/jquery-migrate'

app/design/adminhtml/Magento/backend/etc/view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<item type="file">Lib::jquery/jquery.min.js</item>
5151
<item type="file">Lib::jquery/jquery.parsequery.js</item>
5252
<item type="file">Lib::jquery/jquery-ui.js</item>
53-
<item type="file">Lib::matchMedia.js</item>
53+
<item type="file">Lib::mediaCheck.js</item>
5454
<item type="file">Lib::requirejs/require.js</item>
5555
<item type="file">Lib::requirejs/text.js</item>
5656
<item type="file">Lib::varien/js.js</item>

dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Quote/Item/QuantityValidatorTest.php

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogInventory\Model\Quote\Item;
79

810
use Magento\Catalog\Model\Product;
@@ -14,64 +16,68 @@
1416
use Magento\Eav\Model\Config;
1517
use Magento\Framework\Exception\CouldNotSaveException;
1618
use Magento\Framework\Exception\LocalizedException;
19+
use Magento\Framework\ObjectManagerInterface;
1720
use Magento\Quote\Api\Data\CartInterface;
1821
use Magento\Quote\Model\Quote;
22+
use Magento\Quote\Model\Quote\Item;
1923
use Magento\TestFramework\Helper\Bootstrap;
2024
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option;
2125
use Magento\Framework\Event\Observer;
2226
use Magento\Framework\Event;
2327
use Magento\Catalog\Api\ProductRepositoryInterface;
2428
use Magento\Framework\DataObject;
2529
use Magento\Checkout\Model\Session;
30+
use PHPUnit\Framework\MockObject\MockObject;
31+
use PHPUnit\Framework\TestCase;
2632

2733
/**
2834
* Class QuantityValidatorTest
2935
*
3036
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3137
*/
32-
class QuantityValidatorTest extends \PHPUnit\Framework\TestCase
38+
class QuantityValidatorTest extends TestCase
3339
{
3440
/**
3541
* @var QuantityValidator
3642
*/
3743
private $quantityValidator;
3844

3945
/**
40-
* @var \PHPUnit\Framework\MockObject\MockObject
46+
* @var MockObject
4147
*/
4248
private $observerMock;
4349

4450
/**
45-
* @var \PHPUnit\Framework\MockObject\MockObject
51+
* @var MockObject
4652
*/
4753
private $eventMock;
4854

4955
/**
50-
* @var \Magento\Framework\ObjectManagerInterface
56+
* @var ObjectManagerInterface
5157
*/
5258
private $objectManager;
5359

5460
/**
55-
* @var \PHPUnit\Framework\MockObject\MockObject
61+
* @var MockObject
5662
*/
5763
private $optionInitializer;
5864

5965
/**
60-
* @var \PHPUnit\Framework\MockObject\MockObject
66+
* @var MockObject
6167
*/
6268
private $stockState;
6369

6470
/**
65-
* @var \Magento\CatalogInventory\Observer\QuantityValidatorObserver
71+
* @var QuantityValidatorObserver
6672
*/
6773
private $observer;
6874

6975
/**
70-
* Set up
76+
* @inheritdoc
7177
*/
7278
protected function setUp(): void
7379
{
74-
/** @var \Magento\Framework\ObjectManagerInterface objectManager */
80+
/** @var ObjectManagerInterface objectManager */
7581
$this->objectManager = Bootstrap::getObjectManager();
7682
$this->observerMock = $this->createMock(Observer::class);
7783
$this->optionInitializer = $this->createMock(Option::class);
@@ -89,27 +95,36 @@ protected function setUp(): void
8995
'quantityValidator' => $this->quantityValidator
9096
]
9197
);
92-
$this->eventMock = $this->createPartialMock(Event::class, ['getItem']);
98+
99+
$this->eventMock = $this->getMockBuilder(Event::class)
100+
->disableOriginalConstructor()
101+
->disableOriginalClone()
102+
->disableArgumentCloning()
103+
->disallowMockingUnknownTypes()
104+
->addMethods(['getItem'])
105+
->getMock();
93106
}
94107

95108
/**
96109
* @magentoDataFixture Magento/Checkout/_files/quote_with_bundle_product.php
97110
* @magentoDbIsolation disabled
98111
* @magentoAppIsolation enabled
112+
*
113+
* @return void
99114
*/
100-
public function testQuoteWithOptions()
115+
public function testQuoteWithOptions(): void
101116
{
102-
/** @var $session \Magento\Checkout\Model\Session */
117+
/** @var $session Session */
103118
$session = $this->objectManager->create(Session::class);
104119

105-
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
120+
/** @var ProductRepositoryInterface $productRepository */
106121
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
107122
/** @var $product Product */
108123
$product = $productRepository->get('bundle-product');
109124
$resultMock = $this->createMock(DataObject::class);
110125
$this->stockState->expects($this->any())->method('checkQtyIncrements')->willReturn($resultMock);
111-
/* @var $quoteItem \Magento\Quote\Model\Quote\Item */
112-
$quoteItem = $this->_getQuoteItemIdByProductId($session->getQuote(), $product->getId());
126+
/* @var $quoteItem Item */
127+
$quoteItem = $this->getQuoteItemIdByProductId($session->getQuote(), $product->getId());
113128
$this->observerMock->expects($this->once())->method('getEvent')->willReturn($this->eventMock);
114129
$this->optionInitializer->expects($this->any())->method('initialize')->willReturn($resultMock);
115130
$this->eventMock->expects($this->once())->method('getItem')->willReturn($quoteItem);
@@ -121,21 +136,26 @@ public function testQuoteWithOptions()
121136
* @magentoDataFixture Magento/Checkout/_files/quote_with_bundle_product.php
122137
* @magentoDbIsolation disabled
123138
* @magentoAppIsolation enabled
139+
*
140+
* @return void
124141
*/
125-
public function testQuoteWithOptionsWithErrors()
142+
public function testQuoteWithOptionsWithErrors(): void
126143
{
127-
/** @var $session \Magento\Checkout\Model\Session */
144+
/** @var $session Session */
128145
$session = $this->objectManager->create(Session::class);
129-
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
146+
/** @var ProductRepositoryInterface $productRepository */
130147
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
131148
/** @var $product Product */
132149
$product = $productRepository->get('bundle-product');
133-
/* @var $quoteItem \Magento\Quote\Model\Quote\Item */
134-
$quoteItem = $this->_getQuoteItemIdByProductId($session->getQuote(), $product->getId());
135-
$resultMock = $this->createPartialMock(
136-
DataObject::class,
137-
['checkQtyIncrements', 'getMessage', 'getQuoteMessage', 'getHasError']
138-
);
150+
/* @var $quoteItem Item */
151+
$quoteItem = $this->getQuoteItemIdByProductId($session->getQuote(), $product->getId());
152+
$resultMock = $this->getMockBuilder(DataObject::class)
153+
->disableOriginalConstructor()
154+
->disableOriginalClone()
155+
->disableArgumentCloning()
156+
->disallowMockingUnknownTypes()
157+
->addMethods(['checkQtyIncrements', 'getMessage', 'getQuoteMessage', 'getHasError'])
158+
->getMock();
139159
$this->observerMock->expects($this->once())->method('getEvent')->willReturn($this->eventMock);
140160
$this->eventMock->expects($this->once())->method('getItem')->willReturn($quoteItem);
141161
$this->stockState->expects($this->any())->method('checkQtyIncrements')->willReturn($resultMock);
@@ -150,10 +170,12 @@ public function testQuoteWithOptionsWithErrors()
150170
* Set mock of Stock State Result to Quote Item Options.
151171
*
152172
*
153-
* @param \Magento\Quote\Model\Quote\Item $quoteItem
154-
* @param \PHPUnit\Framework\MockObject\MockObject $resultMock
173+
* @param Item $quoteItem
174+
* @param MockObject $resultMock
175+
*
176+
* @return void
155177
*/
156-
private function setMockStockStateResultToQuoteItemOptions($quoteItem, $resultMock)
178+
private function setMockStockStateResultToQuoteItemOptions($quoteItem, $resultMock): void
157179
{
158180
if ($options = $quoteItem->getQtyOptions()) {
159181
foreach ($options as $option) {
@@ -252,27 +274,29 @@ public function quantityDataProvider(): array
252274
[
253275
'quantity' => 1000,
254276
'error_regexp' => ''
255-
],
256-
277+
]
257278
];
258279
}
259280

260281
/**
261-
* Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
282+
* Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id.
262283
*
263284
* @param Quote $quote
264285
* @param int $productId
265-
* @return \Magento\Quote\Model\Quote\Item
286+
*
287+
* @return Item
266288
*/
267-
private function _getQuoteItemIdByProductId($quote, $productId)
289+
private function getQuoteItemIdByProductId($quote, $productId): Item
268290
{
269-
/** @var $quoteItems \Magento\Quote\Model\Quote\Item[] */
291+
/** @var $quoteItems Item[] */
270292
$quoteItems = $quote->getAllItems();
293+
271294
foreach ($quoteItems as $quoteItem) {
272295
if ($productId == $quoteItem->getProductId()) {
273296
return $quoteItem;
274297
}
275298
}
276-
$this->fail('Test failed since no quoteItem found by productId '.$productId);
299+
300+
$this->fail('Test failed since no quoteItem found by productId ' . $productId);
277301
}
278302
}

dev/tests/integration/testsuite/Magento/Paypal/Controller/Billing/AgreementTest.php

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Paypal\Controller\Billing;
89

10+
use Magento\Customer\Model\Session;
11+
use Magento\Framework\App\Action\Context;
12+
use Magento\Framework\App\RequestInterface;
13+
use Magento\Framework\ObjectManagerInterface;
14+
use Magento\Payment\Helper\Data;
15+
use Magento\Paypal\Controller\Billing\Agreement\ReturnWizard;
16+
use Magento\Paypal\Model\Express;
17+
use Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection;
18+
use Magento\Store\Model\StoreManager;
19+
use Magento\TestFramework\Helper\Bootstrap;
20+
use Magento\TestFramework\TestCase\AbstractController;
21+
922
/**
1023
* Test class for \Magento\Paypal\Controller\Billing\Agreement
1124
*/
12-
class AgreementTest extends \Magento\TestFramework\TestCase\AbstractController
25+
class AgreementTest extends AbstractController
1326
{
1427
/**
1528
* Test billing agreement record creation in Magento DB.
@@ -20,44 +33,46 @@ class AgreementTest extends \Magento\TestFramework\TestCase\AbstractController
2033
* @magentoDataFixture Magento/Customer/_files/customer.php
2134
* @magentoDbIsolation enabled
2235
* @magentoAppArea frontend
36+
*
37+
* @return void
2338
*/
24-
public function testReturnWizardAction()
39+
public function testReturnWizardAction(): void
2540
{
2641
$paymentMethod = "paypal_express";
2742
$token = "token_value";
2843
$referenceId = "Reference-id-1";
2944

30-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
45+
$objectManager = Bootstrap::getObjectManager();
3146

3247
/** Mock Request */
33-
$requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false);
34-
$requestMock
35-
->expects($this->any())
48+
$requestMock = $this->getMockForAbstractClass(RequestInterface::class, [], '', false);
49+
$requestMock->expects($this->any())
3650
->method('getParam')
3751
->willReturnMap(
38-
39-
[
40-
['payment_method', null, $paymentMethod],
41-
['token', null, $token],
42-
]
43-
52+
[
53+
['payment_method', null, $paymentMethod],
54+
['token', null, $token]
55+
]
4456
);
4557

4658
/**
4759
* Disable billing agreement placement using calls to remote system
4860
* in \Magento\Paypal\Model\Billing\Agreement::place()
4961
*/
50-
$objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
51-
$paymentMethodMock = $this->createPartialMock(
52-
\Magento\Paypal\Model\Express::class,
53-
['getTitle', 'setStore', 'placeBillingAgreement']
54-
);
62+
$objectManagerMock = $this->createMock(ObjectManagerInterface::class);
63+
$paymentMethodMock = $this->getMockBuilder(Express::class)
64+
->disableOriginalConstructor()
65+
->disableOriginalClone()
66+
->disableArgumentCloning()
67+
->disallowMockingUnknownTypes()
68+
->onlyMethods(['getTitle', 'setStore'])
69+
->addMethods(['placeBillingAgreement'])
70+
->getMock();
5571
$paymentMethodMock->expects($this->any())->method('placeBillingAgreement')->willReturnSelf();
5672
$paymentMethodMock->expects($this->any())->method('getTitle')->willReturn($paymentMethod);
5773

58-
$paymentHelperMock = $this->createPartialMock(\Magento\Payment\Helper\Data::class, ['getMethodInstance']);
59-
$paymentHelperMock
60-
->expects($this->any())
74+
$paymentHelperMock = $this->createPartialMock(Data::class, ['getMethodInstance']);
75+
$paymentHelperMock->expects($this->any())
6176
->method('getMethodInstance')
6277
->willReturn($paymentMethodMock);
6378
$billingAgreement = $objectManager->create(
@@ -66,50 +81,46 @@ public function testReturnWizardAction()
6681
);
6782
/** Reference ID is normally set by placeBillingAgreement() and is an agreement ID in the external system. */
6883
$billingAgreement->setBillingAgreementId($referenceId);
69-
$objectManagerMock
70-
->expects($this->once())
84+
$objectManagerMock->expects($this->once())
7185
->method('create')
7286
->with(\Magento\Paypal\Model\Billing\Agreement::class, [])
7387
->willReturn($billingAgreement);
74-
$storeManager = $objectManager->get(\Magento\Store\Model\StoreManager::class);
75-
$customerSession = $objectManager->get(\Magento\Customer\Model\Session::class);
76-
$objectManagerMock
77-
->expects($this->any())
88+
$storeManager = $objectManager->get(StoreManager::class);
89+
$customerSession = $objectManager->get(Session::class);
90+
$objectManagerMock->expects($this->any())
7891
->method('get')
7992
->willReturnMap(
80-
81-
[
82-
[\Magento\Store\Model\StoreManager::class, $storeManager],
83-
[\Magento\Customer\Model\Session::class, $customerSession],
84-
]
85-
93+
[
94+
[StoreManager::class, $storeManager],
95+
[Session::class, $customerSession],
96+
]
8697
);
8798
$contextMock = $objectManager->create(
88-
\Magento\Framework\App\Action\Context::class,
99+
Context::class,
89100
[
90101
'objectManager' => $objectManagerMock,
91102
'request' => $requestMock
92103
]
93104
);
94105
/** @var \Magento\Paypal\Controller\Billing\Agreement $billingAgreementController */
95106
$billingAgreementController = $objectManager->create(
96-
\Magento\Paypal\Controller\Billing\Agreement\ReturnWizard::class,
107+
ReturnWizard::class,
97108
['context' => $contextMock]
98109
);
99110

100111
/** Initialize current customer */
101-
/** @var \Magento\Customer\Model\Session $customerSession */
102-
$customerSession = $objectManager->get(\Magento\Customer\Model\Session::class);
112+
/** @var Session $customerSession */
113+
$customerSession = $objectManager->get(Session::class);
103114
$fixtureCustomerId = 1;
104115
$customerSession->setCustomerId($fixtureCustomerId);
105116

106117
/** Execute SUT */
107118
$billingAgreementController->execute();
108119

109120
/** Ensure that billing agreement record was created in the DB */
110-
/** @var \Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection $billingAgreementCollection */
121+
/** @var Collection $billingAgreementCollection */
111122
$billingAgreementCollection = $objectManager->create(
112-
\Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection::class
123+
Collection::class
113124
);
114125
/** @var \Magento\Paypal\Model\Billing\Agreement $createdBillingAgreement */
115126
$createdBillingAgreement = $billingAgreementCollection->getLastItem();

0 commit comments

Comments
 (0)