@@ -16,11 +16,6 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase
16
16
*/
17
17
protected $ model ;
18
18
19
- /**
20
- * @var \PHPUnit_Framework_MockObject_MockObject
21
- */
22
- protected $ storeManagerMock ;
23
-
24
19
/**
25
20
* @var \PHPUnit_Framework_MockObject_MockObject
26
21
*/
@@ -48,7 +43,6 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase
48
43
49
44
protected function setUp ()
50
45
{
51
- $ this ->storeManagerMock = $ this ->getMock ('\Magento\Store\Model\StoreManagerInterface ' );
52
46
$ this ->productRepositoryMock = $ this ->getMock ('\Magento\Catalog\Api\ProductRepositoryInterface ' );
53
47
$ this ->contentValidatorMock = $ this ->getMock ('\Magento\Framework\Api\ImageContentValidatorInterface ' );
54
48
$ this ->productMock = $ this ->getMock (
@@ -69,7 +63,6 @@ protected function setUp()
69
63
$ this ->mediaGalleryEntryMock =
70
64
$ this ->getMock ('Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
71
65
$ this ->model = new \Magento \Catalog \Model \Product \Gallery \GalleryManagement (
72
- $ this ->storeManagerMock ,
73
66
$ this ->productRepositoryMock ,
74
67
$ this ->contentValidatorMock
75
68
);
@@ -78,17 +71,6 @@ protected function setUp()
78
71
->getMock ();
79
72
}
80
73
81
- /**
82
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
83
- * @expectedExceptionMessage There is no store with provided ID.
84
- */
85
- public function testCreateWithNoStoreException ()
86
- {
87
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )
88
- ->willThrowException (new \Exception ());
89
- $ this ->model ->create ('sku ' , $ this ->mediaGalleryEntryMock );
90
- }
91
-
92
74
/**
93
75
* @expectedException \Magento\Framework\Exception\InputException
94
76
* @expectedExceptionMessage The image content is not valid.
@@ -100,13 +82,10 @@ public function testCreateWithInvalidImageException()
100
82
->getMock ();
101
83
$ this ->mediaGalleryEntryMock ->expects ($ this ->any ())->method ('getContent ' )->willReturn ($ entryContentMock );
102
84
103
- $ storeId = 0 ;
104
-
105
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
106
85
$ this ->contentValidatorMock ->expects ($ this ->once ())->method ('isValid ' )->with ($ entryContentMock )
107
86
->willReturn (false );
108
87
109
- $ this ->model ->create ("sku " , $ this ->mediaGalleryEntryMock , $ storeId );
88
+ $ this ->model ->create ("sku " , $ this ->mediaGalleryEntryMock );
110
89
}
111
90
112
91
/**
@@ -120,20 +99,17 @@ public function testCreateWithCannotSaveException()
120
99
->disableOriginalConstructor ()
121
100
->getMock ();;
122
101
$ this ->mediaGalleryEntryMock ->expects ($ this ->any ())->method ('getContent ' )->willReturn ($ entryContentMock );
123
-
124
- $ storeId = 0 ;
125
102
$ this ->productRepositoryMock ->expects ($ this ->once ())
126
103
->method ('get ' )
127
104
->with ($ productSku )
128
105
->willReturn ($ this ->productMock );
129
106
130
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
131
107
$ this ->contentValidatorMock ->expects ($ this ->once ())->method ('isValid ' )->with ($ entryContentMock )
132
108
->willReturn (true );
133
109
134
110
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('save ' )->with ($ this ->productMock )
135
111
->willThrowException (new \Exception ());
136
- $ this ->model ->create ($ productSku , $ this ->mediaGalleryEntryMock , $ storeId );
112
+ $ this ->model ->create ($ productSku , $ this ->mediaGalleryEntryMock );
137
113
}
138
114
139
115
public function testCreate ()
@@ -144,8 +120,6 @@ public function testCreate()
144
120
);
145
121
$ this ->mediaGalleryEntryMock ->expects ($ this ->any ())->method ('getContent ' )->willReturn ($ entryContentMock );
146
122
147
- $ storeId = 0 ;
148
-
149
123
$ this ->productRepositoryMock ->expects ($ this ->once ())
150
124
->method ('get ' )
151
125
->with ($ productSku )
@@ -155,7 +129,6 @@ public function testCreate()
155
129
->with ($ this ->productMock )
156
130
->willReturn ($ this ->productMock );
157
131
158
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
159
132
$ this ->contentValidatorMock ->expects ($ this ->once ())->method ('isValid ' )->with ($ entryContentMock )
160
133
->willReturn (true );
161
134
@@ -166,21 +139,7 @@ public function testCreate()
166
139
$ this ->productMock ->expects ($ this ->once ())->method ('setMediaGalleryEntries ' )
167
140
->with ([$ this ->mediaGalleryEntryMock ]);
168
141
169
- $ this ->assertEquals (42 , $ this ->model ->create ($ productSku , $ this ->mediaGalleryEntryMock , $ storeId ));
170
- }
171
-
172
- /**
173
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
174
- * @expectedExceptionMessage There is no store with provided ID.
175
- */
176
- public function testUpdateWithNonExistingStore ()
177
- {
178
- $ productSku = 'testProduct ' ;
179
- $ entryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
180
- $ storeId = 0 ;
181
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId )
182
- ->willThrowException (new \Exception ());
183
- $ this ->model ->update ($ productSku , $ entryMock , $ storeId );
142
+ $ this ->assertEquals (42 , $ this ->model ->create ($ productSku , $ this ->mediaGalleryEntryMock ));
184
143
}
185
144
186
145
/**
@@ -191,17 +150,15 @@ public function testUpdateWithNonExistingImage()
191
150
{
192
151
$ productSku = 'testProduct ' ;
193
152
$ entryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
194
- $ storeId = 0 ;
195
153
$ entryId = 42 ;
196
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
197
154
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('get ' )->with ($ productSku )
198
155
->willReturn ($ this ->productMock );
199
156
$ existingEntryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
200
157
$ existingEntryMock ->expects ($ this ->once ())->method ('getId ' )->willReturn (43 );
201
158
$ this ->productMock ->expects ($ this ->once ())->method ('getMediaGalleryEntries ' )
202
159
->willReturn ([$ existingEntryMock ]);
203
160
$ entryMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ entryId );
204
- $ this ->model ->update ($ productSku , $ entryMock, $ storeId );
161
+ $ this ->model ->update ($ productSku , $ entryMock );
205
162
}
206
163
207
164
/**
@@ -212,29 +169,24 @@ public function testUpdateWithCannotSaveException()
212
169
{
213
170
$ productSku = 'testProduct ' ;
214
171
$ entryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
215
- $ storeId = 0 ;
216
172
$ entryId = 42 ;
217
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
218
173
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('get ' )->with ($ productSku )
219
174
->willReturn ($ this ->productMock );
220
175
$ existingEntryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
221
176
$ existingEntryMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ entryId );
222
177
$ this ->productMock ->expects ($ this ->once ())->method ('getMediaGalleryEntries ' )
223
178
->willReturn ([$ existingEntryMock ]);
224
179
$ entryMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ entryId );
225
- $ this ->productMock ->expects ($ this ->once ())->method ('setStoreId ' )->with ($ storeId );
226
180
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('save ' )->with ($ this ->productMock )
227
181
->willThrowException (new \Exception ());
228
- $ this ->model ->update ($ productSku , $ entryMock, $ storeId );
182
+ $ this ->model ->update ($ productSku , $ entryMock );
229
183
}
230
184
231
185
public function testUpdate ()
232
186
{
233
187
$ productSku = 'testProduct ' ;
234
188
$ entryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
235
- $ storeId = 0 ;
236
189
$ entryId = 42 ;
237
- $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->with ($ storeId );
238
190
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('get ' )->with ($ productSku )
239
191
->willReturn ($ this ->productMock );
240
192
$ existingEntryMock = $ this ->getMock ('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface ' );
@@ -245,9 +197,8 @@ public function testUpdate()
245
197
246
198
$ this ->productMock ->expects ($ this ->once ())->method ('setMediaGalleryEntries ' )
247
199
->willReturn ([$ entryMock ]);
248
- $ this ->productMock ->expects ($ this ->once ())->method ('setStoreId ' )->with ($ storeId );
249
200
$ this ->productRepositoryMock ->expects ($ this ->once ())->method ('save ' )->with ($ this ->productMock );
250
- $ this ->assertTrue ($ this ->model ->update ($ productSku , $ entryMock, $ storeId ));
201
+ $ this ->assertTrue ($ this ->model ->update ($ productSku , $ entryMock ));
251
202
}
252
203
253
204
/**
0 commit comments