Skip to content

Commit 55c2266

Browse files
committed
Fix static test
1 parent 1b3ac06 commit 55c2266

File tree

2 files changed

+48
-19
lines changed

2 files changed

+48
-19
lines changed

app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\CatalogUrlRewrite\Model;
89

9-
use Magento\Store\Model\Store;
1010
use Magento\Catalog\Api\ProductRepositoryInterface;
1111
use Magento\Catalog\Model\Category;
1212
use Magento\Catalog\Model\Product;
13-
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
1413
use Magento\Framework\App\Config\ScopeConfigInterface;
1514
use Magento\Store\Model\ScopeInterface;
1615
use Magento\Store\Model\StoreManagerInterface;
1716

1817
/**
19-
* Class ProductUrlPathGenerator
18+
* Model product url path generator
2019
*/
2120
class ProductUrlPathGenerator
2221
{

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlPathGeneratorTest.php

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,50 @@
77

88
namespace Magento\CatalogUrlRewrite\Test\Unit\Model;
99

10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\Category;
12+
use Magento\Catalog\Model\Product;
13+
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
1014
use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
15+
use Magento\Framework\App\Config\ScopeConfigInterface;
1116
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1217
use Magento\Store\Model\ScopeInterface;
18+
use Magento\Store\Model\StoreManagerInterface;
19+
use PHPUnit\Framework\TestCase;
20+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1321

1422
/**
15-
* Class ProductUrlPathGeneratorTest
23+
* Verify ProductUrlPathGenerator class
1624
*/
17-
class ProductUrlPathGeneratorTest extends \PHPUnit\Framework\TestCase
25+
class ProductUrlPathGeneratorTest extends TestCase
1826
{
19-
/** @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator */
27+
/** @var ProductUrlPathGenerator */
2028
protected $productUrlPathGenerator;
2129

22-
/** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
30+
/** @var StoreManagerInterface|MockObject */
2331
protected $storeManager;
2432

25-
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
33+
/** @var ScopeConfigInterface|MockObject */
2634
protected $scopeConfig;
2735

28-
/** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject */
36+
/** @var CategoryUrlPathGenerator|MockObject */
2937
protected $categoryUrlPathGenerator;
3038

31-
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
39+
/** @var Product|MockObject */
3240
protected $product;
3341

34-
/** @var \Magento\Catalog\Api\ProductRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */
42+
/** @var ProductRepositoryInterface|MockObject */
3543
protected $productRepository;
3644

37-
/** @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject */
45+
/** @var Category|MockObject */
3846
protected $category;
3947

4048
/**
4149
* @inheritdoc
4250
*/
4351
protected function setUp(): void
4452
{
45-
$this->category = $this->createMock(\Magento\Catalog\Model\Category::class);
53+
$this->category = $this->createMock(Category::class);
4654
$productMethods = [
4755
'__wakeup',
4856
'getData',
@@ -54,17 +62,17 @@ protected function setUp(): void
5462
'setStoreId',
5563
];
5664

57-
$this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $productMethods);
58-
$this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
59-
$this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
65+
$this->product = $this->createPartialMock(Product::class, $productMethods);
66+
$this->storeManager = $this->createMock(StoreManagerInterface::class);
67+
$this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
6068
$this->categoryUrlPathGenerator = $this->createMock(
61-
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class
69+
CategoryUrlPathGenerator::class
6270
);
63-
$this->productRepository = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class);
71+
$this->productRepository = $this->createMock(ProductRepositoryInterface::class);
6472
$this->productRepository->expects($this->any())->method('getById')->willReturn($this->product);
6573

6674
$this->productUrlPathGenerator = (new ObjectManager($this))->getObject(
67-
\Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class,
75+
ProductUrlPathGenerator::class,
6876
[
6977
'storeManager' => $this->storeManager,
7078
'scopeConfig' => $this->scopeConfig,
@@ -75,6 +83,8 @@ protected function setUp(): void
7583
}
7684

7785
/**
86+
* Data provider for testGetUrlPath.
87+
*
7888
* @return array
7989
*/
8090
public function getUrlPathDataProvider(): array
@@ -89,6 +99,8 @@ public function getUrlPathDataProvider(): array
8999
}
90100

91101
/**
102+
* Verify get url path.
103+
*
92104
* @dataProvider getUrlPathDataProvider
93105
* @param string|null|bool $urlKey
94106
* @param string|null|bool $productName
@@ -109,6 +121,8 @@ public function testGetUrlPath($urlKey, $productName, $formatterCalled, $result)
109121
}
110122

111123
/**
124+
* Verify get url key.
125+
*
112126
* @param string|bool $productUrlKey
113127
* @param string|bool $expectedUrlKey
114128
* @return void
@@ -122,6 +136,8 @@ public function testGetUrlKey($productUrlKey, $expectedUrlKey): void
122136
}
123137

124138
/**
139+
* Data provider for testGetUrlKey.
140+
*
125141
* @return array
126142
*/
127143
public function getUrlKeyDataProvider(): array
@@ -133,6 +149,8 @@ public function getUrlKeyDataProvider(): array
133149
}
134150

135151
/**
152+
* Verify get url path with default utl key.
153+
*
136154
* @param string|null|bool $storedUrlKey
137155
* @param string|null|bool $productName
138156
* @param string $expectedUrlKey
@@ -150,6 +168,8 @@ public function testGetUrlPathDefaultUrlKey($storedUrlKey, $productName, $expect
150168
}
151169

152170
/**
171+
* Data provider for testGetUrlPathDefaultUrlKey.
172+
*
153173
* @return array
154174
*/
155175
public function getUrlPathDefaultUrlKeyDataProvider(): array
@@ -161,6 +181,8 @@ public function getUrlPathDefaultUrlKeyDataProvider(): array
161181
}
162182

163183
/**
184+
* Verify get url path with category.
185+
*
164186
* @return void
165187
*/
166188
public function testGetUrlPathWithCategory(): void
@@ -177,6 +199,8 @@ public function testGetUrlPathWithCategory(): void
177199
}
178200

179201
/**
202+
* Verify get url path with suffix.
203+
*
180204
* @return void
181205
*/
182206
public function testGetUrlPathWithSuffix(): void
@@ -198,6 +222,8 @@ public function testGetUrlPathWithSuffix(): void
198222
}
199223

200224
/**
225+
* Verify get url path with suffix and category and store.
226+
*
201227
* @return void
202228
*/
203229
public function testGetUrlPathWithSuffixAndCategoryAndStore(): void
@@ -219,6 +245,8 @@ public function testGetUrlPathWithSuffixAndCategoryAndStore(): void
219245
}
220246

221247
/**
248+
* Verify get canonical url path.
249+
*
222250
* @return void
223251
*/
224252
public function testGetCanonicalUrlPath(): void
@@ -232,6 +260,8 @@ public function testGetCanonicalUrlPath(): void
232260
}
233261

234262
/**
263+
* Verify get canonical path with category.
264+
*
235265
* @return void
236266
*/
237267
public function testGetCanonicalUrlPathWithCategory(): void

0 commit comments

Comments
 (0)