@@ -56,60 +56,20 @@ public function setUp()
56
56
*/
57
57
public function testExecute ()
58
58
{
59
- $ storeMock = $ this ->createMock (\Magento \Store \Model \Store::class);
60
- $ storeMock ->expects ($ this ->once ())
61
- ->method ('getRootCategoryId ' )
62
- ->will ($ this ->returnValue (2 ));
63
-
64
59
$ websiteMock = $ this ->createMock (\Magento \Store \Model \Website::class);
65
- $ websiteMock ->expects ($ this ->once ())
66
- ->method ('getGroups ' )
67
- ->will ($ this ->returnValue ([$ storeMock ]));
68
60
$ websiteMock ->expects ($ this ->once ())
69
61
->method ('getId ' )
70
62
->will ($ this ->returnValue ('website_id ' ));
71
63
72
- $ contextMock = $ this ->createMock (\Magento \Framework \Model \ResourceModel \Db \Context::class);
73
- $ abstractDbMock = $ this ->getMockForAbstractClass (
74
- \Magento \Framework \Model \ResourceModel \Db \AbstractDb::class,
75
- [$ contextMock ],
76
- '' ,
77
- true ,
78
- true ,
79
- true ,
80
- ['getAllChildren ' ]
81
- );
82
- $ abstractDbMock ->expects ($ this ->once ())
83
- ->method ('getAllChildren ' )
84
- ->will ($ this ->returnValue ([1 ]));
85
-
86
64
$ storeManagerMock = $ this ->createMock (\Magento \Store \Model \StoreManager::class);
87
65
$ storeManagerMock ->expects ($ this ->once ())
88
66
->method ('getWebsites ' )
89
67
->will ($ this ->returnValue ([$ websiteMock ]));
90
68
91
- $ categoryMock = $ this ->createMock (\Magento \Catalog \Model \Category::class);
92
- $ categoryMock ->expects ($ this ->once ())
93
- ->method ('getResource ' )
94
- ->will ($ this ->returnValue ($ abstractDbMock ));
95
- $ categoryMock ->expects ($ this ->once ())
96
- ->method ('getPath ' )
97
- ->will ($ this ->returnValue ('path/to/file ' ));
98
- $ categoryMock ->expects ($ this ->once ())
99
- ->method ('getId ' )
100
- ->will ($ this ->returnValue ('category_id ' ));
101
-
102
- $ objectValueMap = [
103
- [\Magento \Catalog \Model \Category::class, $ categoryMock ]
104
- ];
105
-
106
69
$ objectManagerMock = $ this ->createMock (\Magento \Framework \ObjectManager \ObjectManager::class);
107
70
$ objectManagerMock ->expects ($ this ->once ())
108
71
->method ('create ' )
109
72
->will ($ this ->returnValue ($ storeManagerMock ));
110
- $ objectManagerMock ->expects ($ this ->once ())
111
- ->method ('get ' )
112
- ->will ($ this ->returnValueMap ($ objectValueMap ));
113
73
114
74
$ valueMap = [
115
75
['coupon_codes ' , 0 , 1 ]
@@ -120,7 +80,7 @@ public function testExecute()
120
80
->method ('getValue ' )
121
81
->will ($ this ->returnValueMap ($ valueMap ));
122
82
$ this ->fixtureModelMock
123
- ->expects ($ this ->exactly (2 ))
83
+ ->expects ($ this ->exactly (1 ))
124
84
->method ('getObjectManager ' )
125
85
->will ($ this ->returnValue ($ objectManagerMock ));
126
86
0 commit comments