10
10
use Magento \Catalog \Api \CategoryRepositoryInterface ;
11
11
use Magento \Catalog \Api \Data \ProductInterface ;
12
12
use Magento \Catalog \Api \ProductRepositoryInterface ;
13
- use Magento \CatalogUrlRewrite \Model \CategoryUrlPathGenerator ;
13
+ use Magento \CatalogUrlRewrite \Model \ProductUrlPathGenerator ;
14
14
use Magento \Framework \App \Config \ScopeConfigInterface ;
15
15
use Magento \Framework \Registry ;
16
16
use Magento \Store \Model \ScopeInterface ;
@@ -58,7 +58,7 @@ protected function setUp()
58
58
$ this ->categoryRepository = $ this ->_objectManager ->create (CategoryRepositoryInterface::class);
59
59
$ this ->storeManager = $ this ->_objectManager ->get (StoreManagerInterface::class);
60
60
$ this ->urlSuffix = $ this ->config ->getValue (
61
- CategoryUrlPathGenerator:: XML_PATH_CATEGORY_URL_SUFFIX ,
61
+ ProductUrlPathGenerator:: XML_PATH_PRODUCT_URL_SUFFIX ,
62
62
ScopeInterface::SCOPE_STORE
63
63
);
64
64
}
@@ -103,10 +103,10 @@ public function testProductRedirect(): void
103
103
'url_key_create_redirect ' => $ product ->getUrlKey (),
104
104
'save_rewrites_history ' => true ,
105
105
];
106
- $ this ->saveProductWithAdditionalData ($ product , $ data );
106
+ $ this ->updateProduct ($ product , $ data );
107
107
$ this ->dispatch ($ oldUrl );
108
108
109
- $ this ->assertRedirect ($ this ->stringContains ('new-url-key ' . $ this -> urlSuffix ));
109
+ $ this ->assertRedirect ($ this ->stringContains ($ this -> prepareUrl ( 'new-url-key ' ) ));
110
110
}
111
111
112
112
/**
@@ -124,7 +124,7 @@ public function testMultistoreProductUrlRewrite(): void
124
124
$ this ->storeManager ->setCurrentStore ($ secondStoreId );
125
125
126
126
try {
127
- $ product = $ this ->saveProductWithAdditionalData ($ product , ['url_key ' => 'second-store-url-key ' ]);
127
+ $ product = $ this ->updateProduct ($ product , ['url_key ' => 'second-store-url-key ' ]);
128
128
$ this ->assertEquals ('second-store-url-key ' , $ product ->getUrlKey ());
129
129
$ secondStoreUrl = $ this ->prepareUrl ($ product ->getUrlKey ());
130
130
@@ -146,7 +146,7 @@ public function testMultistoreProductUrlRewrite(): void
146
146
* @param array $data
147
147
* @return ProductInterface
148
148
*/
149
- private function saveProductWithAdditionalData (ProductInterface $ product , array $ data ): ProductInterface
149
+ private function updateProduct (ProductInterface $ product , array $ data ): ProductInterface
150
150
{
151
151
$ product ->addData ($ data );
152
152
@@ -195,9 +195,11 @@ private function assertProductIsVisible(ProductInterface $product): void
195
195
$ this ->getResponse ()->getHttpResponseCode (),
196
196
'Wrong response code is returned '
197
197
);
198
+ $ currentProduct = $ this ->registry ->registry ('current_product ' );
199
+ $ this ->assertNotNull ($ currentProduct );
198
200
$ this ->assertEquals (
199
201
$ product ->getSku (),
200
- $ this -> registry -> registry ( ' current_product ' ) ->getSku (),
202
+ $ currentProduct ->getSku (),
201
203
'Wrong product is registered '
202
204
);
203
205
}
0 commit comments