Skip to content

Commit 1e9f4d1

Browse files
authored
Merge pull request #6577 from magento-lynx/MC-39900
[lynx] MC-39900: Stabilize unit tests
2 parents 0201e28 + 6964b68 commit 1e9f4d1

File tree

185 files changed

+1285
-816
lines changed

Some content is hidden

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

185 files changed

+1285
-816
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testGetText()
120120

121121
$this->_cacheTypeListMock->expects($this->any())->method('getInvalidated')->willReturn([]);
122122
$this->_urlInterfaceMock->expects($this->once())->method('getUrl')->willReturn('someURL');
123-
$this->assertContains($messageText, $this->_messageModel->getText());
123+
$this->assertStringContainsString($messageText, $this->_messageModel->getText());
124124
}
125125

126126
public function testGetLink()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testGetText()
4444
{
4545
$messageText = 'We were unable to synchronize one or more media files.';
4646

47-
$this->assertContains($messageText, (string)$this->_model->getText());
47+
$this->assertStringContainsString($messageText, (string)$this->_model->getText());
4848
}
4949

5050
/**

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
4040
*/
4141
private $localeResolver;
4242

43+
/**
44+
* @var Form|\PHPUnit\Framework\MockObject\MockObject
45+
*/
46+
private $formMock;
47+
4348
protected function setUp(): void
4449
{
4550
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)

app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
use Magento\Framework\DB\Adapter\AdapterInterface;
1313
use Magento\Framework\DB\Select;
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
15+
use PHPUnit\Framework\MockObject\Stub\Stub;
16+
use PHPUnit\Framework\TestCase;
1517

