5
5
*/
6
6
namespace Magento \CatalogUrlRewrite \Observer ;
7
7
8
- use Magento \Catalog \Api \ProductRepositoryInterface ;
9
- use Magento \Catalog \Model \Product \Visibility ;
10
8
use Magento \Store \Model \StoreManagerInterface ;
11
- use Magento \UrlRewrite \Model \Exception \UrlAlreadyExistsException ;
12
9
use Magento \UrlRewrite \Service \V1 \Data \UrlRewrite ;
10
+ use Magento \CatalogUrlRewrite \Model \CategoryUrlRewriteGenerator ;
13
11
14
12
/**
15
13
* @magentoAppArea adminhtml
@@ -20,16 +18,12 @@ class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit\Framework\Test
20
18
/** @var \Magento\Framework\ObjectManagerInterface */
21
19
protected $ objectManager ;
22
20
23
- /** @var ProductRepositoryInterface */
24
- private $ productRepository ;
25
-
26
21
/**
27
22
* Set up
28
23
*/
29
24
protected function setUp ()
30
25
{
31
26
$ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
32
- $ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
33
27
}
34
28
35
29
/**
@@ -142,8 +136,10 @@ public function testUrlKeyHasChangedInGlobalContext()
142
136
*/
143
137
public function testUrlKeyHasChangedInStoreviewContextWithPermanentRedirection ()
144
138
{
139
+ /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository*/
140
+ $ productRepository = $ this ->objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
145
141
/** @var \Magento\Catalog\Model\Product $product*/
146
- $ product = $ this -> productRepository ->get ('product1 ' );
142
+ $ product = $ productRepository ->get ('product1 ' );
147
143
148
144
/** @var StoreManagerInterface $storeManager */
149
145
$ storeManager = $ this ->objectManager ->get (StoreManagerInterface::class);
@@ -238,22 +234,4 @@ public function testUrlKeyHasChangedInStoreviewContextWithoutPermanentRedirectio
238
234
$ this ->assertContains ($ row , $ actual );
239
235
}
240
236
}
241
-
242
- /**
243
- * @magentoDataFixture Magento/CatalogUrlRewrite/_files/product_simple.php
244
- * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php
245
- * @magentoAppIsolation enabled
246
- */
247
- public function testDuplicatedUrlKeyInvisibleProduct ()
248
- {
249
- $ this ->expectException (
250
- UrlAlreadyExistsException::class,
251
- 'URL key for specified store already exists '
252
- );
253
- /** @var \Magento\Catalog\Model\Product $product*/
254
- $ product = $ this ->productRepository ->get ('simple2 ' );
255
- $ product ->setVisibility (Visibility::VISIBILITY_NOT_VISIBLE );
256
- $ product ->setUrlKey ('simple_product ' );
257
- $ product ->save ();
258
- }
259
237
}
0 commit comments