Skip to content

Commit f3d4f45

Browse files
Merge remote-tracking branch 'origin/AC-15497' into AC-15050
2 parents 4e5c323 + 5ee2d45 commit f3d4f45

File tree

34 files changed

+241
-288
lines changed

34 files changed

+241
-288
lines changed

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
);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\Bulk\BulkStatusInterface;
1313
use Magento\Framework\Bulk\OperationInterface;
1414
use PHPUnit\Framework\MockObject\MockObject;
15+
use PHPUnit\Framework\Attributes\DataProvider;
16+
1517
use PHPUnit\Framework\TestCase;
1618

1719
class DoneButtonTest extends TestCase
@@ -33,8 +35,8 @@ class DoneButtonTest extends TestCase
3335

3436
protected function setUp(): void
3537
{
36-
$this->bulkStatusMock = $this->getMockForAbstractClass(BulkStatusInterface::class);
37-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
38+
$this->bulkStatusMock = $this->createMock(BulkStatusInterface::class);
39+
$this->requestMock = $this->createMock(RequestInterface::class);
3840
$this->block = new DoneButton(
3941
$this->bulkStatusMock,
4042
$this->requestMock
@@ -45,8 +47,8 @@ protected function setUp(): void
4547
* @param int $failedCount
4648
* @param int $buttonsParam
4749
* @param array $expectedResult
48-
* @dataProvider getButtonDataProvider
4950
*/
51+
#[DataProvider('getButtonDataProvider')]
5052
public function testGetButtonData($failedCount, $buttonsParam, $expectedResult)
5153
{
5254
$uuid = 'some standard uuid string';

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\AsynchronousOperations\Block\Adminhtml\Bulk\Details\RetryButton;
1111
use Magento\AsynchronousOperations\Model\Operation\Details;
1212
use Magento\Framework\App\RequestInterface;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516

@@ -33,7 +34,7 @@ class RetryButtonTest extends TestCase
3334
protected function setUp(): void
3435
{
3536
$this->detailsMock = $this->createMock(Details::class);
36-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
37+
$this->requestMock = $this->createMock(RequestInterface::class);
3738
$this->block = new RetryButton(
3839
$this->detailsMock,
3940
$this->requestMock
@@ -43,8 +44,8 @@ protected function setUp(): void
4344
/**
4445
* @param int $failedCount
4546
* @param array $expectedResult
46-
* @dataProvider getButtonDataProvider
4747
*/
48+
#[DataProvider('getButtonDataProvider')]
4849
public function testGetButtonData($failedCount, $expectedResult)
4950
{
5051
$details = ['failed_retriable' => $failedCount];

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Adminhtml/Bulk/DetailsTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Backend\Model\Menu;
1212
use Magento\Framework\App\RequestInterface;
1313
use Magento\Framework\App\ViewInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1415
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1516
use Magento\Framework\View\Element\BlockInterface;
1617
use Magento\Framework\View\LayoutInterface;
@@ -26,6 +27,8 @@
2627
*/
2728
class DetailsTest extends TestCase
2829
{
30+
use MockCreationTrait;
31+
2932
/**
3033
* @var MockObject
3134
*/
@@ -49,8 +52,8 @@ class DetailsTest extends TestCase
4952
protected function setUp(): void
5053
{
5154
$objectManager = new ObjectManager($this);
52-
$this->viewMock = $this->getMockForAbstractClass(ViewInterface::class);
53-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
55+
$this->viewMock = $this->createMock(ViewInterface::class);
56+
$this->requestMock = $this->createMock(RequestInterface::class);
5457
$this->resultFactoryMock = $this->createMock(PageFactory::class);
5558
$this->model = $objectManager->getObject(
5659
Details::class,
@@ -68,12 +71,12 @@ public function testExecute()
6871
$id = '42';
6972
$parameterName = 'uuid';
7073
$itemId = 'Magento_AsynchronousOperations::system_magento_logging_bulk_operations';
71-
$layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
74+
$layoutMock = $this->createMock(LayoutInterface::class);
7275

73-
$blockMock = $this->getMockBuilder(BlockInterface::class)
74-
->addMethods(['setActive', 'getMenuModel'])
75-
->onlyMethods(['toHtml'])
76-
->getMockForAbstractClass();
76+
$blockMock = $this->createPartialMockWithReflection(
77+
BlockInterface::class,
78+
['setActive', 'getMenuModel', 'toHtml']
79+
);
7780
$menuModelMock = $this->createMock(Menu::class);
7881
$this->viewMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
7982
$layoutMock->expects($this->once())->method('getBlock')->willReturn($blockMock);

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Adminhtml/Bulk/RetryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected function setUp(): void
6666
$objectManager = new ObjectManager($this);
6767
$this->bulkManagementMock = $this->createMock(BulkManagement::class);
6868
$this->notificationManagementMock = $this->createMock(BulkNotificationManagement::class);
69-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
69+
$this->requestMock = $this->createMock(RequestInterface::class);
7070
$this->resultFactoryMock = $this->createPartialMock(ResultFactory::class, ['create']);
7171
$this->jsonResultMock = $this->createMock(Json::class);
7272

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Adminhtml/Index/IndexTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Backend\Model\Menu;
1212
use Magento\Framework\App\RequestInterface;
1313
use Magento\Framework\App\ViewInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1415
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1516
use Magento\Framework\View\Element\BlockInterface;
1617
use Magento\Framework\View\LayoutInterface;
@@ -26,6 +27,8 @@
2627
*/
2728
class IndexTest extends TestCase
2829
{
30+
use MockCreationTrait;
31+
2932
/**
3033
* @var MockObject
3134
*/
@@ -49,8 +52,8 @@ class IndexTest extends TestCase
4952
protected function setUp(): void
5053
{
5154
$objectManager = new ObjectManager($this);
52-
$this->viewMock = $this->getMockForAbstractClass(ViewInterface::class);
53-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
55+
$this->viewMock = $this->createMock(ViewInterface::class);
56+
$this->requestMock = $this->createMock(RequestInterface::class);
5457
$this->resultFactoryMock = $this->createMock(PageFactory::class);
5558

5659
$this->model = $objectManager->getObject(
@@ -68,17 +71,17 @@ public function testExecute()
6871
{
6972
$itemId = 'Magento_AsynchronousOperations::system_magento_logging_bulk_operations';
7073
$prependText = 'Bulk Actions Log';
71-
$layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
74+
$layoutMock = $this->createMock(LayoutInterface::class);
7275
$menuModelMock = $this->createMock(Menu::class);
7376
$pageMock = $this->createMock(Page::class);
7477
$pageConfigMock = $this->createMock(Config::class);
7578
$titleMock = $this->createMock(Title::class);
7679
$this->resultFactoryMock->expects($this->once())->method('create')->willReturn($pageMock);
7780

78-
$blockMock = $this->getMockBuilder(BlockInterface::class)
79-
->addMethods(['setActive', 'getMenuModel'])
80-
->onlyMethods(['toHtml'])
81-
->getMockForAbstractClass();
81+
$blockMock = $this->createPartialMockWithReflection(
82+
BlockInterface::class,
83+
['setActive', 'getMenuModel', 'toHtml']
84+
);
8285

8386
$this->viewMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
8487
$layoutMock->expects($this->once())->method('getBlock')->willReturn($blockMock);

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Adminhtml/Notification/DismissTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp(): void
4747
{
4848
$objectManager = new ObjectManager($this);
4949
$this->notificationManagementMock = $this->createMock(BulkNotificationManagement::class);
50-
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
50+
$this->requestMock = $this->createMock(RequestInterface::class);
5151
$this->resultFactoryMock = $this->createPartialMock(ResultFactory::class, ['create']);
5252

5353
$this->jsonResultMock = $this->createMock(Json::class);

app/code/Magento/AsynchronousOperations/Test/Unit/Controller/Cron/BulkCleanupTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class BulkCleanupTest extends TestCase
5252
protected function setUp(): void
5353
{
5454
$this->dateTimeMock = $this->createMock(DateTime::class);
55-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
55+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
5656
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
5757
$this->metadataPoolMock = $this->createMock(MetadataPool::class);
5858
$this->timeMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\DateTime::class);
@@ -72,8 +72,8 @@ public function testExecute()
7272
$bulkLifetimeMultiplier = 10;
7373
$bulkLifetime = 3600 * 24 * $bulkLifetimeMultiplier;
7474

75-
$adapterMock = $this->getMockForAbstractClass(AdapterInterface::class);
76-
$entityMetadataMock = $this->getMockForAbstractClass(EntityMetadataInterface::class);
75+
$adapterMock = $this->createMock(AdapterInterface::class);
76+
$entityMetadataMock = $this->createMock(EntityMetadataInterface::class);
7777

7878
$this->metadataPoolMock->expects($this->once())->method('getMetadata')->with($this->stringContains($entityType))
7979
->willReturn($entityMetadataMock);

app/code/Magento/AsynchronousOperations/Test/Unit/Model/AccessValidatorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\AsynchronousOperations\Model\AccessValidator;
1313
use Magento\Authorization\Model\UserContextInterface;
1414
use Magento\Framework\EntityManager\EntityManager;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718

@@ -39,7 +40,7 @@ class AccessValidatorTest extends TestCase
3940

4041
protected function setUp(): void
4142
{
42-
$this->userContextMock = $this->getMockForAbstractClass(UserContextInterface::class);
43+
$this->userContextMock = $this->createMock(UserContextInterface::class);
4344
$this->entityManagerMock = $this->createMock(EntityManager::class);
4445
$this->bulkSummaryFactoryMock = $this->createPartialMock(
4546
BulkSummaryInterfaceFactory::class,
@@ -54,15 +55,15 @@ protected function setUp(): void
5455
}
5556

5657
/**
57-
* @dataProvider summaryDataProvider
5858
* @param string $bulkUserId
5959
* @param bool $expectedResult
6060
*/
61+
#[DataProvider('summaryDataProvider')]
6162
public function testIsAllowed($bulkUserId, $expectedResult)
6263
{
6364
$adminId = 1;
6465
$uuid = 'test-001';
65-
$bulkSummaryMock = $this->getMockForAbstractClass(BulkSummaryInterface::class);
66+
$bulkSummaryMock = $this->createMock(BulkSummaryInterface::class);
6667

6768
$this->bulkSummaryFactoryMock->expects($this->once())->method('create')->willReturn($bulkSummaryMock);
6869
$this->entityManagerMock->expects($this->once())

0 commit comments

Comments
 (0)