11
11
/**
12
12
* Test class for \Magento\Catalog\Model\Product\Url.
13
13
*
14
- * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
15
14
* @magentoAppArea frontend
16
15
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17
16
*/
@@ -37,6 +36,9 @@ protected function setUp(): void
37
36
);
38
37
}
39
38
39
+ /**
40
+ * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
41
+ */
40
42
public function testGetUrlInStore ()
41
43
{
42
44
$ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
@@ -89,6 +91,7 @@ public function getUrlsWithSecondStoreProvider()
89
91
90
92
/**
91
93
* @magentoDbIsolation disabled
94
+ * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
92
95
*/
93
96
public function testGetProductUrl ()
94
97
{
@@ -97,54 +100,13 @@ public function testGetProductUrl()
97
100
);
98
101
$ product = $ repository ->get ('simple ' );
99
102
$ this ->assertStringEndsWith ('simple-product.html ' , $ this ->_model ->getProductUrl ($ product ));
100
- }
101
103
102
- public function testFormatUrlKey ()
103
- {
104
- $ this ->assertEquals ('abc-test ' , $ this ->_model ->formatUrlKey ('AbC#-$^test ' ));
105
- }
106
-
107
- public function testGetUrlPath ()
108
- {
109
- /** @var $product \Magento\Catalog\Model\Product */
110
- $ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
111
- \Magento \Catalog \Model \Product::class
112
- );
113
- $ product ->setUrlPath ('product.html ' );
114
-
115
- /** @var $category \Magento\Catalog\Model\Category */
116
- $ category = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
117
- \Magento \Catalog \Model \Category::class,
118
- ['data ' => ['url_path ' => 'category ' , 'entity_id ' => 5 , 'path_ids ' => [2 , 3 , 5 ]]]
119
- );
120
- $ category ->setOrigData ();
121
-
122
- $ this ->assertEquals ('product.html ' , $ this ->urlPathGenerator ->getUrlPath ($ product ));
123
- $ this ->assertEquals ('category/product.html ' , $ this ->urlPathGenerator ->getUrlPath ($ product , $ category ));
124
- }
125
-
126
- /**
127
- * @magentoDbIsolation disabled
128
- * @magentoAppArea frontend
129
- */
130
- public function testGetUrl ()
131
- {
132
- $ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
133
- \Magento \Catalog \Model \ProductRepository::class
134
- );
135
- $ product = $ repository ->get ('simple ' );
136
- $ this ->assertStringEndsWith ('simple-product.html ' , $ this ->_model ->getUrl ($ product ));
137
-
138
- $ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
139
- \Magento \Catalog \Model \Product::class
140
- );
141
- $ product ->setId (100 );
142
- $ this ->assertStringContainsString ('catalog/product/view/id/100/ ' , $ this ->_model ->getUrl ($ product ));
143
104
}
144
105
145
106
/**
146
107
* Check that rearranging product url rewrites do not influence on whether to use category in product links
147
108
*
109
+ * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
148
110
* @magentoConfigFixture current_store catalog/seo/product_use_categories 0
149
111
* @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
150
112
* @magentoDbIsolation disabled
@@ -187,4 +149,52 @@ public function testGetProductUrlWithRearrangedUrlRewrites()
187
149
$ urlPersist ->replace ($ rewrites );
188
150
$ this ->assertStringNotContainsString ($ category ->getUrlPath (), $ this ->_model ->getProductUrl ($ product ));
189
151
}
152
+
153
+ /**
154
+ * @magentoDbIsolation disabled
155
+ */
156
+ public function testFormatUrlKey ()
157
+ {
158
+ $ this ->assertEquals ('abc-test ' , $ this ->_model ->formatUrlKey ('AbC#-$^test ' ));
159
+ }
160
+
161
+ /**
162
+ * @magentoDbIsolation disabled
163
+ * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php
164
+ * @magentoConfigFixture current_store catalog/seo/product_use_categories 0
165
+ * @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
166
+ */
167
+ public function testGetUrl ()
168
+ {
169
+ $ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
170
+ \Magento \Catalog \Model \ProductRepository::class
171
+ );
172
+ $ product = $ repository ->get ('simple ' );
173
+ $ this ->assertStringEndsWith ('simple-product.html ' , $ this ->_model ->getProductUrl ($ product ));
174
+
175
+ $ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
176
+ \Magento \Catalog \Model \Product::class
177
+ );
178
+ $ product ->setId (100 );
179
+ $ this ->assertStringContainsString ('catalog/product/view/id/100/ ' , $ this ->_model ->getUrl ($ product ));
180
+ }
181
+
182
+ public function testGetUrlPath ()
183
+ {
184
+ /** @var $product \Magento\Catalog\Model\Product */
185
+ $ product = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
186
+ \Magento \Catalog \Model \Product::class
187
+ );
188
+ $ product ->setUrlPath ('product.html ' );
189
+
190
+ /** @var $category \Magento\Catalog\Model\Category */
191
+ $ category = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
192
+ \Magento \Catalog \Model \Category::class,
193
+ ['data ' => ['url_path ' => 'category ' , 'entity_id ' => 5 , 'path_ids ' => [2 , 3 , 5 ]]]
194
+ );
195
+ $ category ->setOrigData ();
196
+
197
+ $ this ->assertEquals ('product.html ' , $ this ->urlPathGenerator ->getUrlPath ($ product ));
198
+ $ this ->assertEquals ('category/product.html ' , $ this ->urlPathGenerator ->getUrlPath ($ product , $ category ));
199
+ }
190
200
}
0 commit comments