Skip to content

Commit 4edec38

Browse files
author
Vitaliy Boyko
committed
ENGCOM-20434: Removed url key validation for invisible products (revert unit test)
1 parent f2088d9 commit 4edec38

File tree

1 file changed

+12
-40
lines changed

1 file changed

+12
-40
lines changed

app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ProductProcessUrlRewriteSavingObserverTest.php

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
namespace Magento\CatalogUrlRewrite\Test\Unit\Observer;
88

9+
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
910
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11+
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1012

1113
/**
1214
* Class ProductProcessUrlRewriteSavingObserverTest
@@ -46,21 +48,6 @@ class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit\Framework\Test
4648
*/
4749
protected $objectManager;
4850

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-
6451
/**
6552
* @var \Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver
6653
*/
@@ -73,13 +60,13 @@ protected function setUp()
7360
{
7461
$this->urlPersist = $this->createMock(\Magento\UrlRewrite\Model\UrlPersistInterface::class);
7562
$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+
]);
8370
$this->product->expects($this->any())->method('getId')->will($this->returnValue(3));
8471
$this->event = $this->createPartialMock(\Magento\Framework\Event::class, ['getProduct']);
8572
$this->event->expects($this->any())->method('getProduct')->willReturn($this->product);
@@ -92,28 +79,12 @@ protected function setUp()
9279
$this->productUrlRewriteGenerator->expects($this->any())
9380
->method('generate')
9481
->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));
11082
$this->objectManager = new ObjectManager($this);
11183
$this->model = $this->objectManager->getObject(
11284
\Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver::class,
11385
[
11486
'productUrlRewriteGenerator' => $this->productUrlRewriteGenerator,
115-
'urlPersist' => $this->urlPersist,
116-
'collectionFactory' => $this->collectionFactory
87+
'urlPersist' => $this->urlPersist
11788
]
11889
);
11990
}
@@ -132,7 +103,8 @@ public function urlKeyDataProvider()
132103
'isChangedWebsites' => false,
133104
'isChangedCategories' => false,
134105
'visibilityResult' => true,
135-
'expectedReplaceCount' => 1
106+
'expectedReplaceCount' => 1,
107+
136108
],
137109
'no chnages' => [
138110
'isChangedUrlKey' => false,

0 commit comments

Comments
 (0)