Skip to content

Commit 265cbda

Browse files
authored
Merge pull request #10257 from magento-gl/Arrows-AC-14808-v3
AC-14808: PHPUnit 12: Upgrade
2 parents 91c33e7 + ba0f654 commit 265cbda

File tree

740 files changed

+8299
-10555
lines changed

Some content is hidden

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

740 files changed

+8299
-10555
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ protected function setUp(): void
3939
$escaperMock->expects($this->atLeastOnce())->method('escapeUrl')->willReturn('https://magento.com');
4040

4141
/** @var AuthorizationInterface|MockObject $authorizationMock */
42-
$authorizationMock = $this->getMockForAbstractClass(AuthorizationInterface::class);
42+
$authorizationMock = $this->createMock(AuthorizationInterface::class);
4343
$authorizationMock->expects($this->atLeastOnce())
4444
->method('isAllowed')
4545
->willReturn(true);
4646

4747
/** @var UrlInterface|MockObject $urlBuilder */
48-
$urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
48+
$urlBuilder = $this->createMock(UrlInterface::class);
4949
$urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
5050

5151
/** @var Context|MockObject $contextMock */

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
use Magento\Backend\Block\Context;
1717
use Magento\Backend\Block\Widget\Grid\Column;
1818
use Magento\Framework\DataObject;
19+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1920
use PHPUnit\Framework\MockObject\MockObject;
2021
use PHPUnit\Framework\TestCase;
2122

