Skip to content

Commit 6253c1d

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop-expedited-prs
- merged with '2.4-develop-prs' branch
2 parents 00f078c + 06f406e commit 6253c1d

File tree

13 files changed

+191
-45
lines changed

13 files changed

+191
-45
lines changed

app/code/Magento/Captcha/Test/Unit/Model/Customer/Plugin/AjaxLoginTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class AjaxLoginTest extends TestCase
6363
/**
6464
* @var array
6565
*/
66-
protected $formIds;
66+
protected $formIds = ['user_login'];
6767

6868
/**
6969
* @var AjaxLogin
@@ -97,7 +97,6 @@ protected function setUp(): void
9797
->method('getCaptcha')
9898
->willReturn($this->captchaMock);
9999

100-
$this->formIds = ['user_login'];
101100
$this->serializerMock = $this->createMock(Json::class);
102101

103102
$this->model = new AjaxLogin(
@@ -194,7 +193,10 @@ public function testAroundExecuteCaptchaIsNotRequired($username, $requestContent
194193

195194
$this->captchaMock->expects($this->once())->method('isRequired')->with($username)
196195
->willReturn(false);
197-
$this->captchaMock->expects($this->never())->method('logAttempt')->with($username);
196+
$expectLogAttempt = $requestContent['captcha_form_id'] ?? false;
197+
$this->captchaMock
198+
->expects($expectLogAttempt ? $this->once() : $this->never())
199+
->method('logAttempt')->with($username);
198200
$this->captchaMock->expects($this->never())->method('isCorrect');
199201

200202
$closure = function () {

app/code/Magento/Customer/etc/webapi_rest/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<arguments>
1414
<argument name="userContexts" xsi:type="array">
1515
<item name="customerSessionUserContext" xsi:type="array">
16-
<item name="type" xsi:type="object">Magento\Customer\Model\Authorization\CustomerSessionUserContext</item>
16+
<item name="type" xsi:type="object">Magento\Customer\Model\Authorization\CustomerSessionUserContext\Proxy</item>
1717
<item name="sortOrder" xsi:type="string">20</item>
1818
</item>
1919
</argument>

app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testExecuteVsCodeFormat()
9797
->with(
9898
$this->equalTo(['urn:magento:framework:Module/etc/module.xsd' => $fixtureXmlFile]),
9999
$this->equalTo('test')
100-
)->willReturn(null);
100+
);
101101

102102
$formats = ['vscode' => $vscodeFormatMock];
103103
$readFactory = $this->createMock(ReadFactory::class);

app/code/Magento/PageCache/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
<argument name="layoutCacheKey" xsi:type="object">Magento\Framework\View\Layout\LayoutCacheKeyInterface</argument>
3838
</arguments>
3939
</type>
40-
<type name="Magento\Framework\App\FrontControllerInterface">
41-
<plugin name="page_cache_from_key_from_cookie" type="Magento\PageCache\Plugin\RegisterFormKeyFromCookie" />
42-
</type>
4340
<type name="Magento\Framework\App\Cache\RuntimeStaleCacheStateModifier">
4441
<arguments>
4542
<argument name="cacheTypes" xsi:type="array">

app/code/Magento/PageCache/etc/frontend/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<type name="Magento\Framework\App\FrontControllerInterface">
1010
<plugin name="front-controller-builtin-cache" type="Magento\PageCache\Model\App\FrontController\BuiltinPlugin"/>
1111
<plugin name="front-controller-varnish-cache" type="Magento\PageCache\Model\App\FrontController\VarnishPlugin"/>
12+
<plugin name="page_cache_form_key_from_cookie" type="Magento\PageCache\Plugin\RegisterFormKeyFromCookie" />
1213
</type>
1314
<type name="Magento\Framework\Controller\ResultInterface">
1415
<plugin name="result-builtin-cache" type="Magento\PageCache\Model\Controller\Result\BuiltinPlugin"/>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\Framework\App\FrontControllerInterface">
10+
<plugin name="page_cache_form_key_from_cookie" type="Magento\PageCache\Plugin\RegisterFormKeyFromCookie" />
11+
</type>
12+
</config>

app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,9 @@ public function testSetGuest()
228228
->method('removePersistentCookie')->willReturn($this->sessionMock);
229229
$this->quoteMock->expects($this->once())->method('isVirtual')->willReturn(false);
230230
$this->quoteMock->expects($this->once())->method('getItemsQty')->willReturn(1);
231-
$extensionAttributes = $this->createPartialMock(
232-
CartExtensionInterface::class,
233-
[
234-
'setShippingAssignments',
235-
'getShippingAssignments'
236-
]
237-
);
231+
$extensionAttributes = $this->getMockBuilder(CartExtensionInterface::class)
232+
->addMethods(['getShippingAssignments', 'setShippingAssignments'])
233+
->getMockForAbstractClass();
238234
$shippingAssignment = $this->createMock(ShippingAssignmentInterface::class);
239235
$extensionAttributes->expects($this->once())
240236
->method('setShippingAssignments')

app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/SubtotalTest.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function setUp(): void
5959

6060
$this->stockRegistry = $this->createPartialMock(
6161
StockRegistry::class,
62-
['getStockItem', '__wakeup']
62+
['getStockItem']
6363
);
6464
$this->stockItemMock = $this->createPartialMock(
6565
\Magento\CatalogInventory\Model\Stock\Item::class,
@@ -110,10 +110,11 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri
110110
]
111111
);
112112
/** @var Address|MockObject $address */
113-
$address = $this->createPartialMock(
114-
Address::class,
115-
['setTotalQty', 'getTotalQty', 'removeItem', 'getQuote']
116-
);
113+
$address = $this->getMockBuilder(Address::class)
114+
->disableOriginalConstructor()
115+
->onlyMethods(['removeItem', 'getQuote'])
116+
->addMethods(['setTotalQty', 'getTotalQty'])
117+
->getMock();
117118

