Skip to content

Commit 5e18d92

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into MC-33066
2 parents 304addb + d69c242 commit 5e18d92

File tree

1,020 files changed

+5354
-4180
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,020 files changed

+5354
-4180
lines changed

app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
</annotations>
2222

2323
<!-- Logging in Magento admin -->
24-
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
2525
</test>
2626
</tests>

app/code/Magento/AdminNotification/Test/Mftf/Test/AdminSystemNotificationNavigateMenuTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<group value="mtf_migrated"/>
2121
</annotations>
2222
<before>
23-
<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
2424
</before>
2525
<after>
2626
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\Framework\Escaper;
1919
use Magento\Framework\Url\Helper\Data;
2020
use Magento\Framework\UrlInterface;
21+
use PHPUnit\Framework\MockObject\MockObject;
2122
use PHPUnit\Framework\TestCase;
2223

2324
class ActionsTest extends TestCase
@@ -32,20 +33,20 @@ protected function setUp() : void
3233
{
3334
parent::setUp();
3435

35-
/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
36+
/** @var Escaper|MockObject $escaperMock */
3637
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
3738
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');
3839

39-
/** @var UrlInterface | \PHPUnit_Framework_MockObject_MockObject $urlBuilder */
40+
/** @var UrlInterface|MockObject $urlBuilder */
4041
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
4142
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
4243

43-
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
44+
/** @var Context|MockObject $contextMock */
4445
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
4546
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
4647
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);
4748

