Skip to content

Commit de12b2f

Browse files
committed
Merge remote-tracking branch 'origin/AC-10634-ce' into AC-10821
2 parents 115c5a0 + 9206a32 commit de12b2f

File tree

20 files changed

+166
-131
lines changed

20 files changed

+166
-131
lines changed

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/AddAttributeToTemplateTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,38 +117,39 @@ protected function setUp(): void
117117
->getMock();
118118
$this->resultJsonFactoryMock = $this->getMockBuilder(JsonFactory::class)
119119
->disableOriginalConstructor()
120-
->setMethods(['create'])
120+
->onlyMethods(['create'])
121121
->getMock();
122122
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
123-
->setMethods(['getParam', 'setParam'])
123+
->addMethods(['setParam'])
124+
->onlyMethods(['getParam'])
124125
->getMockForAbstractClass();
125126
$this->contextMock->expects($this->once())
126127
->method('getRequest')
127128
->willReturn($this->requestMock);
128129
$this->attributeSetRepositoryMock = $this->getMockBuilder(AttributeSetRepositoryInterface::class)
129-
->setMethods(['get'])
130+
->onlyMethods(['get'])
130131
->getMockForAbstractClass();
131132
$this->attributeSetInterfaceMock = $this->getMockBuilder(AttributeSetInterface::class)
132133
->getMockForAbstractClass();
133134
$this->searchCriteriaBuilderMock = $this->getMockBuilder(SearchCriteriaBuilder::class)
134135
->disableOriginalConstructor()
135-
->setMethods(['addFilter', 'create', 'setPageSize', 'addSortOrder'])
136+
->onlyMethods(['addFilter', 'create', 'setPageSize', 'addSortOrder'])
136137
->getMockForAbstractClass();
137138
$this->searchCriteriaMock = $this->getMockBuilder(SearchCriteria::class)
138139
->disableOriginalConstructor()
139140
->getMock();
140141
$this->attributeGroupRepositoryMock = $this->getMockBuilder(AttributeGroupRepositoryInterface::class)
141-
->setMethods(['getList'])
142+
->onlyMethods(['getList'])
142143
->getMockForAbstractClass();
143144
$this->attributeGroupSearchResultsMock = $this->getMockBuilder(AttributeGroupSearchResultsInterface::class)
144-
->setMethods(['getItems'])
145+
->onlyMethods(['getItems'])
145146
->getMockForAbstractClass();
146147
$this->attributeGroupInterfaceFactoryMock = $this->getMockBuilder(AttributeGroupInterfaceFactory::class)
147-
->setMethods(['create'])
148+
->onlyMethods(['create'])
148149
->disableOriginalConstructor()
149150
->getMock();
150151
$this->attributeGroupInterfaceMock = $this->getMockBuilder(AttributeGroupInterface::class)
151-
->setMethods(['getExtensionAttributes'])
152+
->onlyMethods(['getExtensionAttributes'])
152153
->getMockForAbstractClass();
153154
$this->jsonMock = $this->getMockBuilder(Json::class)
154155
->disableOriginalConstructor()

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/EditTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ protected function setUp(): void
122122

123123
$this->resultPage = $this->getMockBuilder(Page::class)
124124
->disableOriginalConstructor()
125-
->setMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb', 'addHandle', 'getLayout'])
125+
->onlyMethods(['setActiveMenu', 'getConfig', 'addBreadcrumb', 'addHandle', 'getLayout'])
126126
->getMock();
127127

128128
$this->resultPageFactory = $this->getMockBuilder(PageFactory::class)
129129
->disableOriginalConstructor()
130-
->setMethods(['create'])
130+
->onlyMethods(['create'])
131131
->getMock();
132132

133133
$this->resultLayout = $this->getMockBuilder(Layout::class)
@@ -154,7 +154,7 @@ protected function setUp(): void
154154
->getMock();
155155