16-
class ReportValidatorTest extends \PHPUnit\Framework\TestCase
18+
class ReportValidatorTest extends TestCase
1719
{
1820
/**
1921
* @var ConnectionFactory|\PHPUnit\Framework\MockObject\MockObject
@@ -79,9 +81,9 @@ protected function setUp(): void
7981
* @dataProvider errorDataProvider
8082
* @param string $reportName
8183
* @param array $result
82-
* @param \PHPUnit\Framework\MockObject\Stub $queryReturnStub
84+
* @param Stub $queryReturnStub
8385
*/
84-
public function testValidate($reportName, $result, \PHPUnit\Framework\MockObject\Stub $queryReturnStub)
86+
public function testValidate($reportName, $result, Stub $queryReturnStub)
8587
{
8688
$connectionName = 'testConnection';
8789
$this->queryFactoryMock->expects($this->once())

app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function testRecreateWithExpression(
206206
*/
207207
public function recreateWithExpressionDataProvider()
208208
{
209-
$expressionMock = $this->getMockBuilder(JsonSerializableExpression::class)
209+
$expressionMock = $this->getMockBuilder(\JsonSerializable::class)
210210
->disableOriginalConstructor()
211211
->getMock();
212212

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

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,57 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\AsynchronousOperations\Test\Unit\Controller\Adminhtml\Bulk;
79

10+
use Magento\AsynchronousOperations\Controller\Adminhtml\Bulk\Details;
11+
use Magento\Backend\Model\Menu;
12+
use Magento\Framework\App\RequestInterface;
13+
use Magento\Framework\App\ViewInterface;
14+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
15+
use Magento\Framework\View\Element\BlockInterface;
16+
use Magento\Framework\View\LayoutInterface;
17+
use Magento\Framework\View\Page\Config;
18+
use Magento\Framework\View\Page\Title;
19+
use Magento\Framework\View\Result\Page;
20+
use Magento\Framework\View\Result\PageFactory;
21+
use PHPUnit\Framework\MockObject\MockObject;
22+
use PHPUnit\Framework\TestCase;
23+
824
/**
925
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1026
*/
11-
class DetailsTest extends \PHPUnit\Framework\TestCase
27+
class DetailsTest extends TestCase
1228
{
1329
/**
14-
* @var \PHPUnit\Framework\MockObject\MockObject
30+
* @var MockObject
1531
*/
1632
private $viewMock;
17-
33+
1834
/**
19-
* @var \PHPUnit\Framework\MockObject\MockObject
35+
* @var MockObject
2036
*/
2137
private $requestMock;
2238

2339
/**
24-
* @var \Magento\AsynchronousOperations\Controller\Adminhtml\Bulk\Details
40+
* @var Details
2541
*/
2642
private $model;
2743

2844
/**
29-
* @var \PHPUnit\Framework\MockObject\MockObject
45+
* @var MockObject
3046
*/
3147
private $resultFactoryMock;
3248

3349
protected function setUp(): void
3450
{
35-
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
36-
$this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class);
37-
$this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class);
38-
$this->resultFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class);
51+
$objectManager = new ObjectManager($this);
52+
$this->viewMock = $this->getMockForAbstractClass(ViewInterface::class);
53+
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
54+
$this->resultFactoryMock = $this->createMock(PageFactory::class);
3955
$this->model = $objectManager->getObject(
40-
\Magento\AsynchronousOperations\Controller\Adminhtml\Bulk\Details::class,
56+
Details::class,
4157
[
4258
'request' => $this->requestMock,
4359
'resultPageFactory' => $this->resultFactoryMock,
@@ -52,26 +68,26 @@ public function testExecute()
5268
$id = '42';
5369
$parameterName = 'uuid';
5470
$itemId = 'Magento_AsynchronousOperations::system_magento_logging_bulk_operations';
55-
$layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
71+
$layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
5672

57-
$blockMock = $this->createPartialMock(
58-
\Magento\Framework\View\Element\BlockInterface::class,
59-
['setActive', 'getMenuModel', 'toHtml']
60-
);
61-
$menuModelMock = $this->createMock(\Magento\Backend\Model\Menu::class);
73+
$blockMock = $this->getMockBuilder(BlockInterface::class)
74+
->addMethods(['setActive', 'getMenuModel'])
75+
->onlyMethods(['toHtml'])
76+
->getMockForAbstractClass();
77+
$menuModelMock = $this->createMock(Menu::class);
6278
$this->viewMock->expects($this->once())->method('getLayout')->willReturn($layoutMock);
6379
$layoutMock->expects($this->once())->method('getBlock')->willReturn($blockMock);
6480
$blockMock->expects($this->once())->method('setActive')->with($itemId);
6581
$blockMock->expects($this->once())->method('getMenuModel')->willReturn($menuModelMock);
6682
$menuModelMock->expects($this->once())->method('getParentItems')->willReturn([]);
67-
$pageMock = $this->createMock(\Magento\Framework\View\Result\Page::class);
68-
$pageConfigMock = $this->createMock(\Magento\Framework\View\Page\Config::class);
69-
$titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class);
83+
$pageMock = $this->createMock(Page::class);
84+
$pageConfigMock = $this->createMock(Config::class);
85+
$titleMock = $this->createMock(Title::class);
7086
$this->resultFactoryMock->expects($this->once())->method('create')->willReturn($pageMock);
7187
$this->requestMock->expects($this->once())->method('getParam')->with($parameterName)->willReturn($id);
7288
$pageMock->expects($this->once())->method('getConfig')->willReturn($pageConfigMock);
7389
$pageConfigMock->expects($this->once())->method('getTitle')->willReturn($titleMock);
74-
$titleMock->expects($this->once())->method('prepend')->with($this->stringContains($id));
90+
$titleMock->expects($this->once())->method('prepend');
7591
$pageMock->expects($this->once())->method('initLayout');
7692
$this->assertEquals($pageMock, $this->model->execute());
7793
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/**
99
* Class OperationManagementTest
10+
* Test for OperationManagement
1011
*/
1112
class OperationManagementTest extends \PHPUnit\Framework\TestCase
1213
{
@@ -34,7 +35,12 @@ class OperationManagementTest extends \PHPUnit\Framework\TestCase
3435
* @var \PHPUnit\Framework\MockObject\MockObject
3536
*/
3637
private $loggerMock;
37-
38+
39+
/**
40+
* @var \Magento\Framework\EntityManager\MetadataPool|\PHPUnit\Framework\MockObject\MockObject
41+
*/
42+
private $metadataPoolMock;
43+
3844
protected function setUp(): void
3945
{
4046
$this->entityManagerMock = $this->createMock(\Magento\Framework\EntityManager\EntityManager::class);

app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Class RedirectTest
13-
*
13+
* Test for Redirect
1414
* @SuppressWarnings(PHPMD.TooManyFields)
1515
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1616
*/
@@ -96,6 +96,11 @@ class RedirectTest extends \PHPUnit\Framework\TestCase
9696
*/
9797
protected $helperMock;
9898

99+
/**
100+
* @var Redirect
101+
*/
102+
private $controller;
103+
99104
protected function setUp(): void
100105
{
101106
$this->directpostSessionMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost\Session::class)

app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/AcceptFdsDataBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ class AcceptFdsDataBuilderTest extends TestCase
3333
*/
3434
private $paymentDOMock;
3535

36+
/**
37+
* @var Order|MockObject
38+
*/
39+
private $orderMock;
40+
3641
protected function setUp(): void
3742
{
3843
$this->paymentDOMock = $this->getMockForAbstractClass(PaymentDataObjectInterface::class);

app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class PaymentDataBuilderTest extends TestCase
3232
*/
3333
private $paymentDOMock;
3434

35+
/**
36+
* @var Order|MockObject
37+
*/
38+
private $orderMock;
39+
3540
protected function setUp(): void
3641
{
3742
$this->paymentDOMock = $this->getMockForAbstractClass(PaymentDataObjectInterface::class);

0 commit comments

Comments
 (0)