Skip to content

Commit c578524

Browse files
committed
Merge branch '2.4-develop' into B2B-582
# Conflicts: # dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php
2 parents b7259b0 + 0423eae commit c578524

File tree

7,333 files changed

+137157
-102210
lines changed

Some content is hidden

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

7,333 files changed

+137157
-102210
lines changed

.travis.yml.sample

-68
This file was deleted.

app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php

+7-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\AdminAnalytics\Test\Unit\Condition;
79

810
use Magento\AdminAnalytics\Model\Condition\CanViewNotification;
911
use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger;
1012
use Magento\AdminAnalytics\Model\Viewer\Log;
13+
use Magento\Framework\App\CacheInterface;
1114
use Magento\Framework\App\ProductMetadataInterface;
1215
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13-
use Magento\Framework\App\CacheInterface;
1416
use PHPUnit\Framework\MockObject\MockObject;
1517
use PHPUnit\Framework\TestCase;
1618

@@ -28,21 +30,16 @@ class CanViewNotificationTest extends TestCase
2830
/** @var Log|MockObject */
2931
private $logMock;
3032

31-
/** @var $cacheStorageMock MockObject|CacheInterface */
33+
/** @var MockObject|CacheInterface $cacheStorageMock */
3234
private $cacheStorageMock;
3335

3436
protected function setUp(): void
3537
{
3638
$this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class)
3739
->getMockForAbstractClass();
38-
$this->logMock = $this->getMockBuilder(Log::class)
39-
->getMock();
40-
$this->viewerLoggerMock = $this->getMockBuilder(Logger::class)
41-
->disableOriginalConstructor()
42-
->getMock();
43-
$this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class)
44-
->disableOriginalConstructor()
45-
->getMock();
40+
$this->logMock = $this->createMock(Log::class);
41+
$this->viewerLoggerMock = $this->createMock(Logger::class);
42+
$this->productMetadataMock = $this->getMockForAbstractClass(ProductMetadataInterface::class);
4643
$objectManager = new ObjectManager($this);
4744
$this->canViewNotification = $objectManager->getObject(
4845
CanViewNotification::class,

app/code/Magento/AdminAnalytics/composer.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"sort-packages": true
66
},
77
"require": {
8-
"php": "~7.1.3||~7.2.0||~7.3.0",
8+
"php": "~7.3.0||~7.4.0",
99
"magento/framework": "*",
1010
"magento/module-backend": "*",
1111
"magento/module-config": "*",
@@ -18,12 +18,11 @@
1818
"AFL-3.0"
1919
],
2020
"autoload": {
21-
"files": [
22-
"registration.php"
23-
],
24-
"psr-4": {
25-
"Magento\\AdminAnalytics\\": ""
26-
}
21+
"files": [
22+
"registration.php"
23+
],
24+
"psr-4": {
25+
"Magento\\AdminAnalytics\\": ""
26+
}
2727
}
2828
}
29-

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ class ActionsTest extends TestCase
2929
*/
3030
private $sut;
3131

32-
protected function setUp() : void
32+
protected function setUp(): void
3333
{
3434
parent::setUp();
3535

3636
/** @var Escaper|MockObject $escaperMock */
37-
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
37+
$escaperMock = $this->createMock(Escaper::class);
3838
$escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');
3939

4040
/** @var UrlInterface|MockObject $urlBuilder */
41-
$urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
41+
$urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
4242
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
4343

4444
/** @var Context|MockObject $contextMock */
45-
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
45+
$contextMock = $this->createMock(Context::class);
4646
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
4747
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);
4848

4949
/** @var Data|MockObject $urlHelperMock */
50-
$urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
50+
$urlHelperMock = $this->createMock(Data::class);
5151
$urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');
5252

5353
$this->sut = new Actions($contextMock, $urlHelperMock);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace Magento\AdminNotification\Test\Unit\Block\Grid\Renderer;
1313

1414
use Magento\AdminNotification\Block\Grid\Renderer\Notice;
15+
use Magento\Backend\Block\Context;
1516
use Magento\Framework\DataObject;
1617
use Magento\Framework\Escaper;
17-
use Magento\Backend\Block\Context;
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020