2223
class SeverityTest extends TestCase
2324
{
25+
use MockCreationTrait;
26+
2427
/**
2528
* System under Test
2629
*
@@ -44,10 +47,7 @@ protected function setUp(): void
4447
public function testShouldRenderSeverity() : void
4548
{
4649
/** @var Column|MockObject $columnMock */
47-
$columnMock = $this->getMockBuilder(Column::class)
48-
->disableOriginalConstructor()
49-
->addMethods(['getIndex'])
50-
->getMock();
50+
$columnMock = $this->createPartialMockWithReflection(Column::class, ['getIndex']);
5151
$columnMock->expects($this->exactly(5))->method('getIndex')->willReturn('index');
5252
$this->sut->setColumn($columnMock);
5353
$dataObject = new DataObject();

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Framework\HTTP\Adapter\CurlFactory;
2121
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
2222
use Magento\Framework\UrlInterface;
23+
use PHPUnit\Framework\Attributes\DataProvider;
2324
use PHPUnit\Framework\MockObject\MockObject;
2425
use PHPUnit\Framework\TestCase;
2526

@@ -100,10 +101,7 @@ protected function setUp(): void
100101
$this->curlFactory = $this->createPartialMock(CurlFactory::class, ['create']);
101102
$this->curl = $this->createMock(Curl::class);
102103
$this->appState = $this->createPartialMock(State::class, []);
103-
$this->inboxModel = $this->createPartialMock(Inbox::class, [
104-
'__wakeup',
105-
'parse'
106-
]);
104+
$this->inboxModel = $this->createMock(Inbox::class);
107105
$this->backendConfig = $this->createPartialMock(
108106
ConfigInterface::class,
109107
[
@@ -126,7 +124,7 @@ protected function setUp(): void
126124
$this->deploymentConfig = $this->createMock(DeploymentConfig::class);
127125
$this->objectManagerHelper = new ObjectManagerHelper($this);
128126
$this->productMetadata = $this->createMock(ProductMetadata::class);
129-
$this->urlBuilder = $this->getMockForAbstractClass(UrlInterface::class);
127+
$this->urlBuilder = $this->createMock(UrlInterface::class);
130128

131129
$this->feed = $this->objectManagerHelper->getObject(
132130
Feed::class,
@@ -148,8 +146,8 @@ protected function setUp(): void
148146
* @param string $curlRequest
149147
*
150148
* @return void
151-
* @dataProvider checkUpdateDataProvider
152149
*/
150+
#[DataProvider('checkUpdateDataProvider')]
153151
public function testCheckUpdate(bool $callInbox, string $curlRequest): void
154152
{
155153
$mockName = 'Test Product Name';

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
use Magento\AdminNotification\Model\InboxFactory;
1515
use Magento\AdminNotification\Model\NotificationService;
1616
use Magento\Framework\Exception\LocalizedException;
17+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
1920

2021
class NotificationServiceTest extends TestCase
2122
{
23+
use MockCreationTrait;
24+
2225
/**
2326
* Retrieve instance of notification service model
2427
*
@@ -30,15 +33,11 @@ protected function _getServiceInstanceForMarkAsReadTest($notificationId)
3033
/**
3134
* @var MockObject|InboxFactory $notificationFactory
3235
*/
33-
$notificationFactory = $this->createPartialMock(
34-
InboxFactory::class,
35-
['create']
36+
$notificationFactory = $this->createMock(InboxFactory::class);
37+
$notification = $this->createPartialMockWithReflection(
38+
Inbox::class,
39+
['load', 'getId', 'save', 'setData', 'setIsRead']
3640
);
37-
$notification = $this->getMockBuilder(Inbox::class)
38-
->addMethods(['setIsRead'])
39-
->onlyMethods(['load', 'getId', 'save', 'setData', '__sleep', '__wakeup'])
40-
->disableOriginalConstructor()
41-
->getMock();
4241
$notification->expects($this->once())->method('load')->with($notificationId)->willReturnSelf();
4342
$notification->expects($this->once())->method('getId')->willReturn($notificationId);
4443

app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
use Magento\AdminNotification\Model\System\Message\CacheOutdated;
1111
use Magento\Framework\App\Cache\TypeListInterface;
1212
use Magento\Framework\AuthorizationInterface;
13+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415
use Magento\Framework\UrlInterface;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1517
use PHPUnit\Framework\MockObject\MockObject;
1618
use PHPUnit\Framework\TestCase;
1719

1820
class CacheOutdatedTest extends TestCase
1921
{
22+
use MockCreationTrait;
23+
2024
/**
2125
* @var MockObject
2226
*/
@@ -39,9 +43,9 @@ class CacheOutdatedTest extends TestCase
3943

4044
protected function setUp(): void
4145
{
42-
$this->_authorizationMock = $this->getMockForAbstractClass(AuthorizationInterface::class);
43-
$this->_urlInterfaceMock = $this->getMockForAbstractClass(UrlInterface::class);
44-
$this->_cacheTypeListMock = $this->getMockForAbstractClass(TypeListInterface::class);
46+
$this->_authorizationMock = $this->createMock(AuthorizationInterface::class);
47+
$this->_urlInterfaceMock = $this->createMock(UrlInterface::class);
48+
$this->_cacheTypeListMock = $this->createMock(TypeListInterface::class);
4549

4650
$objectManagerHelper = new ObjectManager($this);
4751
$arguments = [
@@ -58,8 +62,8 @@ protected function setUp(): void
5862
/**
5963
* @param string $expectedSum
6064
* @param array $cacheTypes
61-
* @dataProvider getIdentityDataProvider
6265
*/
66+
#[DataProvider('getIdentityDataProvider')]
6367
public function testGetIdentity($expectedSum, $types)
6468
{
6569
$cacheType = [];
@@ -77,9 +81,7 @@ public function testGetIdentity($expectedSum, $types)
7781

7882
protected function getMockForStdClass($mockReturn)
7983
{
80-
$cacheTypeMock = $this->getMockBuilder(\stdClass::class)->addMethods(['getCacheType'])
81-
->disableOriginalConstructor()
82-
->getMock();
84+
$cacheTypeMock = $this->createPartialMockWithReflection(\stdClass::class, ['getCacheType']);
8385
$cacheTypeMock->method('getCacheType')->willReturn($mockReturn);
8486
return $cacheTypeMock;
8587
}
@@ -102,8 +104,8 @@ public static function getIdentityDataProvider()
102104
* @param bool $expected
103105
* @param bool $allowed
104106
* @param array $cacheTypes
105-
* @dataProvider isDisplayedDataProvider
106107
*/
108+
#[DataProvider('isDisplayedDataProvider')]
107109
public function testIsDisplayed($expected, $allowed, $cacheTypes)
108110
{
109111
$cacheType1 = [];

app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Notification\MessageInterface;
1212
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1313
use Magento\MediaStorage\Model\File\Storage\Flag;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617

@@ -58,8 +59,8 @@ public function testGetText()
5859
/**
5960
* @param bool $expectedFirstRun
6061
* @param array $data
61-
* @dataProvider isDisplayedDataProvider
6262
*/
63+
#[DataProvider('isDisplayedDataProvider')]
6364
public function testIsDisplayed($expectedFirstRun, $data)
6465
{
6566
$arguments = ['fileStorage' => $this->_fileStorage];

app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\HTTP\Adapter\Curl;
1414
use Magento\Framework\HTTP\Adapter\CurlFactory;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
1819

@@ -41,8 +42,8 @@ class SecurityTest extends TestCase
4142
protected function setUp(): void
4243
{
4344
//Prepare objects for constructor
44-
$this->cacheMock = $this->getMockForAbstractClass(CacheInterface::class);
45-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
45+
$this->cacheMock = $this->createMock(CacheInterface::class);
46+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
4647
$this->curlFactoryMock = $this->createPartialMock(
4748
CurlFactory::class,
4849
['create']
@@ -66,8 +67,8 @@ protected function setUp(): void
6667
* @param $cached
6768
* @param $response
6869
* @return void
69-
* @dataProvider isDisplayedDataProvider
7070
*/
71+
#[DataProvider('isDisplayedDataProvider')]
7172
public function testIsDisplayed($expectedResult, $cached, $response)
7273
{
7374
$this->cacheMock->method('load')->willReturn($cached);

app/code/Magento/AdminNotification/Test/Unit/Observer/PredispatchAdminActionControllerObserverTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,20 @@ protected function setUp(): void
6666
$this->objectManager = new ObjectManager($this);
6767
$this->observerMock = $this->createMock(Observer::class);
6868

69-
$this->backendAuthSessionMock = $this->getMockBuilder(Session::class)
70-
->disableOriginalConstructor()
71-
->onlyMethods(['isLoggedIn'])
72-
->getMock();
73-
74-
$this->feedMock = $this->getMockBuilder(Feed::class)
75-
->disableOriginalConstructor()
76-
->onlyMethods(['checkUpdate'])
77-
->getMock();
78-
79-
$this->feedFactoryMock = $this->getMockBuilder(FeedFactory::class)
80-
->disableOriginalConstructor()
81-
->onlyMethods(['create'])
82-
->getMock();
69+
$this->backendAuthSessionMock = $this->createPartialMock(
70+
Session::class,
71+
['isLoggedIn']
72+
);
73+
74+
$this->feedMock = $this->createPartialMock(
75+
Feed::class,
76+
['checkUpdate']
77+
);
78+
79+
$this->feedFactoryMock = $this->createPartialMock(
80+
FeedFactory::class,
81+
['create']
82+
);
8383

8484
$this->observer = $this->objectManager->getObject(
8585
PredispatchAdminActionControllerObserver::class,

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Config\Data\ConfigData;
1414
use Magento\Framework\Setup\Option\TextConfigOption;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
use PHPUnit\Framework\Attributes\DataProvider;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
1819

@@ -56,13 +57,8 @@ protected function setUp(): void
5657
];
5758

5859
$this->objectManager = new ObjectManager($this);
59-
$this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class)
60-
->disableOriginalConstructor()
61-
->getMock();
62-
63-
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
64-
->disableOriginalConstructor()
65-
->getMock();
60+
$this->connectionValidatorMock = $this->createMock(ConnectionValidator::class);
61+
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
6662

6763
$this->model = $this->objectManager->getObject(
6864
ConfigOptionsList::class,
@@ -131,8 +127,8 @@ public function testGetOptions()
131127
/**
132128
* @param array $options
133129
* @param array $expectedConfigData
134-
* @dataProvider getCreateConfigDataProvider
135130
*/
131+
#[DataProvider('getCreateConfigDataProvider')]
136132
public function testCreateConfig($options, $expectedConfigData)
137133
{
138134
$result = $this->model->createConfig($options, $this->deploymentConfigMock);

app/code/Magento/AsynchronousOperations/Test/Unit/Block/Adminhtml/Bulk/Details/BackButtonTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BackButtonTest extends TestCase
2626

2727
protected function setUp(): void
2828
{
29-
$this->urlBuilderMock = $this->getMockForAbstractClass(UrlInterface::class);
29+
$this->urlBuilderMock = $this->createMock(UrlInterface::class);
3030
$this->block = new BackButton(
3131
$this->urlBuilderMock
3232
);

0 commit comments

Comments
 (0)