Skip to content

Commit a9f9be2

Browse files
Merge branch '2.4-develop' into cron-log
2 parents 2506852 + ff4439c commit a9f9be2

File tree

715 files changed

+9568
-4550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

715 files changed

+9568
-4550
lines changed

app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testShouldRenderSeverity() : void
4646
/** @var Column|MockObject $columnMock */
4747
$columnMock = $this->getMockBuilder(Column::class)
4848
->disableOriginalConstructor()
49-
->setMethods(['getIndex'])
49+
->addMethods(['getIndex'])
5050
->getMock();
5151
$columnMock->expects($this->exactly(5))->method('getIndex')->willReturn('index');
5252
$this->sut->setColumn($columnMock);

app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
use Magento\AdminNotification\Block\ToolbarEntry;
1414
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread;
15+
use Magento\Directory\Helper\Data as DirectoryHelper;
16+
use Magento\Framework\Json\Helper\Data as JsonHelper;
1517
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1618
use PHPUnit\Framework\TestCase;
1719

@@ -26,6 +28,17 @@ class ToolbarEntryTest extends TestCase
2628
protected function _getBlockInstance($unreadNotifications)
2729
{
2830
$objectManagerHelper = new ObjectManager($this);
31+
$objects = [
32+
[
33+
JsonHelper::class,
34+
$this->createMock(JsonHelper::class)
35+
],
36+
[
37+
DirectoryHelper::class,
38+
$this->createMock(DirectoryHelper::class)
39+
]
40+
];
41+
$objectManagerHelper->prepareObjectManager($objects);
2942
// mock collection of unread notifications
3043
$notificationList = $this->createPartialMock(
3144
Unread::class,
@@ -52,6 +65,18 @@ public function testGetLatestUnreadNotifications()
5265
{
5366
$helper = new ObjectManager($this);
5467

68+
$objects = [
69+
[
70+
JsonHelper::class,
71+
$this->createMock(JsonHelper::class)
72+
],
73+
[
74+
DirectoryHelper::class,
75+
$this->createMock(DirectoryHelper::class)
76+
]
77+
];
78+
$helper->prepareObjectManager($objects);
79+
5580
// 1. Create mocks
5681
$notificationList = $this->createMock(Unread::class);
5782

app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,15 @@ protected function setUp(): void
225225
'initWebsites',
226226
'initCategories'
227227
];
228+
$mockAddMethods = [
229+
'_headerColumns'
230+
];
228231
$mockMethods = array_merge($constructorMethods, [
229232
'_customHeadersMapping',
230233
'_prepareEntityCollection',
231234
'_getEntityCollection',
232235
'getWriter',
233236
'getExportData',
234-
'_headerColumns',
235237
'_customFieldsMapping',
236238
'getItemsPerPage',
237239
'paginateCollection',
@@ -243,7 +245,8 @@ protected function setUp(): void
243245
$this->advancedPricing = $this->getMockBuilder(
244246
AdvancedPricing::class
245247
)
246-
->setMethods($mockMethods)
248+
->addMethods($mockAddMethods)
249+
->onlyMethods($mockMethods)
247250
->disableOriginalConstructor()
248251
->getMock();
249252
foreach ($constructorMethods as $method) {

app/code/Magento/AdvancedSearch/Test/Unit/Model/Client/ClientResolverTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ public function testCreate(): void
6767
$clientOptionsMock = $this->getMockForAbstractClass(ClientOptionsInterface::class);
6868

6969
$this->objectManager->expects($this->exactly(2))->method('create')
70-
->withConsecutive(
71-
[$this->equalTo('engineFactoryClass')],
72-
[$this->equalTo('engineOptionClass')]
73-
)
74-
->willReturnOnConsecutiveCalls(
75-
$factoryMock,
76-
$clientOptionsMock
77-
);
70+
->willReturnCallback(function ($className) use ($factoryMock, $clientOptionsMock) {
71+
if ($className == 'engineFactoryClass') {
72+
return $factoryMock;
73+
} elseif ($className == 'engineOptionClass') {
74+
return $clientOptionsMock;
75+
}
76+
});
7877

7978
$clientOptionsMock->expects($this->once())->method('prepareClientOptions')
8079
->with([])

app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ protected function setUp(): void
5858
$this->objectManager = new ObjectManager($this);
5959
$this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class)
6060
->disableOriginalConstructor()
61-
->setMethods([])
6261
->getMock();
6362

6463
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
6564
->disableOriginalConstructor()
66-
->setMethods([])
65+
->onlyMethods([])
6766
->getMock();
6867

6968
$this->model = $this->objectManager->getObject(
@@ -171,7 +170,7 @@ public function testValidateNoOptions()
171170
/**
172171
* @return array
173172
*/
174-
public function getCreateConfigDataProvider()
173+
public static function getCreateConfigDataProvider()
175174
{
176175
return [
177176
[

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ protected function setUp(): void
4949
$this->subscriptionStatusProviderMock = $this->createMock(SubscriptionStatusProvider::class);
5050
$this->contextMock = $this->createMock(Context::class);
5151
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
52-
->setMethods(['getComment', 'getElementHtml'])
52+
->addMethods(['getComment'])
53+
->onlyMethods(['getElementHtml'])
5354
->disableOriginalConstructor()
5455
->getMock();
5556

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class VerticalTest extends TestCase
4141
protected function setUp(): void
4242
{
4343
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
44-
->setMethods(['getComment', 'getLabel', 'getHint', 'getElementHtml'])
44+
->addMethods(['getComment', 'getLabel', 'getHint'])
45+
->onlyMethods(['getElementHtml'])
4546
->disableOriginalConstructor()
4647
->getMock();
4748

app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
100100
$this->flagManagerMock
101101
->expects($this->exactly(2 * $isExecuted))
102102
->method('deleteFlag')
103-
->withConsecutive(
104-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE],
105-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE]
106-
);
103+
->willReturnCallback(fn($param) => match ([$param]) {
104+
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE] => $this->flagManagerMock,
105+
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE] => $this->flagManagerMock
106+
});
107107
$this->configWriterMock
108108
->expects($this->exactly((int)$isExecuted))
109109
->method('delete')
@@ -143,7 +143,7 @@ public function testExecuteWithEmptyReverseCounter($counterData)
143143
*
144144
* @return array
145145
*/
146-
public function executeWithEmptyReverseCounterDataProvider()
146+
public static function executeWithEmptyReverseCounterDataProvider()
147147
{
148148
return [
149149
[null],
@@ -189,7 +189,7 @@ public function testExecuteRegularScenario(
189189
/**
190190
* @return array
191191
*/
192-
public function executeRegularScenarioDataProvider()
192+
public static function executeRegularScenarioDataProvider()
193193
{
194194
return [
195195
'The last attempt with command execution result False' => [

app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,15 @@ public function testTokenAndPreviousBaseUrlExist()
126126
$this->flagManagerMock
127127
->expects($this->once())
128128
->method('saveFlag')
129-
->withConsecutive(
130-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue],
131-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url]
132-
);
129+
->willReturnCallback(function ($arg1, $arg2) use ($url) {
130+
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
131+
&& $arg2 == $this->attemptsInitValue) {
132+
return true;
133+
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
134+
return true;
135+
}
136+
});
137+
133138
$this->configWriterMock
134139
->expects($this->once())
135140
->method('save')
@@ -160,10 +165,14 @@ public function testTokenExistAndWithoutPreviousBaseUrl()
160165
$this->flagManagerMock
161166
->expects($this->exactly(2))
162167
->method('saveFlag')
163-
->withConsecutive(
164-
[SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url],
165-
[SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue]
166-
);
168+
->willReturnCallback(function ($arg1, $arg2) use ($url) {
169+
if ($arg1 == SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
170+
&& $arg2 == $this->attemptsInitValue) {
171+
return true;
172+
} elseif ($arg1 == SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE && $arg2 == $url) {
173+
return true;
174+
}
175+
});
167176
$this->configWriterMock
168177
->expects($this->once())
169178
->method('save')

app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,18 @@ public function testPrepareExportData($isArchiveSourceDirectory)
132132
$this->directoryMock
133133
->expects($this->exactly(4))
134134
->method('delete')
135-
->withConsecutive(
136-
[$tmpFilesDirectoryPath],
137-
[$archiveRelativePath]
138-
);
135+
->willReturnCallback(fn($param) => match ([$param]) {
136+
[$tmpFilesDirectoryPath] => true,
137+
[$archiveRelativePath] => true
138+
});
139139

140140
$this->directoryMock
141141
->expects($this->exactly(4))
142142
->method('getAbsolutePath')
143-
->withConsecutive(
144-
[$tmpFilesDirectoryPath],
145-
[$tmpFilesDirectoryPath],
146-
[$archiveRelativePath],
147-
[$archiveRelativePath]
148-
)
149-
->willReturnOnConsecutiveCalls(
150-
$archiveSource,
151-
$archiveSource,
152-
$archiveAbsolutePath,
153-
$archiveAbsolutePath
154-
);
143+
->willReturnCallback(fn($param) => match ([$param]) {
144+
[$tmpFilesDirectoryPath] => $archiveSource,
145+
[$archiveRelativePath] => $archiveAbsolutePath
146+
});
155147

156148
$this->reportWriterMock
157149
->expects($this->once())
@@ -161,14 +153,10 @@ public function testPrepareExportData($isArchiveSourceDirectory)
161153
$this->directoryMock
162154
->expects($this->exactly(2))
163155
->method('isExist')
164-
->withConsecutive(
165-
[$tmpFilesDirectoryPath],
166-
[$archiveRelativePath]
167-
)
168-
->willReturnOnConsecutiveCalls(
169-
true,
170-
true
171-
);
156+
->willReturnCallback(fn($param) => match ([$param]) {
157+
[$tmpFilesDirectoryPath] => true,
158+
[$archiveRelativePath] => true
159+
});
172160

173161
$this->directoryMock
174162
->expects($this->once())
@@ -208,7 +196,7 @@ public function testPrepareExportData($isArchiveSourceDirectory)
208196
/**
209197
* @return array
210198
*/
211-
public function prepareExportDataDataProvider()
199+
public static function prepareExportDataDataProvider()
212200
{
213201
return [
214202
'Data source for archive is directory' => [true],
@@ -237,11 +225,10 @@ public function testPrepareExportDataWithLocalizedException()
237225
$this->directoryMock
238226
->expects($this->exactly(3))
239227
->method('delete')
240-
->withConsecutive(
241-
[$tmpFilesDirectoryPath],
242-
[$tmpFilesDirectoryPath],
243-
[$archivePath]
244-
);
228+
->willReturnCallback(fn($param) => match ([$param]) {
229+
[$tmpFilesDirectoryPath] => true,
230+
[$archivePath] => true
231+
});
245232
$this->directoryMock
246233
->expects($this->exactly(2))
247234
->method('getAbsolutePath')

app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ protected function setUp(): void
4747
$this->subscriptionUpdateHandlerMock = $this->createMock(SubscriptionUpdateHandler::class);
4848
$this->configValueMock = $this->getMockBuilder(Value::class)
4949
->disableOriginalConstructor()
50-
->setMethods(['isValueChanged', 'getPath', 'getScope', 'getOldValue'])
50+
->addMethods(['getPath', 'getScope'])
51+
->onlyMethods(['isValueChanged', 'getOldValue'])
5152
->getMock();
5253
$this->objectManagerHelper = new ObjectManagerHelper($this);
5354
$this->plugin = $this->objectManagerHelper->getObject(
@@ -88,7 +89,7 @@ public function testAfterSavePluginIsNotApplicable(
8889
/**
8990
* @return array
9091
*/
91-
public function afterSavePluginIsNotApplicableDataProvider()
92+
public static function afterSavePluginIsNotApplicableDataProvider()
9293
{
9394
return [
9495
'Value has not been changed' => [

0 commit comments

Comments
 (0)