Skip to content

Commit 932b845

Browse files
author
Paliarush, Alexander(apaliarush)
committed
Merge pull request #325 from magento-api/develop
[API] Sprint 49 Bugfixes + Task
2 parents 183254f + 5afa00a commit 932b845

File tree

60 files changed

+473
-251
lines changed

Some content is hidden

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

60 files changed

+473
-251
lines changed

app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class UserConfigTest extends \PHPUnit_Framework_TestCase
1010
{
1111
public function testUserRequestCreation()
1212
{
13-
$factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', [], [], '', false);
13+
$factoryMock = $this->getMock('Magento\Config\Model\Config\Factory', ['create'], [], '', false);
1414
$responseMock = $this->getMock('Magento\Framework\App\Console\Response', [], [], '', false);
1515
$configMock = $this->getMock('Magento\Config\Model\Config', [], [], '', false);
1616

app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function setUp()
177177
);
178178
$this->orderFactoryMock = $this->getMock(
179179
'Magento\Sales\Model\OrderFactory',
180-
[],
180+
['create'],
181181
[],
182182
'',
183183
false

app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function setUp()
9494
->getMock();
9595
$this->backupModelFactoryMock = $this->getMockBuilder('Magento\Backup\Model\BackupFactory')
9696
->disableOriginalConstructor()
97+
->setMethods(['create'])
9798
->getMock();
9899
$this->backupModelMock = $this->getMockBuilder('Magento\Backup\Model\Backup')
99100
->disableOriginalConstructor()

app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected function setUp()
3535
{
3636
$this->optionListMock = $this->getMock('\Magento\Bundle\Model\Product\OptionList', [], [], '', false);
3737
$this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
38+
->setMethods(['create'])
3839
->disableOriginalConstructor()
3940
->getMock();
4041
$this->model = new \Magento\Bundle\Model\Plugin\BundleLoadOptions(

app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php

+16-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class PriceTest extends \PHPUnit_Framework_TestCase
6262
protected function setUp()
6363
{
6464
$this->ruleFactoryMock = $this->getMock(
65-
'\Magento\CatalogRule\Model\Resource\RuleFactory',
66-
[],
65+
'Magento\CatalogRule\Model\Resource\RuleFactory',
66+
['create'],
6767
[],
6868
'',
6969
false
@@ -77,8 +77,20 @@ protected function setUp()
7777
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')->getMock();
7878
$this->groupManagement = $this->getMockBuilder('Magento\Customer\Api\GroupManagementInterface')
7979
->getMockForAbstractClass();
80-
$gpFactory = $this->getMock('Magento\Catalog\Api\Data\ProductGroupPriceInterfaceFactory', [], [], '', false);
81-
$tpFactory = $this->getMock('Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory', [], [], '', false);
80+
$gpFactory = $this->getMock(
81+
'Magento\Catalog\Api\Data\ProductGroupPriceInterfaceFactory',
82+
['create'],
83+
[],
84+
'',
85+
false
86+
);
87+
$tpFactory = $this->getMock(
88+
'Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory',
89+
['create'],
90+
[],
91+
'',
92+
false
93+
);
8294
$scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
8395

8496
$objectManagerHelper = new ObjectManagerHelper($this);

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ protected function setUp()
105105
->disableOriginalConstructor()
106106
->getMockForAbstractClass();
107107
$this->bundleModelSelection = $this->getMockBuilder('Magento\Bundle\Model\SelectionFactory')
108+
->setMethods(['create'])
108109
->disableOriginalConstructor()
109110
->getMock();
110111
$this->bundleFactory = $this->getMockBuilder('\Magento\Bundle\Model\Resource\BundleFactory')
112+
->setMethods(['create'])
111113
->disableOriginalConstructor()
112114
->getMock();
113115
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testGetCaptcha()
7171
new \Magento\Captcha\Model\DefaultModel(
7272
$this->getMock('Magento\Framework\Session\SessionManager', [], [], '', false),
7373
$this->getMock('Magento\Captcha\Helper\Data', [], [], '', false),
74-
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', [], [], '', false),
74+
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', ['create'], [], '', false),
7575
'user_create'
7676
)
7777
)

app/code/Magento/Captcha/Test/Unit/Model/CronTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function setUp()
6969
);
7070

7171
$this->_model = new \Magento\Captcha\Model\Cron(
72-
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', [], [], '', false),
72+
$this->getMock('Magento\Captcha\Model\Resource\LogFactory', ['create'], [], '', false),
7373
$this->_helper,
7474
$this->_adminHelper,
7575
$this->_filesystem,

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Category/Edit/FormTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function setUp()
8282
);
8383
$this->categoryFactoryMock = $this->getMock(
8484
'Magento\Catalog\Model\CategoryFactory',
85-
[],
85+
['create'],
8686
[],
8787
'',
8888
false

app/code/Magento/Catalog/Test/Unit/Block/Product/View/OptionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testGetOptionHtml()
5959

6060
$optValFactoryMock = $this->getMock(
6161
'Magento\Catalog\Model\Product\Option\ValueFactory',
62-
[],
62+
['create'],
6363
[],
6464
'',
6565
false

app/code/Magento/Catalog/Test/Unit/Controller/Product/Compare/IndexTest.php

+18-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class IndexTest extends \PHPUnit_Framework_TestCase
6969

7070
protected function setUp()
7171
{
72-
$this->contextMock = $this->getMock('Magento\Framework\App\Action\Context',
72+
$this->contextMock = $this->getMock(
73+
'Magento\Framework\App\Action\Context',
7374
['getRequest', 'getResponse', 'getResultRedirectFactory'],
7475
[],
7576
'',
@@ -90,10 +91,16 @@ protected function setUp()
9091
->method('getResultRedirectFactory')
9192
->willReturn($this->redirectFactoryMock);
9293

93-
$this->itemFactoryMock = $this->getMock('Magento\Catalog\Model\Product\Compare\ItemFactory', [], [], '', false);
94+
$this->itemFactoryMock = $this->getMock(
95+
'Magento\Catalog\Model\Product\Compare\ItemFactory',
96+
['create'],
97+
[],
98+
'',
99+
false
100+
);
94101
$this->collectionFactoryMock = $this->getMock(
95102
'Magento\Catalog\Model\Resource\Product\Compare\Item\CollectionFactory',
96-
[],
103+
['create'],
97104
[],
98105
'',
99106
false
@@ -131,10 +138,12 @@ public function testExecute()
131138
$beforeUrl = 'test_url';
132139
$this->request->expects($this->any())
133140
->method('getParam')
134-
->willReturnMap([
141+
->willReturnMap(
142+
[
135143
['items', null, null],
136144
['uenc', null, $beforeUrl],
137-
]);
145+
]
146+
);
138147
$this->decoderMock->expects($this->once())
139148
->method('decode')
140149
->with($beforeUrl)
@@ -152,10 +161,12 @@ public function testExecuteWithItems()
152161
{
153162
$this->request->expects($this->any())
154163
->method('getParam')
155-
->willReturnMap([
164+
->willReturnMap(
165+
[
156166
['items', null, '1,2,3'],
157167
['uenc', null, null],
158-
]);
168+
]
169+
);
159170
$this->decoderMock->expects($this->never())->method('decode');
160171
$this->catalogSession->expects($this->never())->method('setBeforeCompareUrl');
161172

app/code/Magento/Catalog/Test/Unit/Helper/Product/Flat/IndexerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ public function setUp()
6565

6666
$resourceConfigFactoryMock = $this->getMock(
6767
'Magento\Catalog\Model\Resource\ConfigFactory',
68-
[],
68+
['create'],
6969
[],
7070
'',
7171
false
7272
);
7373

74-
$eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', [], [], '', false);
74+
$eavFactoryMock = $this->getMock('Magento\Eav\Model\Entity\AttributeFactory', ['create'], [], '', false);
7575

7676
$this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface');
7777

app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ protected function setUp()
141141
->disableOriginalConstructor()
142142
->getMock();
143143
$this->typeFactoryMock = $this->getMockBuilder('Magento\Eav\Model\Entity\TypeFactory')
144+
->setMethods(['create'])
144145
->disableOriginalConstructor()
145146
->getMock();
146147
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
@@ -153,6 +154,7 @@ protected function setUp()
153154
->getMock();
154155
$this->attributeOptionFactoryMock =
155156
$this->getMockBuilder('Magento\Eav\Api\Data\AttributeOptionInterfaceFactory')
157+
->setMethods(['create'])
156158
->disableOriginalConstructor()
157159
->getMock();
158160
$this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor')

app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php

+20-11
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,26 @@ public function setUp()
6666

6767
$layerResolver = $this->_getCleanMock('Magento\Catalog\Model\Layer\Resolver');
6868
$layerResolver->expects($this->once())->method('get')->willReturn(null);
69-
$this->_observer = (new ObjectManager($this))->getObject('Magento\Catalog\Model\Observer', [
70-
'categoryResource' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Category'),
71-
'catalogProduct' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Product'),
72-
'storeManager' => $this->_storeManager,
73-
'layerResolver' => $layerResolver,
74-
'indexIndexer' => $this->_getCleanMock('\Magento\Index\Model\Indexer'),
75-
'catalogCategory' => $this->_catalogCategory,
76-
'catalogData' => $this->_getCleanMock('\Magento\Catalog\Helper\Data'),
77-
'categoryFlatState' => $this->_categoryFlatState,
78-
'productResourceFactory' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\ProductFactory'),
79-
]);
69+
$this->_observer = (new ObjectManager($this))->getObject(
70+
'Magento\Catalog\Model\Observer',
71+
[
72+
'categoryResource' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Category'),
73+
'catalogProduct' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Product'),
74+
'storeManager' => $this->_storeManager,
75+
'layerResolver' => $layerResolver,
76+
'indexIndexer' => $this->_getCleanMock('\Magento\Index\Model\Indexer'),
77+
'catalogCategory' => $this->_catalogCategory,
78+
'catalogData' => $this->_getCleanMock('\Magento\Catalog\Helper\Data'),
79+
'categoryFlatState' => $this->_categoryFlatState,
80+
'productResourceFactory' => $this->getMock(
81+
'Magento\Catalog\Model\Resource\ProductFactory',
82+
['create'],
83+
[],
84+
'',
85+
false
86+
)
87+
]
88+
);
8089
}
8190

8291
/**

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/Backend/GroupPrice/AbstractTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp()
2424
$this->_helper = $this->getMock('Magento\Catalog\Helper\Data', ['isPriceGlobal'], [], '', false);
2525
$this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
2626

27-
$currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', [], [], '', false);
27+
$currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', ['create'], [], '', false);
2828
$storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
2929
$productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', [], [], '', false);
3030
$configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');

app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function setUp()
8383
->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4]));
8484
$this->validatorFactoryMock = $this->getMock(
8585
'Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory',
86-
[],
86+
['create'],
8787
[],
8888
'',
8989
false);

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ protected function setUp()
201201
->disableOriginalConstructor()->getMock();
202202
$this->mimeTypeExtensionMapMock =
203203
$this->getMockBuilder('Magento\Catalog\Model\Product\Gallery\MimeTypeExtensionMap')->getMock();
204-
$this->contentFactoryMock = $this->getMockBuilder(
205-
'Magento\Framework\Api\Data\ImageContentInterfaceFactory'
206-
)->disableOriginalConstructor()->setMethods(['create'])->getMockForAbstractClass();
204+
$this->contentFactoryMock = $this->getMock('Magento\Framework\Api\Data\ImageContentInterfaceFactory', ['create'], [], '', false);
207205
$this->contentValidatorMock = $this->getMockBuilder('Magento\Framework\Api\ImageContentValidatorInterface')
208206
->disableOriginalConstructor()
209207
->getMock();

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function setUp()
3838
);
3939
$attrSetColFactory = $this->getMock(
4040
'\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory',
41-
[],
41+
['create'],
4242
[],
4343
'',
4444
false
@@ -52,7 +52,7 @@ protected function setUp()
5252
);
5353
$attrColFactory = $this->getMock(
5454
'\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory',
55-
[],
55+
['create'],
5656
[],
5757
'',
5858
false

app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected function setUp()
3535
{
3636
$stockRegistryMock = $this->getMock('\Magento\CatalogInventory\Api\StockRegistryInterface');
3737
$this->productExtensionFactoryMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
38+
->setMethods(['create'])
3839
->disableOriginalConstructor()
3940
->getMock();
4041

app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ protected function setUp()
5151
false
5252
);
5353
$countryCollectionFactoryMock = $this->getMock(
54-
'\Magento\Directory\Model\Resource\Country\CollectionFactory',
55-
[],
54+
'Magento\Directory\Model\Resource\Country\CollectionFactory',
55+
['create'],
5656
[],
5757
'',
5858
false
5959
);
6060
$regionCollectionFactoryMock = $this->getMock(
61-
'\Magento\Directory\Model\Resource\Region\CollectionFactory',
62-
[],
61+
'Magento\Directory\Model\Resource\Region\CollectionFactory',
62+
['create'],
6363
[],
6464
'',
6565
false

app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ public function setUp()
3838
*/
3939
public function testGetLastRealOrder($orderId, $incrementId, $orderMock)
4040
{
41-
$orderFactory = $this->getMockBuilder(
42-
'Magento\Sales\Model\OrderFactory'
43-
)->disableOriginalConstructor()->setMethods(
44-
['create']
45-
)->getMock();
41+
$orderFactory = $this->getMockBuilder('Magento\Sales\Model\OrderFactory')
42+
->disableOriginalConstructor()
43+
->setMethods(['create'])
44+
->getMock();
4645
$orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock));
4746

48-
$messageCollectionFactory = $this->getMockBuilder(
49-
'Magento\Framework\Message\CollectionFactory'
50-
)->disableOriginalConstructor()->getMock();
51-
$quoteRepository = $this->getMockBuilder(
52-
'Magento\Quote\Model\QuoteRepository'
53-
)->disableOriginalConstructor()->getMock();
47+
$messageCollectionFactory = $this->getMockBuilder('Magento\Framework\Message\CollectionFactory')
48+
->disableOriginalConstructor()
49+
->setMethods(['create'])
50+
->getMock();
51+
$quoteRepository = $this->getMockBuilder('Magento\Quote\Model\QuoteRepository')
52+
->disableOriginalConstructor()
53+
->getMock();
5454

5555
$appState = $this->getMock('\Magento\Framework\App\State', [], [], '', false);
5656
$appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
@@ -323,7 +323,7 @@ public function testReplaceQuote()
323323
$quoteIdMaskMock->expects($this->once())->method('setQuoteId')->with($replaceQuoteId)->willReturnSelf();
324324
$quoteIdMaskMock->expects($this->once())->method('save');
325325

326-
$quoteIdMaskFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteIdMaskFactory', [], [], '', false);
326+
$quoteIdMaskFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteIdMaskFactory', ['create'], [], '', false);
327327
$quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock);
328328

329329
$session = $this->_helper->getObject(

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function setUp()
165165

166166
$this->_storageCollectionFactoryMock = $this->getMock(
167167
'Magento\Cms\Model\Wysiwyg\Images\Storage\CollectionFactory',
168-
[],
168+
['create'],
169169
[],
170170
'',
171171
false

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/AfterProductLoadTest.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ class AfterProductLoadTest extends \PHPUnit_Framework_TestCase
3737

3838
protected function setUp()
3939
{
40-
$this->optionValueFactory = $this->getMockBuilder(
41-
'\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory'
42-
)->disableOriginalConstructor()->getMock();
40+
$this->optionValueFactory = $this->getMock(
41+
'\Magento\ConfigurableProduct\Api\Data\OptionValueInterfaceFactory',
42+
['create'],
43+
[],
44+
'',
45+
false
46+
);
4347
$this->productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
4448
->disableOriginalConstructor()
4549
->getMock();
@@ -54,6 +58,7 @@ protected function setUp()
5458
->method('getTypeInstance')
5559
->willReturn($this->configurableProductTypeInstanceMock);
5660
$this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory')
61+
->setMethods(['create'])
5762
->disableOriginalConstructor()
5863
->getMock();
5964

0 commit comments

Comments
 (0)