9
9
use Magento \Catalog \Api \CategoryRepositoryInterface ;
10
10
use Magento \Catalog \Api \Data \CategoryProductLinkInterface ;
11
11
use Magento \Catalog \Api \ProductRepositoryInterface ;
12
- use Magento \Catalog \Model \CategoryLinkRepository ;
13
- use Magento \Catalog \Model \ResourceModel \Product ;
14
12
use Magento \Catalog \Model \Category ;
13
+ use Magento \Catalog \Model \CategoryLinkRepository ;
15
14
use Magento \Catalog \Model \Product as ProductModel ;
15
+ use Magento \Catalog \Model \ResourceModel \Product ;
16
+ use Magento \Framework \Exception \CouldNotSaveException ;
17
+ use Magento \Framework \Exception \InputException ;
18
+ use PHPUnit_Framework_MockObject_MockObject as MockObject ;
16
19
17
20
/**
18
21
* Test for \Magento\Catalog\Model\CategoryLinkRepository
@@ -24,27 +27,27 @@ class CategoryLinkRepositoryTest extends \PHPUnit\Framework\TestCase
24
27
/**
25
28
* @var CategoryLinkRepository
26
29
*/
27
- protected $ model ;
30
+ private $ model ;
28
31
29
32
/**
30
- * @var CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
33
+ * @var CategoryRepositoryInterface|MockObject
31
34
*/
32
- protected $ categoryRepositoryMock ;
35
+ private $ categoryRepositoryMock ;
33
36
34
37
/**
35
- * @var ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
38
+ * @var ProductRepositoryInterface|MockObject
36
39
*/
37
- protected $ productRepositoryMock ;
40
+ private $ productRepositoryMock ;
38
41
39
42
/**
40
- * @var CategoryProductLinkInterface|\PHPUnit_Framework_MockObject_MockObject
43
+ * @var CategoryProductLinkInterface|MockObject
41
44
*/
42
- protected $ productLinkMock ;
45
+ private $ productLinkMock ;
43
46
44
47
/**
45
- * @var Product|\PHPUnit_Framework_MockObject_MockObject
48
+ * @var Product|MockObject
46
49
*/
47
- protected $ productResourceMock ;
50
+ private $ productResourceMock ;
48
51
49
52
/**
50
53
* Initialize required data
@@ -126,7 +129,7 @@ public function testSaveWithCouldNotSaveException(): void
126
129
$ categoryMock ->expects ($ this ->once ())->method ('save ' )->willThrowException (new \Exception ());
127
130
128
131
$ this ->expectExceptionMessage ('Could not save product "55" with position 1 to category 42 ' );
129
- $ this ->expectException (\ Magento \ Framework \ Exception \ CouldNotSaveException::class);
132
+ $ this ->expectException (CouldNotSaveException::class);
130
133
$ this ->model ->save ($ this ->productLinkMock );
131
134
}
132
135
@@ -185,7 +188,7 @@ public function testDeleteByIdsWithCouldNotSaveException(): void
185
188
$ categoryMock ->expects ($ this ->once ())->method ('save ' )->willThrowException (new \Exception ());
186
189
187
190
$ this ->expectExceptionMessage ('Could not save product "55" with position 1 to category 42 ' );
188
- $ this ->expectException (\ Magento \ Framework \ Exception \ CouldNotSaveException::class);
191
+ $ this ->expectException (CouldNotSaveException::class);
189
192
$ this ->model ->deleteByIds ($ categoryId , $ productSku );
190
193
}
191
194
@@ -216,7 +219,7 @@ public function testDeleteWithInputException(): void
216
219
$ categoryMock ->expects ($ this ->never ())->method ('save ' );
217
220
218
221
$ this ->expectExceptionMessage ('The category doesn \'t contain the specified product. ' );
219
- $ this ->expectException (\ Magento \ Framework \ Exception \ InputException::class);
222
+ $ this ->expectException (InputException::class);
220
223
$ this ->assertTrue ($ this ->model ->delete ($ this ->productLinkMock ));
221
224
}
222
225
@@ -293,7 +296,7 @@ public function testDeleteBySkusWithInputException(): void
293
296
->willReturn ($ categoryMock );
294
297
295
298
$ this ->expectExceptionMessage ('The category doesn \'t contain the specified products. ' );
296
- $ this ->expectException (\ Magento \ Framework \ Exception \ InputException::class);
299
+ $ this ->expectException (InputException::class);
297
300
$ this ->model ->deleteBySkus ($ categoryId , [$ productSku ]);
298
301
}
299
302
@@ -322,7 +325,7 @@ public function testDeleteSkusIdsWithCouldNotSaveException(): void
322
325
$ categoryMock ->expects ($ this ->once ())->method ('save ' )->willThrowException (new \Exception ());
323
326
324
327
$ this ->expectExceptionMessage ('Could not save products "testSku" to category 42 ' );
325
- $ this ->expectException (\ Magento \ Framework \ Exception \ CouldNotSaveException::class);
328
+ $ this ->expectException (CouldNotSaveException::class);
326
329
$ this ->assertTrue ($ this ->model ->deleteBySkus ($ categoryId , [$ productSku ]));
327
330
}
328
331
}
0 commit comments