118119
/** @var Product|MockObject $product */
119120
$product = $this->createMock(Product::class);
@@ -161,10 +162,10 @@ public function testCollect($price, $originalPrice, $itemHasParent, $expectedPri
161162
$shippingAssignmentMock->expects($this->exactly(2))->method('getShipping')->willReturn($shipping);
162163
$shippingAssignmentMock->expects($this->once())->method('getItems')->willReturn([$quoteItem]);
163164

164-
$total = $this->createPartialMock(
165-
Total::class,
166-
['setBaseVirtualAmount', 'setVirtualAmount']
167-
);
165+
$total = $this->getMockBuilder(Total::class)
166+
->disableOriginalConstructor()
167+
->addMethods(['setVirtualAmount', 'setBaseVirtualAmount'])
168+
->getMock();
168169
$total->expects($this->once())->method('setBaseVirtualAmount')->willReturnSelf();
169170
$total->expects($this->once())->method('setVirtualAmount')->willReturnSelf();
170171

@@ -185,7 +186,9 @@ public function testFetch()
185186
];
186187

187188
$quoteMock = $this->createMock(Quote::class);
188-
$totalMock = $this->createPartialMock(Total::class, ['getSubtotal']);
189+
$totalMock = $this->getMockBuilder(Total::class)
190+
->addMethods(['getSubtotal'])
191+
->getMockForAbstractClass();
189192
$totalMock->expects($this->once())->method('getSubtotal')->willReturn(100);
190193

191194
$this->assertEquals($expectedResult, $this->subtotalModel->fetch($quoteMock, $totalMock));
@@ -229,13 +232,11 @@ public function testCollectWithInvalidItems()
229232
$address->expects($this->once())
230233
->method('removeItem')
231234
->with($addressItemId);
232-
$addressItem = $this->createPartialMock(
233-
AddressItem::class,
234-
[
235-
'getId',
236-
'getQuoteItemId'
237-
]
238-
);
235+
$addressItem = $this->getMockBuilder(AddressItem::class)
236+
->disableOriginalConstructor()
237+
->onlyMethods(['getId'])
238+
->addMethods(['getQuoteItemId'])
239+
->getMock();
239240
$addressItem->setAddress($address);
240241
$addressItem->method('getId')
241242
->willReturn($addressItemId);

app/code/Magento/Sales/Test/Unit/Model/Order/CreditmemoFactoryTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ class CreditmemoFactoryTest extends TestCase
4949
*/
5050
protected function setUp(): void
5151
{
52-
$this->orderItemMock = $this->createPartialMock(
53-
Item::class,
54-
['getChildrenItems', 'isDummy', 'getHasChildren', 'getId', 'getParentItemId']
55-
);
52+
$this->orderItemMock = $this->getMockBuilder(Item::class)
53+
->disableOriginalConstructor()
54+
->onlyMethods(['getChildrenItems', 'isDummy', 'getId', 'getParentItemId'])
55+
->addMethods(['getHasChildren'])
56+
->getMock();
5657
$this->orderChildItemOneMock = $this->createPartialMock(
5758
Item::class,
5859
['getQtyToRefund', 'getId']

app/code/Magento/User/etc/webapi_rest/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<arguments>
1111
<argument name="userContexts" xsi:type="array">
1212
<item name="adminSessionUserContext" xsi:type="array">
13-
<item name="type" xsi:type="object">Magento\User\Model\Authorization\AdminSessionUserContext</item>
13+
<item name="type" xsi:type="object">Magento\User\Model\Authorization\AdminSessionUserContext\Proxy</item>
1414
<item name="sortOrder" xsi:type="string">30</item>
1515
</item>
1616
</argument>

0 commit comments

Comments
 (0)