48-
/** @var Data | \PHPUnit_Framework_MockObject_MockObject $urlHelperMock */
49+
/** @var Data|MockObject $urlHelperMock */
4950
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
5051
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');
5152

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\DataObject;
1616
use Magento\Framework\Escaper;
1717
use Magento\Backend\Block\Context;
18+
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class NoticeTest extends TestCase
@@ -30,11 +31,11 @@ protected function setUp() : void
3031
{
3132
parent::setUp();
3233

33-
/** @var Escaper | \PHPUnit_Framework_MockObject_MockObject $escaperMock */
34+
/** @var Escaper|MockObject $escaperMock */
3435
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
3536
$escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('<div>Some random html</div>');
3637

37-
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
38+
/** @var Context|MockObject $contextMock */
3839
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
3940
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
4041

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Backend\Block\Widget\Grid\Column;
1818
use Magento\Framework\DataObject;
1919
use Magento\Framework\Escaper;
20+
use PHPUnit\Framework\MockObject\MockObject;
2021
use PHPUnit\Framework\TestCase;
2122

2223
class SeverityTest extends TestCase
@@ -32,18 +33,18 @@ protected function setUp() : void
3233
{
3334
parent::setUp();
3435

35-
/** @var Inbox |\PHPUnit_Framework_MockObject_MockObject $inboxMock */
36+
/** @var Inbox|MockObject $inboxMock */
3637
$inboxMock = $this->getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock();
3738

38-
/** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
39+
/** @var Context|MockObject $contextMock */
3940
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
4041

4142
$this->sut = new Severity($contextMock, $inboxMock);
4243
}
4344

4445
public function testShouldRenderSeverity() : void
4546
{
46-
/** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
47+
/** @var Column|MockObject $columnMock */
4748
$columnMock = $this->getMockBuilder(Column::class)
4849
->disableOriginalConstructor()
4950
->setMethods(['getIndex'])

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99
*/
1010
namespace Magento\AdminNotification\Test\Unit\Block;
1111

12-
class ToolbarEntryTest extends \PHPUnit\Framework\TestCase
12+
use Magento\AdminNotification\Block\ToolbarEntry;
13+
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class ToolbarEntryTest extends TestCase
1318
{
1419
/**
1520
* Retrieve toolbar entry block instance
1621
*
1722
* @param int $unreadNotifications number of unread notifications
18-
* @return \Magento\AdminNotification\Block\ToolbarEntry
23+
* @return ToolbarEntry
1924
*/
2025
protected function _getBlockInstance($unreadNotifications)
2126
{
22-
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
27+
$objectManagerHelper = new ObjectManager($this);
2328
// mock collection of unread notifications
2429
$notificationList = $this->createPartialMock(
25-
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class,
30+
Unread::class,
2631
['getSize', 'setCurPage', 'setPageSize']
2732
);
2833
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));
2934

3035
$block = $objectManagerHelper->getObject(
31-
\Magento\AdminNotification\Block\ToolbarEntry::class,
36+
ToolbarEntry::class,
3237
['notificationList' => $notificationList]
3338
);
3439

@@ -44,25 +49,23 @@ public function testGetUnreadNotificationCount()
4449

4550
public function testGetLatestUnreadNotifications()
4651
{
47-
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
52+
$helper = new ObjectManager($this);
4853

4954
// 1. Create mocks
50-
$notificationList = $this->getMockBuilder(
51-
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class
52-
)
55+
$notificationList = $this->getMockBuilder(Unread::class)
5356
->disableOriginalConstructor()
5457
->getMock();
5558

56-
/** @var \Magento\AdminNotification\Block\ToolbarEntry $model */
59+
/** @var ToolbarEntry $model */
5760
$model = $helper->getObject(
58-
\Magento\AdminNotification\Block\ToolbarEntry::class,
61+
ToolbarEntry::class,
5962
['notificationList' => $notificationList]
6063
);
6164

6265
// 2. Set expectations
6366
$notificationList->expects($this->atLeastOnce())
6467
->method('setPageSize')
65-
->with(\Magento\AdminNotification\Block\ToolbarEntry::NOTIFICATIONS_NUMBER)
68+
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)
6669
->will($this->returnSelf());
6770

6871
// 3. Run tested method

app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,87 @@
66

77
namespace Magento\AdminNotification\Test\Unit\Model;
88

9+
use Magento\AdminNotification\Model\Feed;
10+
use Magento\AdminNotification\Model\Inbox;
11+
use Magento\AdminNotification\Model\InboxFactory;
12+
use Magento\Backend\App\ConfigInterface;
13+
use Magento\Framework\App\CacheInterface;
14+
use Magento\Framework\App\DeploymentConfig;
15+
use Magento\Framework\App\ProductMetadata;
16+
use Magento\Framework\App\State;
917
use Magento\Framework\Config\ConfigOptionsListConstants;
18+
use Magento\Framework\HTTP\Adapter\Curl;
19+
use Magento\Framework\HTTP\Adapter\CurlFactory;
1020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
21+
use Magento\Framework\UrlInterface;
22+
use PHPUnit\Framework\MockObject\MockObject;
23+
use PHPUnit\Framework\TestCase;
1124

1225
/**
1326
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1427
*/
15-
class FeedTest extends \PHPUnit\Framework\TestCase
28+
class FeedTest extends TestCase
1629
{
17-
/** @var \Magento\AdminNotification\Model\Feed */
30+
/** @var Feed */
1831
protected $feed;
1932

2033
/** @var ObjectManagerHelper */
2134
protected $objectManagerHelper;
2235

23-
/** @var \Magento\AdminNotification\Model\InboxFactory|\PHPUnit_Framework_MockObject_MockObject */
36+
/** @var InboxFactory|MockObject */
2437
protected $inboxFactory;
2538

26-
/** @var \Magento\AdminNotification\Model\Inbox|\PHPUnit_Framework_MockObject_MockObject */
39+
/** @var Inbox|MockObject */
2740
protected $inboxModel;
2841

29-
/** @var \Magento\Framework\HTTP\Adapter\CurlFactory|\PHPUnit_Framework_MockObject_MockObject */
42+
/** @var CurlFactory|MockObject */
3043
protected $curlFactory;
3144

32-
/** @var \Magento\Framework\HTTP\Adapter\Curl|\PHPUnit_Framework_MockObject_MockObject */
45+
/** @var Curl|MockObject */
3346
protected $curl;
3447

35-
/** @var \Magento\Backend\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
48+
/** @var ConfigInterface|MockObject */
3649
protected $backendConfig;
3750

38-
/** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */
51+
/** @var CacheInterface|MockObject */
3952
protected $cacheManager;
4053

41-
/** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */
54+
/** @var State|MockObject */
4255
protected $appState;
4356

44-
/** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
57+
/** @var DeploymentConfig|MockObject */
4558
protected $deploymentConfig;
4659

47-
/** @var \Magento\Framework\App\ProductMetadata|\PHPUnit_Framework_MockObject_MockObject */
60+
/** @var ProductMetadata|MockObject */
4861
protected $productMetadata;
4962

50-
/** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
63+
/** @var UrlInterface|MockObject */
5164
protected $urlBuilder;
5265

53-
protected function setUp()
66+
protected function setUp(): void
5467
{
5568
$this->inboxFactory = $this->createPartialMock(
56-
\Magento\AdminNotification\Model\InboxFactory::class,
69+
InboxFactory::class,
5770
['create']
5871
);
59-
$this->curlFactory = $this->createPartialMock(\Magento\Framework\HTTP\Adapter\CurlFactory::class, ['create']);
60-
$this->curl = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\Curl::class)
72+
$this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
73+
$this->curl = $this->getMockBuilder(Curl::class)
6174
->disableOriginalConstructor()->getMock();
62-
$this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getInstallDate']);
63-
$this->inboxModel = $this->createPartialMock(\Magento\AdminNotification\Model\Inbox::class, [
75+
$this->appState = $this->createPartialMock(State::class, []);
76+
$this->inboxModel = $this->createPartialMock(Inbox::class, [
6477
'__wakeup',
6578
'parse'
6679
]);
6780
$this->backendConfig = $this->createPartialMock(
68-
\Magento\Backend\App\ConfigInterface::class,
81+
ConfigInterface::class,
6982
[
7083
'getValue',
7184
'setValue',
7285
'isSetFlag'
7386
]
7487
);
7588
$this->cacheManager = $this->createPartialMock(
76-
\Magento\Framework\App\CacheInterface::class,
89+
CacheInterface::class,
7790
[
7891
'load',
7992
'getFrontend',
@@ -83,18 +96,18 @@ protected function setUp()
8396
]
8497
);
8598

86-
$this->deploymentConfig = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class)
99+
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
87100
->disableOriginalConstructor()->getMock();
88101

89102
$this->objectManagerHelper = new ObjectManagerHelper($this);
90103

91-
$this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
104+
$this->productMetadata = $this->getMockBuilder(ProductMetadata::class)
92105
->disableOriginalConstructor()->getMock();
93106

94-
$this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class);
107+
$this->urlBuilder = $this->createMock(UrlInterface::class);
95108

96109
$this->feed = $this->objectManagerHelper->getObject(
97-
\Magento\AdminNotification\Model\Feed::class,
110+
Feed::class,
98111
[
99112
'backendConfig' => $this->backendConfig,
100113
'cacheManager' => $this->cacheManager,

app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,46 @@
99
*/
1010
namespace Magento\AdminNotification\Test\Unit\Model;
1111

12-
class NotificationServiceTest extends \PHPUnit\Framework\TestCase
12+
use Magento\AdminNotification\Model\Inbox;
13+
use Magento\AdminNotification\Model\InboxFactory;
14+
use Magento\AdminNotification\Model\NotificationService;
15+
use Magento\Framework\Exception\LocalizedException;
16+
use PHPUnit\Framework\MockObject\MockObject;
17+
use PHPUnit\Framework\TestCase;
18+
19+
class NotificationServiceTest extends TestCase
1320
{
1421
/**
1522
* Retrieve instance of notification service model
1623
*
1724
* @param $notificationId
18-
* @return \Magento\AdminNotification\Model\NotificationService
25+
* @return NotificationService
1926
*/
2027
protected function _getServiceInstanceForMarkAsReadTest($notificationId)
2128
{
2229
/**
23-
* @var
24-
* $notificationFactory \PHPUnit_Framework_MockObject_MockObject|\Magento\AdminNotification\Model\InboxFactory
30+
* @var $notificationFactory MockObject|InboxFactory
2531
*/
2632
$notificationFactory = $this->createPartialMock(
27-
\Magento\AdminNotification\Model\InboxFactory::class,
33+
InboxFactory::class,
2834
['create']
2935
);
3036
$notification = $this->createPartialMock(
31-
\Magento\AdminNotification\Model\Inbox::class,
32-
['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup']
37+
Inbox::class,
38+
['load', 'getId', 'save', 'setData', '__sleep', '__wakeup']
3339
);
3440
$notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf());
3541
$notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId));
3642

3743
// when notification Id is valid, add additional expectations
3844
if ($notificationId) {
3945
$notification->expects($this->once())->method('save')->will($this->returnSelf());
40-
$notification->expects($this->once())->method('setIsRead')->with(1)->will($this->returnSelf());
46+
$notification->expects($this->once())->method('setData')
47+
->with('is_read', 1)->will($this->returnSelf());
4148
}
4249

4350
$notificationFactory->expects($this->once())->method('create')->will($this->returnValue($notification));
44-
return new \Magento\AdminNotification\Model\NotificationService($notificationFactory);
51+
return new NotificationService($notificationFactory);
4552
}
4653

4754
public function testMarkAsRead()
@@ -51,12 +58,11 @@ public function testMarkAsRead()
5158
$service->markAsRead($notificationId);
5259
}
5360

54-
/**
55-
* @expectedException \Magento\Framework\Exception\LocalizedException
56-
* @expectedExceptionMessage Wrong notification ID specified.
57-
*/
5861
public function testMarkAsReadThrowsExceptionWhenNotificationIdIsInvalid()
5962
{
63+
$this->expectException(LocalizedException::class);
64+
$this->expectExceptionMessage('Wrong notification ID specified.');
65+
6066
$notificationId = null;
6167
$service = $this->_getServiceInstanceForMarkAsReadTest($notificationId);
6268
$service->markAsRead($notificationId);

0 commit comments

Comments
 (0)