Skip to content

Commit 0bb90ed

Browse files
committed
Merge branch 'MAGNIMEX-SPRINT2-UnitTestWithoutGeneration' into 'MAGNIMEX-SPRINT2'
Magnimex sprint2 unit test without generation See merge request !103
2 parents 8185f76 + bcd9a62 commit 0bb90ed

File tree

4 files changed

+81
-41
lines changed

4 files changed

+81
-41
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ protected function setUp()
7373
->method('getItemById')
7474
->will($this->returnValueMap($map));
7575

76-
$categoryColFactory = $this->getMockBuilder('Magento\Catalog\Model\Resource\Category\CollectionFactory')
77-
->disableOriginalConstructor()
78-
->getMock();
76+
$categoryColFactory = $this->getMock(
77+
'Magento\Catalog\Model\Resource\Category\CollectionFactory',
78+
['create'],
79+
[],
80+
'',
81+
false
82+
);
7983
$categoryColFactory->method('create')->will($this->returnValue($categoryCollection));
8084

8185
$categoryFactory = $this->getMockBuilder('Magento\Catalog\Model\CategoryFactory')

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ protected function setUp()
5050
'Magento\Tax\Model\Resource\TaxClass\Collection',
5151
[$taxClass]
5252
);
53-
$taxClassCollectionFactory = $this->getMockBuilder('Magento\Tax\Model\Resource\TaxClass\CollectionFactory')
54-
->disableOriginalConstructor()
55-
->getMock();
53+
$taxClassCollectionFactory = $this->getMock(
54+
'Magento\Tax\Model\Resource\TaxClass\CollectionFactory',
55+
['create'],
56+
[],
57+
'',
58+
false
59+
);
5660
$taxClassCollectionFactory->method('create')->will($this->returnValue($taxClassCollection));
5761

5862
$anotherTaxClass = $this->getMockBuilder('Magento\Tax\Model\ClassModel')
@@ -61,9 +65,13 @@ protected function setUp()
6165
$anotherTaxClass->method('getClassName')->will($this->returnValue(self::TEST_TAX_CLASS_NAME));
6266
$anotherTaxClass->method('getId')->will($this->returnValue(self::TEST_JUST_CREATED_TAX_CLASS_ID));
6367

64-
$taxClassFactory = $this->getMockBuilder('Magento\Tax\Model\ClassModelFactory')
65-
->disableOriginalConstructor()
66-
->getMock();
68+
$taxClassFactory = $this->getMock(
69+
'Magento\Tax\Model\ClassModelFactory',
70+
['create'],
71+
[],
72+
'',
73+
false
74+
);
6775
$taxClassFactory->method('create')->will($this->returnValue($anotherTaxClass));
6876

6977
$this->taxClassProcessor =

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

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -208,41 +208,62 @@ protected function setUp()
208208
$this->getMockBuilder('\Magento\ImportExport\Model\Import\Config')
209209
->disableOriginalConstructor()
210210
->getMock();
211-
$this->_resourceFactory =
212-
$this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceFactory')
213-
->disableOriginalConstructor()
214-
->getMock();
215-
$this->_setColFactory =
216-
$this->getMockBuilder('\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory')
217-
->disableOriginalConstructor()
218-
->getMock();
219-
$this->_productTypeFactory =
220-
$this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Product\Type\Factory')
221-
->disableOriginalConstructor()
222-
->getMock();
223-
$this->_linkFactory =
224-
$this->getMockBuilder('\Magento\Catalog\Model\Resource\Product\LinkFactory')
225-
->disableOriginalConstructor()
226-
->getMock();
227-
$this->_proxyProdFactory =
228-
$this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory')
229-
->disableOriginalConstructor()
230-
->getMock();
231-
$this->_uploaderFactory =
232-
$this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\UploaderFactory')
233-
->disableOriginalConstructor()
234-
->getMock();
211+
$this->_resourceFactory = $this->getMock(
212+
'\Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceFactory',
213+
['create'],
214+
[],
215+
'',
216+
false
217+
);
218+
$this->_setColFactory = $this->getMock(
219+
'\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory',
220+
['create'],
221+
[],
222+
'',
223+
false
224+
);
225+
$this->_productTypeFactory = $this->getMock(
226+
'\Magento\CatalogImportExport\Model\Import\Product\Type\Factory',
227+
['create'],
228+
[],
229+
'',
230+
false
231+
);
232+
$this->_linkFactory = $this->getMock(
233+
'\Magento\Catalog\Model\Resource\Product\LinkFactory',
234+
['create'],
235+
[],
236+
'',
237+
false
238+
);
239+
$this->_proxyProdFactory = $this->getMock(
240+
'\Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory',
241+
['create'],
242+
[],
243+
'',
244+
false
245+
);
246+
$this->_uploaderFactory = $this->getMock(
247+
'\Magento\CatalogImportExport\Model\Import\UploaderFactory',
248+
['create'],
249+
[],
250+
'',
251+
false
252+
);
235253
$this->_filesystem =
236254
$this->getMockBuilder('\Magento\Framework\Filesystem')
237255
->disableOriginalConstructor()
238256
->getMock();
239257
$this->_mediaDirectory =
240258
$this->getMockBuilder('\Magento\Framework\Filesystem\Directory\WriteInterface')
241259
->getMock();
242-
$this->_stockResItemFac =
243-
$this->getMockBuilder('\Magento\CatalogInventory\Model\Resource\Stock\ItemFactory')
244-
->disableOriginalConstructor()
245-
->getMock();
260+
$this->_stockResItemFac = $this->getMock(
261+
'\Magento\CatalogInventory\Model\Resource\Stock\ItemFactory',
262+
['create'],
263+
[],
264+
'',
265+
false
266+
);
246267
$this->_localeDate =
247268
$this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\TimezoneInterface')
248269
->getMock();
@@ -341,8 +362,13 @@ protected function setUp()
341362
*/
342363
protected function _objectConstructor()
343364
{
344-
$this->optionFactory = $this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Product\OptionFactory')
345-
->disableOriginalConstructor()->getMock();
365+
$this->optionFactory = $this->getMock(
366+
'\Magento\CatalogImportExport\Model\Import\Product\OptionFactory',
367+
['create'],
368+
[],
369+
'',
370+
false
371+
);
346372
$this->optionEntity = $this->getMockBuilder('\Magento\CatalogImportExport\Model\Import\Product\Option')
347373
->disableOriginalConstructor()->getMock();
348374
$this->optionFactory->expects($this->once())->method('create')->willReturn($this->optionEntity);

app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function setUp()
109109

110110
$this->attrCollectionFactory = $this->getMock(
111111
'Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory',
112-
[],
112+
['create'],
113113
[],
114114
'',
115115
false
@@ -122,7 +122,9 @@ protected function setUp()
122122
'',
123123
false
124124
);
125-
125+
$this->attrCollectionFactory->method('create')->will(
126+
$this->returnValue($this->attrCollection)
127+
);
126128
$superAttributes = [];
127129
foreach ($this->_getSuperAttributes() as $superAttribute) {
128130
$item = $this->getMock(

0 commit comments

Comments
 (0)