5
5
*/
6
6
declare (strict_types=1 );
7
7
8
+ namespace Magento \CatalogUrlRewrite \Model ;
9
+
8
10
use Magento \Catalog \Api \ProductRepositoryInterface ;
9
- use Magento \CatalogUrlRewrite \Model \AbstractUrlRewriteTest ;
10
11
use Magento \CatalogUrlRewrite \Model \Map \DataProductUrlRewriteDatabaseMap ;
11
- use Magento \CatalogUrlRewrite \Model \ProductUrlPathGenerator ;
12
12
use Magento \Store \Model \ScopeInterface ;
13
13
use Magento \TestFramework \Fixture \DataFixture ;
14
14
use Magento \Catalog \Model \Product \Visibility ;
18
18
* Class for product url rewrites tests
19
19
*
20
20
*/
21
- class ProductUrlRewriteDataTest extends AbstractUrlRewriteTest
21
+ class ProductUrlRewriteVisibilityTest extends AbstractUrlRewriteTest
22
22
{
23
+ const URL_KEY_EMPTY_MESSAGE = 'Failed asserting URL key is empty for the given product ' ;
23
24
24
25
/** @var string */
25
26
private $ suffix ;
@@ -54,7 +55,7 @@ protected function setUp(): void
54
55
public function testUrlRewriteOnInvisibleProductEdit (array $ expectedData ): void
55
56
{
56
57
$ product = $ this ->productRepository ->get ('simple ' , true , 0 , true );
57
- $ this ->assertUrlKeyEmpty ($ product );
58
+ $ this ->assertUrlKeyEmpty ($ product, self :: URL_KEY_EMPTY_MESSAGE );
58
59
59
60
//Update visibility and check the database entry
60
61
$ product ->setVisibility (Visibility::VISIBILITY_BOTH );
@@ -71,7 +72,7 @@ public function testUrlRewriteOnInvisibleProductEdit(array $expectedData): void
71
72
$ product ->setVisibility (Visibility::VISIBILITY_NOT_VISIBLE );
72
73
$ product = $ this ->productRepository ->save ($ product );
73
74
74
- $ this ->assertUrlKeyEmpty ($ product );
75
+ $ this ->assertUrlKeyEmpty ($ product, self :: URL_KEY_EMPTY_MESSAGE );
75
76
}
76
77
77
78
/**
@@ -95,15 +96,14 @@ public function invisibleProductDataProvider(): array
95
96
* Assert URL key is empty in database for the given product
96
97
*
97
98
* @param $product
99
+ * @param string $message
100
+ *
98
101
* @return void
99
102
*/
100
- public function assertUrlKeyEmpty ($ product ): void
103
+ public function assertUrlKeyEmpty ($ product, $ message = '' ): void
101
104
{
102
105
$ productUrlRewriteItems = $ this ->getEntityRewriteCollection ($ product ->getId ())->getItems ();
103
- $ this ->assertEmpty (
104
- $ productUrlRewriteItems ,
105
- 'Failed asserting URL key is empty for the given product '
106
- );
106
+ $ this ->assertEmpty ($ productUrlRewriteItems , $ message );
107
107
}
108
108
109
109
/**
0 commit comments