156156
$this->blockTemplate = $this->getMockBuilder(Template::class)
157-
->setMethods(['setIsPopup'])
157+
->addMethods(['setIsPopup'])
158158
->disableOriginalConstructor()
159159
->getMock();
160160

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Attribute/SaveTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ public function testExecuteWithOptionsDataError()
395395
private function addReturnResultConditions(string $path = '', array $params = [], array $response = [])
396396
{
397397
$layoutMock = $this->getMockBuilder(LayoutInterface::class)
398-
->setMethods(['initMessages', 'getMessagesBlock'])
398+
->addMethods(['initMessages'])
399+
->onlyMethods(['getMessagesBlock'])
399400
->getMockForAbstractClass();
400401
$this->layoutFactoryMock
401402
->expects($this->once())

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/BuilderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ protected function setUp(): void
9797
$methods = ['setStoreId', 'setData', 'load', 'setAttributeSetId', 'setTypeId'];
9898
$this->productMock = $this->createPartialMock(Product::class, $methods);
9999
$this->storeFactoryMock = $this->getMockBuilder(StoreFactory::class)
100-
->setMethods(['create'])
100+
->onlyMethods(['create'])
101101
->disableOriginalConstructor()
102102
->getMock();
103103
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
104-
->setMethods(['load'])
104+
->addMethods(['load'])
105105
->getMockForAbstractClass();
106106

107107
$this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class)
108-
->setMethods(['getById'])
108+
->onlyMethods(['getById'])
109109
->disableOriginalConstructor()
110110
->getMockForAbstractClass();
111111

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ReloadTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function setUp(): void
100100
->disableOriginalConstructor()
101101
->getMock();
102102
$this->resultMock = $this->getMockBuilder(ResultInterface::class)
103-
->setMethods(['forward', 'setJsonData', 'getLayout'])
103+
->addMethods(['forward', 'setJsonData', 'getLayout'])
104104
->getMockForAbstractClass();
105105
$this->productMock = $this->getMockBuilder(ProductInterface::class)
106106
->getMockForAbstractClass();

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,24 @@ protected function initContext(array $additionalParams = [], array $objectManage
7575
->disableOriginalConstructor()
7676
->getMockForAbstractClass();
7777
$this->layout = $this->getMockBuilder(Layout::class)
78-
->setMethods(['getBlock'])->disableOriginalConstructor()
78+
->onlyMethods(['getBlock'])->disableOriginalConstructor()
7979
->getMock();
8080
$this->layout->expects($this->any())->method('getBlock')->willReturn($block);
8181

8282
$eventManager = $this->getMockBuilder(Manager::class)
83-
->setMethods(['dispatch'])->disableOriginalConstructor()
83+
->onlyMethods(['dispatch'])->disableOriginalConstructor()
8484
->getMock();
8585
$eventManager->expects($this->any())->method('dispatch')->willReturnSelf();
8686
$requestInterfaceMock = $this->getMockBuilder(Http::class)
87-
->setMethods(
87+
->onlyMethods(
8888
['getParam', 'getPost', 'getFullActionName', 'getPostValue']
8989
)->disableOriginalConstructor()
9090
->getMock();
9191

9292
$responseInterfaceMock = $this->getMockBuilder(ResponseInterface::class)
93-
->setMethods(
94-
['setRedirect', 'sendResponse']
95-
)->getMockForAbstractClass();
93+
->addMethods(['setRedirect'])
94+
->onlyMethods(['sendResponse'])
95+
->getMockForAbstractClass();
9696

9797
$managerInterfaceMock = $this->getMockForAbstractClass(ManagerInterface::class);
9898
$sessionMock = $this->getMockBuilder(Session::class)

app/code/Magento/Catalog/Test/Unit/Controller/Product/ViewTest.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
use Magento\Framework\App\RequestInterface;
1818
use Magento\Framework\Controller\Result\ForwardFactory;
1919
use Magento\Framework\DataObject;
20+
use Magento\Framework\Json\Helper\Data;
2021
use Magento\Framework\ObjectManager\ObjectManager;
2122
use Magento\Framework\View\Result\Page;
2223
use Magento\Framework\View\Result\PageFactory;
2324
use Magento\Store\Model\Store;
2425
use Magento\Store\Model\StoreManagerInterface;
2526
use PHPUnit\Framework\MockObject\MockObject;
2627
use PHPUnit\Framework\TestCase;
28+
use Psr\Log\LoggerInterface;
2729

2830
/**
2931
* Responsible for testing product view action on a strorefront.
@@ -82,6 +84,16 @@ class ViewTest extends TestCase
8284
*/
8385
protected $urlBuilder;
8486

87+
/**
88+
* @var LoggerInterface|MockObject
89+
*/
90+
protected $loggerMock;
91+
92+
/**
93+
* @var Data|MockObject
94+
*/
95+
protected $jsonHelperMock;
96+
8597
/**
8698
* @inheritDoc
8799
*/
@@ -92,7 +104,8 @@ protected function setUp(): void
92104
->getMock();
93105
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
94106
->disableOriginalConstructor()
95-
->setMethods(['isAjax', 'isPost', 'getParam'])
107+
->onlyMethods(['getParam'])
108+
->addMethods(['isAjax', 'isPost'])
96109
->getMockForAbstractClass();
97110
$contextMock->expects($this->any())
98111
->method('getRequest')
@@ -116,7 +129,7 @@ protected function setUp(): void
116129
->method('getResultRedirectFactory')
117130
->willReturn($resultRedirectFactoryMock);
118131
$this->urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
119-
->setMethods(['getUrl'])
132+
->onlyMethods(['getUrl'])
120133
->disableOriginalConstructor()
121134
->getMockForAbstractClass();
122135
$contextMock->expects($this->any())
@@ -147,13 +160,16 @@ protected function setUp(): void
147160
$storeMock = $this->createMock(Store::class);
148161
$this->storeManagerMock->method('getStore')->willReturn($storeMock);
149162

163+
$this->loggerMock = $this->createMock(LoggerInterface::class);
164+
$this->jsonHelperMock = $this->createMock(Data::class);
165+
150166
$this->view = new View(
151167
$contextMock,
152168
$viewHelperMock,
153169
$resultForwardFactoryMock,
154170
$this->resultPageFactoryMock,
155-
null,
156-
null,
171+
$this->loggerMock,
172+
$this->jsonHelperMock,
157173
$this->catalogDesignMock,
158174
$this->productRepositoryMock,
159175
$this->storeManagerMock

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ protected function _parentObjectConstructor()
581581
$this->_connection = $this->getMockForAbstractClass(AdapterInterface::class);
582582
$this->select = $this->getMockBuilder(Select::class)
583583
->disableOriginalConstructor()
584-
->setMethods(['from', 'where'])
584+
->onlyMethods(['from', 'where'])
585585
->getMock();
586586
$this->select->expects($this->any())->method('from')->willReturnSelf();
587587
//$this->select->expects($this->any())->method('where')->willReturnSelf();
@@ -741,7 +741,7 @@ public function testIsAttributeValidAssertAttrValid($attrParams, $rowData): void
741741
$attrCode = 'code';
742742
$rowNum = 0;
743743
$string = $this->getMockBuilder(StringUtils::class)
744-
->setMethods(null)->getMock();
744+
->onlyMethods([])->getMock();
745745
$this->setPropertyValue($this->importProduct, 'string', $string);
746746

747747
$this->validator->expects($this->once())->method('isAttributeValid')->willReturn(true);
@@ -759,7 +759,7 @@ public function testIsAttributeValidAssertAttrInvalid($attrParams, $rowData): vo
759759
$attrCode = 'code';
760760
$rowNum = 0;
761761
$string = $this->getMockBuilder(StringUtils::class)
762-
->setMethods(null)->getMock();
762+
->onlyMethods([])->getMock();
763763
$this->setPropertyValue($this->importProduct, 'string', $string);
764764

765765
$this->validator->expects($this->once())->method('isAttributeValid')->willReturn(false);
@@ -1089,7 +1089,7 @@ public function testGetCategoryProcessor(): void
10891089
/**
10901090
* @return array
10911091
*/
1092-
public function getStoreIdByCodeDataProvider(): array
1092+
public static function getStoreIdByCodeDataProvider(): array
10931093
{
10941094
return [
10951095
[
@@ -1131,10 +1131,6 @@ public function testValidateRowCheckSpecifiedSku($sku, $expectedError): void
11311131
->expects($this->once())
11321132
->method('getRowScope')
11331133
->willReturn(Product::SCOPE_STORE);
1134-
$importProduct
1135-
->method('addRowError')
1136-
->withConsecutive([$expectedError, $rowNum])
1137-
->willReturnOnConsecutiveCalls(null);
11381134

11391135
$importProduct->validateRow($rowData, $rowNum);
11401136
}
@@ -1689,7 +1685,7 @@ public function testGetProductCategoriesDataSave(array $categoriesData, string $
16891685
*
16901686
* @return array
16911687
*/
1692-
public function productCategoriesDataProvider()
1688+
public static function productCategoriesDataProvider()
16931689
{
16941690
return [
16951691
[
@@ -1722,7 +1718,7 @@ public function productCategoriesDataProvider()
17221718
*
17231719
* @return array
17241720
*/
1725-
public function fillUploaderObjectDataProvider(): array
1721+
public static function fillUploaderObjectDataProvider(): array
17261722
{
17271723
return [
17281724
[false, true, 'File directory \'pub/media/import\' is not readable.'],
@@ -1736,7 +1732,7 @@ public function fillUploaderObjectDataProvider(): array
17361732
*
17371733
* @return array
17381734
*/
1739-
public function uploadMediaFilesDataProvider(): array
1735+
public static function uploadMediaFilesDataProvider(): array
17401736
{
17411737
return [
17421738
['test1.jpg', false],
@@ -1747,7 +1743,7 @@ public function uploadMediaFilesDataProvider(): array
17471743
/**
17481744
* @return array
17491745
*/
1750-
public function getImagesFromRowDataProvider(): array
1746+
public static function getImagesFromRowDataProvider(): array
17511747
{
17521748
return [
17531749
[
@@ -1776,7 +1772,7 @@ public function getImagesFromRowDataProvider(): array
17761772
/**
17771773
* @return array
17781774
*/
1779-
public function validateRowValidateNewProductTypeAddRowErrorCallDataProvider(): array
1775+
public static function validateRowValidateNewProductTypeAddRowErrorCallDataProvider(): array
17801776
{
17811777
return [
17821778
[
@@ -1813,7 +1809,7 @@ public function validateRowValidateNewProductTypeAddRowErrorCallDataProvider():
18131809
/**
18141810
* @return array
18151811
*/
1816-
public function validateRowCheckSpecifiedSkuDataProvider(): array
1812+
public static function validateRowCheckSpecifiedSkuDataProvider(): array
18171813
{
18181814
return [
18191815
[
@@ -1834,7 +1830,7 @@ public function validateRowCheckSpecifiedSkuDataProvider(): array
18341830
/**
18351831
* @return array
18361832
*/
1837-
public function validateRowDataProvider(): array
1833+
public static function validateRowDataProvider(): array
18381834
{
18391835
return [
18401836
[
@@ -1869,7 +1865,7 @@ public function validateRowDataProvider(): array
18691865
/**
18701866
* @return array
18711867
*/
1872-
public function isAttributeValidAssertAttrValidDataProvider(): array
1868+
public static function isAttributeValidAssertAttrValidDataProvider(): array
18731869
{
18741870
return [
18751871
[
@@ -1942,7 +1938,7 @@ public function isAttributeValidAssertAttrValidDataProvider(): array
19421938
/**
19431939
* @return array
19441940
*/
1945-
public function isAttributeValidAssertAttrInvalidDataProvider(): array
1941+
public static function isAttributeValidAssertAttrInvalidDataProvider(): array
19461942
{
19471943
return [
19481944
[
@@ -2015,7 +2011,7 @@ public function isAttributeValidAssertAttrInvalidDataProvider(): array
20152011
/**
20162012
* @return array
20172013
*/
2018-
public function getRowScopeDataProvider(): array
2014+
public static function getRowScopeDataProvider(): array
20192015
{
20202016
$colSku = Product::COL_SKU;
20212017
$colStore = Product::COL_STORE;
@@ -2195,7 +2191,7 @@ protected function createModelMockWithErrorAggregator(
21952191
$methods[] = 'getErrorAggregator';
21962192
$importProduct = $this->getMockBuilder(Product::class)
21972193
->disableOriginalConstructor()
2198-
->setMethods($methods)
2194+
->onlyMethods($methods)
21992195
->getMock();
22002196
$errorMethods = array_keys($errorAggregatorMethods);
22012197
$errorAggregator = $this->getErrorAggregatorObject($errorMethods);
@@ -2224,7 +2220,7 @@ public function testParseMultiselectValues($value, $fieldSeparator, $valueSepara
22242220
/**
22252221
* @return array
22262222
*/
2227-
public function valuesDataProvider(): array
2223+
public static function valuesDataProvider(): array
22282224
{
22292225
return [
22302226
'pipeWithCustomFieldSeparator' => [

app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testGetConfig($isAutocomplete, $baseUrl, $registerUrl, $forgotUr
111111

112112
/** @var StoreInterface||\PHPUnit\Framework\MockObject\MockObject $storeMock */
113113
$storeMock = $this->getMockBuilder(StoreInterface::class)
114-
->setMethods(['getBaseUrl'])
114+
->addMethods(['getBaseUrl'])
115115
->getMockForAbstractClass();
116116

117117
$this->storeManagerMock->expects($this->any())
@@ -139,7 +139,7 @@ public function testGetConfig($isAutocomplete, $baseUrl, $registerUrl, $forgotUr
139139
/**
140140
* @return array
141141
*/
142-
public function dataProviderGetConfig()
142+
public static function dataProviderGetConfig()
143143
{
144144
return [
145145
[
@@ -226,7 +226,7 @@ public function testGetSerializedConfig(
226226

227227
/** @var StoreInterface||\PHPUnit\Framework\MockObject\MockObject $storeMock */
228228
$storeMock = $this->getMockBuilder(StoreInterface::class)
229-
->setMethods(['getBaseUrl'])
229+
->addMethods(['getBaseUrl'])
230230
->getMockForAbstractClass();
231231

232232
$this->storeManagerMock->expects($this->any())

0 commit comments

Comments
 (0)