@@ -17,55 +17,20 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase
17
17
*/
18
18
protected $ _resourceMock ;
19
19
20
- /**
21
- * @var \Magento\Catalog\Model\CategoryFactory|\PHPUnit_Framework_MockObject_MockObject
22
- */
23
- protected $ _categoryFactoryMock ;
24
-
25
- /**
26
- * @var \Magento\Catalog\Model\Resource\Category\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
27
- */
28
- protected $ _categoryCollectionFactoryMock ;
29
-
30
- /**
31
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
32
- */
33
- protected $ _storeManagerMock ;
34
-
35
- /**
36
- * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject
37
- */
38
- protected $ _catalogConfigMock ;
39
-
40
- /**
41
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
42
- */
43
- protected $ _eventManagerMock ;
44
20
45
21
protected function setUp ()
46
22
{
47
23
$ this ->_resourceMock = $ this ->getMockBuilder ('Magento\Framework\App\Resource ' )
48
24
->disableOriginalConstructor ()
49
25
->getMock ();
50
- $ this ->_categoryFactoryMock = $ this ->getMockBuilder ('Magento\Catalog\Model\CategoryFactory ' )
51
- ->disableOriginalConstructor ()
52
- ->getMock ();
53
- $ this ->_categoryCollectionFactoryMock = $ this ->getMockBuilder (
54
- 'Magento\Catalog\Model\Resource\Category\CollectionFactory '
55
- )->disableOriginalConstructor ()->getMock ();
56
- $ this ->_storeManagerMock = $ this ->getMock ('Magento\Store\Model\StoreManagerInterface ' );
57
- $ this ->_catalogConfigMock = $ this ->getMockBuilder ('Magento\Catalog\Model\Config ' )
58
- ->disableOriginalConstructor ()
59
- ->getMock ();
60
- $ this ->_eventManagerMock = $ this ->getMock ('Magento\Framework\Event\ManagerInterface ' );
61
-
62
- $ this ->model = new \Magento \Indexer \Model \Resource \AbstractResourceStub (
63
- $ this ->_resourceMock ,
64
- $ this ->_categoryFactoryMock ,
65
- $ this ->_categoryCollectionFactoryMock ,
66
- $ this ->_storeManagerMock ,
67
- $ this ->_catalogConfigMock ,
68
- $ this ->_eventManagerMock
26
+
27
+ $ objectManager = new \Magento \TestFramework \Helper \ObjectManager ($ this );
28
+ $ arguments = $ objectManager ->getConstructArguments ('\Magento\Indexer\Model\Resource\AbstractResourceStub ' ,
29
+ ['resource ' => $ this ->_resourceMock ]
30
+ );
31
+ $ this ->model = $ objectManager ->getObject (
32
+ '\Magento\Indexer\Model\Resource\AbstractResourceStub ' ,
33
+ $ arguments
69
34
);
70
35
}
71
36
@@ -86,9 +51,7 @@ public function testUseIdxTable()
86
51
public function testClearTemporaryIndexTable ()
87
52
{
88
53
$ connectionMock = $ this ->getMock ('Magento\Framework\DB\Adapter\AdapterInterface ' , [], [], '' , false );
89
- $ storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , [], [], '' , false );
90
54
$ this ->_resourceMock ->expects ($ this ->any ())->method ('getConnection ' )->will ($ this ->returnValue ($ connectionMock ));
91
- $ this ->_storeManagerMock ->expects ($ this ->any ())->method ('getStore ' )->will ($ this ->returnValue ($ storeMock ));
92
55
$ connectionMock ->expects ($ this ->once ())->method ('delete ' )->will ($ this ->returnSelf ());
93
56
$ this ->model ->clearTemporaryIndexTable ();
94
57
}
@@ -101,7 +64,6 @@ public function testSyncData()
101
64
102
65
$ selectMock = $ this ->getMock ('Magento\Framework\DB\Select ' , [], [], '' , false );
103
66
$ connectionMock = $ this ->getMock ('Magento\Framework\DB\Adapter\AdapterInterface ' , [], [], '' , false );
104
- $ storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , [], [], '' , false );
105
67
106
68
$ connectionMock ->expects ($ this ->any ())->method ('describeTable ' )->will ($ this ->returnValue ($ describeTable ));
107
69
$ connectionMock ->expects ($ this ->any ())->method ('select ' )->will ($ this ->returnValue ($ selectMock ));
@@ -112,7 +74,6 @@ public function testSyncData()
112
74
$ resultColumns
113
75
)->will ($ this ->returnSelf ());
114
76
115
- $ this ->_storeManagerMock ->expects ($ this ->any ())->method ('getStore ' )->will ($ this ->returnValue ($ storeMock ));
116
77
$ this ->_resourceMock ->expects ($ this ->any ())->method ('getConnection ' )->will ($ this ->returnValue ($ connectionMock ));
117
78
$ this ->_resourceMock ->expects ($ this ->any ())->method ('getTableName ' )->will ($ this ->returnArgument (0 ));
118
79
@@ -147,13 +108,11 @@ public function testInsertFromTable($readToIndex)
147
108
148
109
$ selectMock = $ this ->getMock ('Magento\Framework\DB\Select ' , [], [], '' , false );
149
110
$ connectionMock = $ this ->getMock ('Magento\Framework\DB\Adapter\AdapterInterface ' , [], [], '' , false );
150
- $ storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , [], [], '' , false );
151
111
152
112
$ connectionMock ->expects ($ this ->any ())->method ('describeTable ' )->will ($ this ->returnValue ($ tableColumns ));
153
113
$ connectionMock ->expects ($ this ->any ())->method ('select ' )->will ($ this ->returnValue ($ selectMock ));
154
114
$ selectMock ->expects ($ this ->any ())->method ('from ' )->will ($ this ->returnSelf ());
155
115
156
- $ this ->_storeManagerMock ->expects ($ this ->any ())->method ('getStore ' )->will ($ this ->returnValue ($ storeMock ));
157
116
if ($ readToIndex ) {
158
117
$ connectionCustomMock = $ this ->getMock (
159
118
'Magento\Framework\DB\Adapter\CustomAdapterInterface ' ,
0 commit comments