Skip to content

Commit f6c3836

Browse files
Andrei KuprienkaAndrei Kuprienka
authored andcommitted
MAGNIMEX-SPRINT2: Add lost php unit tests
replace MockBuilder with just getMock methods for collection classes fix cs for ZipTest.php, merge conficts
1 parent 4a1bf6d commit f6c3836

File tree

3 files changed

+81
-65
lines changed

3 files changed

+81
-65
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ 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+
);
83+
7984
$categoryColFactory->method('create')->will($this->returnValue($categoryCollection));
8085

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

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ 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+
54+
$taxClassCollectionFactory = $this->getMock(
55+
'Magento\Tax\Model\Resource\TaxClass\CollectionFactory',
56+
['create'],
57+
[],
58+
'',
59+
false
60+
);
61+
5662
$taxClassCollectionFactory->method('create')->will($this->returnValue($taxClassCollection));
5763

5864
$anotherTaxClass = $this->getMockBuilder('Magento\Tax\Model\ClassModel')
@@ -61,9 +67,14 @@ protected function setUp()
6167
$anotherTaxClass->method('getClassName')->will($this->returnValue(self::TEST_TAX_CLASS_NAME));
6268
$anotherTaxClass->method('getId')->will($this->returnValue(self::TEST_JUST_CREATED_TAX_CLASS_ID));
6369

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

6980
$this->taxClassProcessor =
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
<?php
2-
3-
/**
4-
* Copyright © 2015 Magento. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
7-
8-
namespace Magento\Framework\Archive\Test\Unit;
9-
10-
use Composer\Composer;
11-
12-
class ZipTest extends \PHPUnit_Framework_TestCase
13-
{
14-
15-
/**
16-
* @var \Magento\Framework\Archive\Zip|\PHPUnit_Framework_MockObject_MockObject
17-
*/
18-
protected $zip;
19-
20-
public function setUp()
21-
{
22-
$this->zip = $this->getMockBuilder('\Magento\Framework\Archive\Zip')
23-
->disableOriginalConstructor()
24-
->getMock();
25-
}
26-
27-
/**
28-
* Check constructor if no exceptions is thrown.
29-
*/
30-
public function testConstructorNoExceptions()
31-
{
32-
try{
33-
$reflectedClass = new \ReflectionClass('\Magento\Framework\Archive\Zip');
34-
$constructor = $reflectedClass->getConstructor();
35-
$constructor->invoke($this->zip, []);
36-
} catch (\Exception $e){
37-
$this->fail('Failed asserting that no exceptions is thrown');
38-
}
39-
}
40-
41-
/**
42-
* @depends testConstructorNoExceptions
43-
*/
44-
public function testPack()
45-
{
46-
$this->markTestSkipped('Method pack contains dependency on \ZipArchive object');
47-
}
48-
49-
/**
50-
* @depends testConstructorNoExceptions
51-
*/
52-
public function testUnpack()
53-
{
54-
$this->markTestSkipped('Method unpack contains dependency on \ZipArchive object');
55-
}
56-
}
1+
<?php
2+
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\Framework\Archive\Test\Unit;
9+
10+
use Composer\Composer;
11+
12+
class ZipTest extends \PHPUnit_Framework_TestCase
13+
{
14+
15+
/**
16+
* @var \Magento\Framework\Archive\Zip|\PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
protected $zip;
19+
20+
public function setUp()
21+
{
22+
$this->zip = $this->getMockBuilder('\Magento\Framework\Archive\Zip')
23+
->disableOriginalConstructor()
24+
->getMock();
25+
}
26+
27+
/**
28+
* Check constructor if no exceptions is thrown.
29+
*/
30+
public function testConstructorNoExceptions()
31+
{
32+
try {
33+
$reflectedClass = new \ReflectionClass('\Magento\Framework\Archive\Zip');
34+
$constructor = $reflectedClass->getConstructor();
35+
$constructor->invoke($this->zip, []);
36+
} catch (\Exception $e) {
37+
$this->fail('Failed asserting that no exceptions is thrown');
38+
}
39+
}
40+
41+
/**
42+
* @depends testConstructorNoExceptions
43+
*/
44+
public function testPack()
45+
{
46+
$this->markTestSkipped('Method pack contains dependency on \ZipArchive object');
47+
}
48+
49+
/**
50+
* @depends testConstructorNoExceptions
51+
*/
52+
public function testUnpack()
53+
{
54+
$this->markTestSkipped('Method unpack contains dependency on \ZipArchive object');
55+
}
56+
}

0 commit comments

Comments
 (0)