6
6
7
7
namespace Magento \CatalogUrlRewrite \Test \Unit \Observer ;
8
8
9
+ use Magento \CatalogUrlRewrite \Model \ProductUrlRewriteGenerator ;
9
10
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
11
+ use Magento \UrlRewrite \Service \V1 \Data \UrlRewrite ;
10
12
11
13
/**
12
14
* Class ProductProcessUrlRewriteSavingObserverTest
@@ -46,21 +48,6 @@ class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit\Framework\Test
46
48
*/
47
49
protected $ objectManager ;
48
50
49
- /**
50
- * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
51
- */
52
- private $ collectionFactory ;
53
-
54
- /**
55
- * @var \Magento\Catalog\Model\ResourceModel\Product\Collection
56
- */
57
- private $ productCollection ;
58
-
59
- /**
60
- * @var \Magento\Framework\DB\Select
61
- */
62
- private $ select ;
63
-
64
51
/**
65
52
* @var \Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver
66
53
*/
@@ -73,13 +60,13 @@ protected function setUp()
73
60
{
74
61
$ this ->urlPersist = $ this ->createMock (\Magento \UrlRewrite \Model \UrlPersistInterface::class);
75
62
$ this ->product = $ this ->createPartialMock (\Magento \Catalog \Model \Product::class, [
76
- 'getId ' ,
77
- 'dataHasChangedFor ' ,
78
- 'isVisibleInSiteVisibility ' ,
79
- 'getIsChangedWebsites ' ,
80
- 'getIsChangedCategories ' ,
81
- 'getStoreId '
82
- ]);
63
+ 'getId ' ,
64
+ 'dataHasChangedFor ' ,
65
+ 'isVisibleInSiteVisibility ' ,
66
+ 'getIsChangedWebsites ' ,
67
+ 'getIsChangedCategories ' ,
68
+ 'getStoreId '
69
+ ]);
83
70
$ this ->product ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue (3 ));
84
71
$ this ->event = $ this ->createPartialMock (\Magento \Framework \Event::class, ['getProduct ' ]);
85
72
$ this ->event ->expects ($ this ->any ())->method ('getProduct ' )->willReturn ($ this ->product );
@@ -92,28 +79,12 @@ protected function setUp()
92
79
$ this ->productUrlRewriteGenerator ->expects ($ this ->any ())
93
80
->method ('generate ' )
94
81
->will ($ this ->returnValue ([3 => 'rewrite ' ]));
95
- $ this ->collectionFactory = $ this ->createMock (
96
- \Magento \Catalog \Model \ResourceModel \Product \CollectionFactory::class
97
- );
98
- $ this ->productCollection = $ this ->createMock (
99
- \Magento \Catalog \Model \ResourceModel \Product \Collection::class
100
- );
101
- $ this ->select = $ this ->createMock (
102
- \Magento \Framework \DB \Select::class
103
- );
104
- $ this ->collectionFactory ->expects ($ this ->any ())
105
- ->method ('create ' )
106
- ->will ($ this ->returnValue ($ this ->productCollection ));
107
- $ this ->productCollection ->expects ($ this ->any ())
108
- ->method ('getSelect ' )
109
- ->will ($ this ->returnValue ($ this ->select ));
110
82
$ this ->objectManager = new ObjectManager ($ this );
111
83
$ this ->model = $ this ->objectManager ->getObject (
112
84
\Magento \CatalogUrlRewrite \Observer \ProductProcessUrlRewriteSavingObserver::class,
113
85
[
114
86
'productUrlRewriteGenerator ' => $ this ->productUrlRewriteGenerator ,
115
- 'urlPersist ' => $ this ->urlPersist ,
116
- 'collectionFactory ' => $ this ->collectionFactory
87
+ 'urlPersist ' => $ this ->urlPersist
117
88
]
118
89
);
119
90
}
@@ -132,7 +103,8 @@ public function urlKeyDataProvider()
132
103
'isChangedWebsites ' => false ,
133
104
'isChangedCategories ' => false ,
134
105
'visibilityResult ' => true ,
135
- 'expectedReplaceCount ' => 1
106
+ 'expectedReplaceCount ' => 1 ,
107
+
136
108
],
137
109
'no chnages ' => [
138
110
'isChangedUrlKey ' => false ,
0 commit comments