Skip to content

Commit ddd451e

Browse files
Merge remote-tracking branch 'origin/AC-15501-Newletter-GiftCard' into Arrows-AC-14808-v4
2 parents b319969 + f45a9c7 commit ddd451e

File tree

51 files changed

+732
-844
lines changed

Some content is hidden

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

51 files changed

+732
-844
lines changed

app/code/Magento/Contact/Test/Unit/Block/ContactFormTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ protected function setUp(): void
4444
->onlyMethods(['getUrlBuilder'])
4545
->getMock();
4646

47-
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
48-
->disableOriginalConstructor()
49-
->getMockForAbstractClass();
47+
$this->urlBuilderMock = $this->createMock(UrlInterface::class);
5048

5149
$this->contextMock->expects($this->any())
5250
->method('getUrlBuilder')

app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,29 @@ class IndexTest extends TestCase
4949
*/
5050
protected function setUp(): void
5151
{
52-
$this->configMock = $this->getMockBuilder(ConfigInterface::class)
53-
->getMockForAbstractClass();
52+
$this->configMock = $this->createMock(ConfigInterface::class);
5453

5554
$contextMock = $this->getMockBuilder(Context::class)
5655
->onlyMethods(
5756
['getRequest', 'getResponse', 'getResultFactory', 'getUrl']
5857
)->disableOriginalConstructor(
5958
)->getMock();
6059

61-
$this->urlMock = $this->getMockBuilder(UrlInterface::class)
62-
->getMockForAbstractClass();
60+
$this->urlMock = $this->createMock(UrlInterface::class);
6361

6462
$contextMock->expects($this->any())
6563
->method('getUrl')
6664
->willReturn($this->urlMock);
6765

6866
$contextMock->expects($this->any())
6967
->method('getRequest')
70-
->willReturn($this->getMockBuilder(RequestInterface::class)
71-
->getMockForAbstractClass());
68+
->willReturn($this->createMock(RequestInterface::class));
7269

7370
$contextMock->expects($this->any())
7471
->method('getResponse')
75-
->willReturn($this->getMockBuilder(ResponseInterface::class)
76-
->getMockForAbstractClass());
72+
->willReturn($this->createMock(ResponseInterface::class));
7773

78-
$this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
79-
->disableOriginalConstructor()
80-
->getMock();
74+
$this->resultFactoryMock = $this->createMock(ResultFactory::class);
8175

8276
$contextMock->expects($this->once())
8377
->method('getResultFactory')
@@ -97,7 +91,7 @@ protected function setUp(): void
9791
*/
9892
public function testExecute(): void
9993
{
100-
$resultStub = $this->getMockForAbstractClass(ResultInterface::class);
94+
$resultStub = $this->createMock(ResultInterface::class);
10195
$this->resultFactoryMock->expects($this->once())
10296
->method('create')
10397
->with(ResultFactory::TYPE_PAGE)

app/code/Magento/Contact/Test/Unit/Controller/Index/PostTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\Framework\Message\ManagerInterface;
1919
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
2020
use Magento\Framework\UrlInterface;
21+
use PHPUnit\Framework\Attributes\DataProvider;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223
use PHPUnit\Framework\TestCase;
2324

@@ -72,14 +73,13 @@ class PostTest extends TestCase
7273
*/
7374
protected function setUp(): void
7475
{
75-
$this->mailMock = $this->getMockBuilder(MailInterface::class)
76-
->getMockForAbstractClass();
76+
$this->mailMock = $this->createMock(MailInterface::class);
7777
$contextMock = $this->createPartialMock(
7878
Context::class,
7979
['getRequest', 'getResponse', 'getResultRedirectFactory', 'getUrl', 'getRedirect', 'getMessageManager']
8080
);
81-
$this->urlMock = $this->getMockForAbstractClass(UrlInterface::class);
82-
$this->messageManagerMock = $this->getMockForAbstractClass(ManagerInterface::class);
81+
$this->urlMock = $this->createMock(UrlInterface::class);
82+
$this->messageManagerMock = $this->createMock(ManagerInterface::class);
8383
$this->requestStub = $this->createPartialMock(
8484
Http::class,
8585
['getPostValue', 'getParams', 'getParam', 'isPost']
@@ -96,15 +96,14 @@ protected function setUp(): void
9696
->method('create')
9797
->willReturn($this->redirectResultMock);
9898

99-
$this->dataPersistorMock = $this->getMockBuilder(DataPersistorInterface::class)
100-
->getMockForAbstractClass();
99+
$this->dataPersistorMock = $this->createMock(DataPersistorInterface::class);
101100

102101
$contextMock->expects($this->any())
103102
->method('getRequest')
104103
->willReturn($this->requestStub);
105104
$contextMock->expects($this->any())
106105
->method('getResponse')
107-
->willReturn($this->getMockForAbstractClass(ResponseInterface::class));
106+
->willReturn($this->createMock(ResponseInterface::class));
108107
$contextMock->expects($this->any())
109108
->method('getMessageManager')
110109
->willReturn($this->messageManagerMock);
@@ -138,8 +137,8 @@ public function testExecuteEmptyPost(): void
138137
* Test exceute post validation
139138
*
140139
* @param array $postData
141-
* @dataProvider postDataProvider
142140
*/
141+
#[DataProvider('postDataProvider')]
143142
public function testExecutePostValidation($postData): void
144143
{
145144
$this->stubRequestPostData($postData);

app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ class IndexTest extends TestCase
4343
*/
4444
protected function setUp(): void
4545
{
46-
$this->configMock = $this->getMockBuilder(ConfigInterface::class)
47-
->getMockForAbstractClass();
46+
$this->configMock = $this->createMock(ConfigInterface::class);
4847

49-
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
50-
->getMockForAbstractClass();
51-
$responseMock = $this->getMockBuilder(ResponseInterface::class)
52-
->getMockForAbstractClass();
48+
$this->requestMock = $this->createMock(RequestInterface::class);
49+
$responseMock = $this->createMock(ResponseInterface::class);
5350

5451
$contextMock = $this->getMockBuilder(Context::class)
5552
->onlyMethods(['getRequest', 'getResponse'])

app/code/Magento/Contact/Test/Unit/Helper/DataTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class DataTest extends TestCase
5454
*/
5555
protected function setUp(): void
5656
{
57-
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
57+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
5858

5959
$contextMock = $this->getMockBuilder(Context::class)
6060
->onlyMethods(['getScopeConfig'])
@@ -159,7 +159,7 @@ public function testGetUserEmail(): void
159159
->method('isLoggedIn')
160160
->willReturn(true);
161161

162-
$customerDataObject = $this->getMockForAbstractClass(CustomerInterface::class);
162+
$customerDataObject = $this->createMock(CustomerInterface::class);
163163
$customerDataObject->expects($this->once())
164164
->method('getEmail')
165165
->willReturn('[email protected]');
@@ -181,8 +181,7 @@ public function testGetPostValue(): void
181181
'email' => 'Some Email'
182182
];
183183

184-
$dataPersistorMock = $this->getMockBuilder(DataPersistorInterface::class)
185-
->getMockForAbstractClass();
184+
$dataPersistorMock = $this->createMock(DataPersistorInterface::class);
186185
$dataPersistorMock->expects($this->once())
187186
->method('get')
188187
->with('contact_us')

app/code/Magento/Contact/Test/Unit/Model/ConfigTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1313
use Magento\Store\Model\ScopeInterface;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617

@@ -34,10 +35,7 @@ class ConfigTest extends TestCase
3435
*/
3536
protected function setUp(): void
3637
{
37-
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
38-
->onlyMethods(['getValue', 'isSetFlag'])
39-
->disableOriginalConstructor()
40-
->getMockForAbstractClass();
38+
$this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class);
4139

4240
$objectManager = new ObjectManagerHelper($this);
4341
$this->model = $objectManager->getObject(
@@ -52,8 +50,8 @@ protected function setUp(): void
5250
* Test isEnabled()
5351
*
5452
* @return void
55-
* @dataProvider isEnabledDataProvider
5653
*/
54+
#[DataProvider('isEnabledDataProvider')]
5755
public function testIsEnabled($isSetFlag, $result): void
5856
{
5957
$this->scopeConfigMock->expects($this->once())

app/code/Magento/Contact/Test/Unit/Model/MailTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,10 @@ class MailTest extends TestCase
5353
*/
5454
protected function setUp(): void
5555
{
56-
$this->configMock = $this->getMockBuilder(ConfigInterface::class)
57-
->getMockForAbstractClass();
58-
$this->transportBuilderMock = $this->getMockBuilder(TransportBuilder::class)
59-
->disableOriginalConstructor()
60-
->getMock();
61-
$this->inlineTranslationMock = $this->getMockBuilder(StateInterface::class)
62-
->disableOriginalConstructor()
63-
->getMockForAbstractClass();
64-
$this->storeManagerMock = $this->getMockForAbstractClass(StoreManagerInterface::class);
56+
$this->configMock = $this->createMock(ConfigInterface::class);
57+
$this->transportBuilderMock = $this->createMock(TransportBuilder::class);
58+
$this->inlineTranslationMock = $this->createMock(StateInterface::class);
59+
$this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
6560

6661
$objectManager = new ObjectManagerHelper($this);
6762
$this->mail = $objectManager->getObject(
@@ -83,9 +78,9 @@ public function testSendMail(): void
8378
$email = '[email protected]';
8479
$templateVars = ['comment' => 'Comment'];
8580

86-
$transport = $this->getMockForAbstractClass(TransportInterface::class);
81+
$transport = $this->createMock(TransportInterface::class);
8782

88-
$storeMock = $this->getMockForAbstractClass(StoreInterface::class);
83+
$storeMock = $this->createMock(StoreInterface::class);
8984
$storeMock->expects($this->once())->method('getId')->willReturn(555);
9085

9186
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);

app/code/Magento/Contact/Test/Unit/Plugin/UserDataProvider/ViewModelTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@
1010
use Magento\Contact\Plugin\UserDataProvider\ViewModel as ViewModelPlugin;
1111
use Magento\Framework\DataObject;
1212
use Magento\Framework\View\Element\Block\ArgumentInterface;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
16+
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1517

1618
/**
1719
* Unit test for the ViewModelPlugin class
1820
*/
1921
class ViewModelTest extends TestCase
2022
{
23+
use MockCreationTrait;
24+
2125
/**
2226
* @var ArgumentInterface|MockObject
2327
*/
@@ -38,23 +42,23 @@ class ViewModelTest extends TestCase
3842
*/
3943
protected function setUp(): void
4044
{
41-
$this->viewModelMock = $this->getMockForAbstractClass(ArgumentInterface::class);
45+
$this->viewModelMock = $this->createMock(ArgumentInterface::class);
4246
$this->blockMock = $this->createMock(DataObject::class);
4347

4448
$this->plugin = new ViewModelPlugin($this->viewModelMock);
4549
}
4650

47-
/**
48-
* @dataProvider dataProvider
49-
*/
51+
#[DataProvider('dataProvider')]
5052
public function testBeforeToHtml($hasDataResult, $setDataExpects)
5153
{
5254
$this->blockMock->expects($this->once())
5355
->method('hasData')
5456
->with('view_model')
5557
->willReturn($hasDataResult);
5658

57-
$this->blockMock->expects($setDataExpects)
59+
$invocationMatcher = $this->createInvocationMatcher($setDataExpects);
60+
61+
$this->blockMock->expects($invocationMatcher)
5862
->method('setData')
5963
->with('view_model', $this->viewModelMock);
6064

@@ -66,11 +70,11 @@ public static function dataProvider()
6670
return [
6771
'view model was not preset before' => [
6872
'hasDataResult' => false,
69-
'setDataExpects' => self::once(),
73+
'setDataExpects' => 'once',
7074
],
7175
'view model was pre-installed before' => [
7276
'hasDataResult' => true,
73-
'setDataExpects' => self::never(),
77+
'setDataExpects' => 'never',
7478
]
7579
];
7680
}

app/code/Magento/GiftMessage/Test/Unit/Block/Cart/GiftOptionsTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ protected function setUp(): void
4040
$this->context = $this->createMock(Context::class);
4141
$this->jsonEncoderMock = $this->createMock(Encoder::class);
4242
$this->compositeConfigProvider = $this->createMock(CompositeConfigProvider::class);
43-
$this->layoutProcessorMock = $this->getMockForAbstractClass(
44-
LayoutProcessorInterface::class,
45-
[],
46-
'',
47-
false
48-
);
43+
$this->layoutProcessorMock = $this->createMock(LayoutProcessorInterface::class);
4944
$this->model = new GiftOptions(
5045
$this->context,
5146
$this->jsonEncoderMock,

app/code/Magento/GiftMessage/Test/Unit/Block/Cart/Item/Renderer/Actions/GiftOptionsTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,13 @@ class GiftOptionsTest extends TestCase
4040

4141
protected function setUp(): void
4242
{
43-
$this->contextMock = $this->getMockBuilder(Context::class)
44-
->disableOriginalConstructor()
45-
->getMock();
43+
$this->contextMock = $this->createMock(Context::class);
4644

47-
$this->jsonEncoderMock = $this->getMockBuilder(Encoder::class)
48-
->disableOriginalConstructor()
49-
->getMock();
45+
$this->jsonEncoderMock = $this->createMock(Encoder::class);
5046

51-
$this->compositeConfigProvider = $this->getMockBuilder(CompositeConfigProvider::class)
52-
->disableOriginalConstructor()
53-
->getMock();
47+
$this->compositeConfigProvider = $this->createMock(CompositeConfigProvider::class);
5448

55-
$this->layoutProcessorMock = $this->getMockBuilder(
56-
LayoutProcessorInterface::class
57-
)
58-
->disableOriginalConstructor()
59-
->getMockForAbstractClass();
49+
$this->layoutProcessorMock = $this->createMock(LayoutProcessorInterface::class);
6050

6151
$this->model = new GiftOptions(
6252
$this->contextMock,
@@ -71,9 +61,7 @@ public function testGetJsLayout()
7161
/**
7262
* @var Item|MockObject $itemMock
7363
*/
74-
$itemMock = $this->getMockBuilder(Item::class)
75-
->disableOriginalConstructor()
76-
->getMock();
64+
$itemMock = $this->createMock(Item::class);
7765

7866
$this->layoutProcessorMock->expects($this->once())
7967
->method('process')

0 commit comments

Comments
 (0)