Skip to content

Commit f8fd657

Browse files
authored
Merge branch '2.4-develop' into add-logic-check-imports-less-for-enabled-modules
2 parents afb812a + 725b648 commit f8fd657

File tree

1,836 files changed

+32120
-20813
lines changed

Some content is hidden

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

1,836 files changed

+32120
-20813
lines changed

app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/EnableAdminUsage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function markUserNotified(): ResultInterface
8989
public function execute()
9090
{
9191
$this->enableAdminUsage();
92-
$this->markUserNotified();
92+
return $this->markUserNotified();
9393
}
9494

9595
/**
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CloseAllDialogBoxes
2+
SelectAdminUsageSetting
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Magento\AdminAnalytics\Test\Unit\Controller\Adminhtml\Config;
10+
11+
use Magento\AdminAnalytics\Controller\Adminhtml\Config\EnableAdminUsage;
12+
use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger as NotificationLogger;
13+
use Magento\Config\Model\Config;
14+
use Magento\Config\Model\Config\Factory as ConfigFactory;
15+
use Magento\Framework\App\ProductMetadataInterface;
16+
use Magento\Framework\Controller\Result\Json as JsonResult;
17+
use Magento\Framework\Controller\ResultFactory;
18+
use Magento\Framework\Controller\ResultInterface;
19+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
20+
use PHPUnit\Framework\MockObject\MockObject;
21+
22+
/**
23+
* @covers \Magento\AdminAnalytics\Controller\Adminhtml\Config\EnableAdminUsage
24+
*/
25+
class EnableAdminUsageTest extends \PHPUnit\Framework\TestCase
26+
{
27+
private const STUB_PRODUCT_VERSION = 'Product Version';
28+
29+
/** @var EnableAdminUsage */
30+
private $controller;
31+
32+
/** @var MockObject|Config */
33+
private $configMock;
34+
35+
/** @var MockObject|ProductMetadataInterface */
36+
private $productMetadataMock;
37+
38+
/** @var MockObject|NotificationLogger */
39+
private $notificationLoggerMock;
40+
41+
/** @var MockObject|ResultFactory */
42+
private $resultFactoryMock;
43+
44+
/** @var JsonResult|MockObject */
45+
private $resultMock;
46+
47+
protected function setUp(): void
48+
{
49+
$objectManager = new ObjectManager($this);
50+
51+
$this->configMock = $this->getMockBuilder(Config::class)
52+
->disableOriginalConstructor()
53+
->onlyMethods(['setDataByPath', 'save'])
54+
->getMock();
55+
56+
$configFactory = $this->getMockBuilder(ConfigFactory::class)
57+
->disableOriginalConstructor()
58+
->onlyMethods(['create'])
59+
->getMock();
60+
61+
$configFactory->method('create')
62+
->willReturn($this->configMock);
63+
64+
$this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class)
65+
->onlyMethods(['getVersion'])
66+
->getMockForAbstractClass();
67+
68+
$this->productMetadataMock->method('getVersion')
69+
->willReturn(self::STUB_PRODUCT_VERSION);
70+
71+
$this->notificationLoggerMock = $this->getMockBuilder(NotificationLogger::class)
72+
->disableOriginalConstructor()
73+
->onlyMethods(['log'])
74+
->getMock();
75+
76+
$this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
77+
->disableOriginalConstructor()
78+
->onlyMethods(['create'])
79+
->getMock();
80+
81+
$this->resultMock = $this->getMockBuilder(JsonResult::class)
82+
->disableOriginalConstructor()
83+
->onlyMethods(['setData'])
84+
->getMock();
85+
86+
$this->resultFactoryMock->method('create')
87+
->with(ResultFactory::TYPE_JSON)
88+
->willReturn($this->resultMock);
89+
90+
$this->controller = $objectManager->getObject(EnableAdminUsage::class, [
91+
'configFactory' => $configFactory,
92+
'productMetadata' => $this->productMetadataMock,
93+
'notificationLogger' => $this->notificationLoggerMock,
94+
'resultFactory' => $this->resultFactoryMock
95+
]);
96+
}
97+
98+
/**
99+
* If Controller returns `null`, no data is passed to the browser
100+
*/
101+
public function testResponseAfterAdminUsageChange()
102+
{
103+
// Given
104+
$this->resultMock->method('setData')->willReturnSelf();
105+
106+
// When
107+
$response = $this->controller->execute();
108+
109+
// Then
110+
$this->assertInstanceOf(ResultInterface::class, $response);
111+
}
112+
113+
public function testResponseWhenExceptionThrown()
114+
{
115+
$this->markTestSkipped('magento/magento2#31393 Lack of exception handling');
116+
117+
$this->configMock->method('setDataByPath')
118+
->willThrowException(
119+
new \Exception('System Exception')
120+
);
121+
122+
// When
123+
$response = $this->controller->execute();
124+
125+
// Then
126+
$this->assertInstanceOf(ResultInterface::class, $response);
127+
}
128+
}

app/code/Magento/AdminAnalytics/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"sort-packages": true
66
},
77
"require": {
8-
"php": "~8.1.0||~8.2.0",
8+
"php": "~8.1.0||~8.2.0||~8.3.0",
99
"magento/framework": "*",
1010
"magento/module-backend": "*",
1111
"magento/module-config": "*",

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/AdminNotification/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"sort-packages": true
66
},
77
"require": {
8-
"php": "~8.1.0||~8.2.0",
8+
"php": "~8.1.0||~8.2.0||~8.3.0",
99
"lib-libxml": "*",
1010
"magento/framework": "*",
1111
"magento/module-backend": "*",

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/AdvancedPricingImportExport/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"sort-packages": true
66
},
77
"require": {
8-
"php": "~8.1.0||~8.2.0",
8+
"php": "~8.1.0||~8.2.0||~8.3.0",
99
"magento/framework": "*",
1010
"magento/module-catalog": "*",
1111
"magento/module-catalog-import-export": "*",

0 commit comments

Comments
 (0)