@@ -27,16 +27,16 @@ class NoticeTest extends TestCase
2727
*/
2828
private $sut;
2929

30-
protected function setUp() : void
30+
protected function setUp(): void
3131
{
3232
parent::setUp();
3333

3434
/** @var Escaper|MockObject $escaperMock */
35-
$escaperMock = $this->getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
35+
$escaperMock = $this->createMock(Escaper::class);
3636
$escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('<div>Some random html</div>');
3737

3838
/** @var Context|MockObject $contextMock */
39-
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
39+
$contextMock = $this->createMock(Context::class);
4040
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
4141

4242
$this->sut = new Notice($contextMock);

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Magento\Backend\Block\Context;
1717
use Magento\Backend\Block\Widget\Grid\Column;
1818
use Magento\Framework\DataObject;
19-
use Magento\Framework\Escaper;
2019
use PHPUnit\Framework\MockObject\MockObject;
2120
use PHPUnit\Framework\TestCase;
2221

@@ -29,15 +28,15 @@ class SeverityTest extends TestCase
2928
*/
3029
private $sut;
3130

32-
protected function setUp() : void
31+
protected function setUp(): void
3332
{
3433
parent::setUp();
3534

3635
/** @var Inbox|MockObject $inboxMock */
37-
$inboxMock = $this->getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock();
36+
$inboxMock = $this->createMock(Inbox::class);
3837

3938
/** @var Context|MockObject $contextMock */
40-
$contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
39+
$contextMock = $this->createMock(Context::class);
4140

4241
$this->sut = new Severity($contextMock, $inboxMock);
4342
}

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
/**
89
* Test class for \Magento\AdminNotification\Block\ToolbarEntry
@@ -30,7 +31,7 @@ protected function _getBlockInstance($unreadNotifications)
3031
Unread::class,
3132
['getSize', 'setCurPage', 'setPageSize']
3233
);
33-
$notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications));
34+
$notificationList->method('getSize')->willReturn($unreadNotifications);
3435

3536
$block = $objectManagerHelper->getObject(
3637
ToolbarEntry::class,
@@ -52,9 +53,7 @@ public function testGetLatestUnreadNotifications()
5253
$helper = new ObjectManager($this);
5354

5455
// 1. Create mocks
55-
$notificationList = $this->getMockBuilder(Unread::class)
56-
->disableOriginalConstructor()
57-
->getMock();
56+
$notificationList = $this->createMock(Unread::class);
5857

5958
/** @var ToolbarEntry $model */
6059
$model = $helper->getObject(
@@ -65,8 +64,7 @@ public function testGetLatestUnreadNotifications()
6564
// 2. Set expectations
6665
$notificationList->expects($this->atLeastOnce())
6766
->method('setPageSize')
68-
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)
69-
->will($this->returnSelf());
67+
->with(ToolbarEntry::NOTIFICATIONS_NUMBER)->willReturnSelf();
7068

7169
// 3. Run tested method
7270
$result = $model->getLatestUnreadNotifications();

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

+17-19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\AdminNotification\Test\Unit\Model;
89

@@ -70,13 +71,12 @@ protected function setUp(): void
7071
['create']
7172
);
7273
$this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
73-
$this->curl = $this->getMockBuilder(Curl::class)
74-
->disableOriginalConstructor()->getMock();
74+
$this->curl = $this->createMock(Curl::class);
7575
$this->appState = $this->createPartialMock(State::class, []);
7676
$this->inboxModel = $this->createPartialMock(Inbox::class, [
77-
'__wakeup',
78-
'parse'
79-
]);
77+
'__wakeup',
78+
'parse'
79+
]);
8080
$this->backendConfig = $this->createPartialMock(
8181
ConfigInterface::class,
8282
[
@@ -96,15 +96,13 @@ protected function setUp(): void
9696
]
9797
);
9898

99-
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
100-
->disableOriginalConstructor()->getMock();
99+
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);
101100

102101
$this->objectManagerHelper = new ObjectManagerHelper($this);
103102

104-
$this->productMetadata = $this->getMockBuilder(ProductMetadata::class)
105-
->disableOriginalConstructor()->getMock();
103+
$this->productMetadata = $this->createMock(ProductMetadata::class);
106104

107-
$this->urlBuilder = $this->createMock(UrlInterface::class);
105+
$this->urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
108106

109107
$this->feed = $this->objectManagerHelper->getObject(
110108
Feed::class,
@@ -145,20 +143,20 @@ public function testCheckUpdate($callInbox, $curlRequest)
145143
];
146144

147145
$lastUpdate = 0;
148-
$this->cacheManager->expects($this->once())->method('load')->will(($this->returnValue($lastUpdate)));
149-
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
146+
$this->cacheManager->expects($this->once())->method('load')->willReturn($lastUpdate);
147+
$this->curlFactory->expects($this->at(0))->method('create')->willReturn($this->curl);
150148
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
151-
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
152-
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
153-
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
149+
$this->curl->expects($this->once())->method('read')->willReturn($curlRequest);
150+
$this->backendConfig->expects($this->at(0))->method('getValue')->willReturn('1');
151+
$this->backendConfig->expects($this->once())->method('isSetFlag')->willReturn(false);
154152
$this->backendConfig->expects($this->at(1))->method('getValue')
155-
->will($this->returnValue('http://feed.magento.com'));
153+
->willReturn('http://feed.magento.com');
156154
$this->deploymentConfig->expects($this->once())->method('get')
157155
->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)
158-
->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
156+
->willReturn('Sat, 6 Sep 2014 16:46:11 UTC');
159157
if ($callInbox) {
160158
$this->inboxFactory->expects($this->once())->method('create')
161-
->will($this->returnValue($this->inboxModel));
159+
->willReturn($this->inboxModel);
162160
$this->inboxModel->expects($this->once())
163161
->method('parse')
164162
->with(
@@ -178,7 +176,7 @@ function ($initialValue, $item) use ($data) {
178176
}
179177
)
180178
)
181-
->will($this->returnSelf());
179+
->willReturnSelf();
182180
} else {
183181
$this->inboxFactory->expects($this->never())->method('create');
184182
$this->inboxModel->expects($this->never())->method('parse');

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

+12-11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
/**
89
* Test class for \Magento\AdminNotification\Model\NotificationService
@@ -27,27 +28,27 @@ class NotificationServiceTest extends TestCase
2728
protected function _getServiceInstanceForMarkAsReadTest($notificationId)
2829
{
2930
/**
30-
* @var $notificationFactory MockObject|InboxFactory
31+
* @var MockObject|InboxFactory $notificationFactory
3132
*/
3233
$notificationFactory = $this->createPartialMock(
3334
InboxFactory::class,
3435
['create']
3536
);
36-
$notification = $this->createPartialMock(
37-
Inbox::class,
38-
['load', 'getId', 'save', 'setData', '__sleep', '__wakeup']
39-
);
40-
$notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf());
41-
$notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId));
37+
$notification = $this->getMockBuilder(Inbox::class)
38+
->addMethods(['setIsRead'])
39+
->onlyMethods(['load', 'getId', 'save', 'setData', '__sleep', '__wakeup'])
40+
->disableOriginalConstructor()
41+
->getMock();
42+
$notification->expects($this->once())->method('load')->with($notificationId)->willReturnSelf();
43+
$notification->expects($this->once())->method('getId')->willReturn($notificationId);
4244

4345
// when notification Id is valid, add additional expectations
4446
if ($notificationId) {
45-
$notification->expects($this->once())->method('save')->will($this->returnSelf());
46-
$notification->expects($this->once())->method('setData')
47-
->with('is_read', 1)->will($this->returnSelf());
47+
$notification->expects($this->once())->method('save')->willReturnSelf();
48+
$notification->expects($this->once())->method('setIsRead')->with(1)->willReturnSelf();
4849
}
4950

50-
$notificationFactory->expects($this->once())->method('create')->will($this->returnValue($notification));
51+
$notificationFactory->expects($this->once())->method('create')->willReturn($notification);
5152
return new NotificationService($notificationFactory);
5253
}
5354

0 commit comments

Comments
 (0)