55 */
66declare (strict_types=1 );
77
8+ namespace Magento \CatalogUrlRewrite \Model ;
9+
810use Magento \Catalog \Api \ProductRepositoryInterface ;
9- use Magento \CatalogUrlRewrite \Model \AbstractUrlRewriteTest ;
1011use Magento \CatalogUrlRewrite \Model \Map \DataProductUrlRewriteDatabaseMap ;
11- use Magento \CatalogUrlRewrite \Model \ProductUrlPathGenerator ;
1212use Magento \Store \Model \ScopeInterface ;
1313use Magento \TestFramework \Fixture \DataFixture ;
1414use Magento \Catalog \Model \Product \Visibility ;
1818 * Class for product url rewrites tests
1919 *
2020 */
21- class ProductUrlRewriteDataTest extends AbstractUrlRewriteTest
21+ class ProductUrlRewriteVisibilityTest extends AbstractUrlRewriteTest
2222{
23+ const URL_KEY_EMPTY_MESSAGE = 'Failed asserting URL key is empty for the given product ' ;
2324
2425 /** @var string */
2526 private $ suffix ;
@@ -54,7 +55,7 @@ protected function setUp(): void
5455 public function testUrlRewriteOnInvisibleProductEdit (array $ expectedData ): void
5556 {
5657 $ product = $ this ->productRepository ->get ('simple ' , true , 0 , true );
57- $ this ->assertUrlKeyEmpty ($ product );
58+ $ this ->assertUrlKeyEmpty ($ product, self :: URL_KEY_EMPTY_MESSAGE );
5859
5960 //Update visibility and check the database entry
6061 $ product ->setVisibility (Visibility::VISIBILITY_BOTH );
@@ -71,7 +72,7 @@ public function testUrlRewriteOnInvisibleProductEdit(array $expectedData): void
7172 $ product ->setVisibility (Visibility::VISIBILITY_NOT_VISIBLE );
7273 $ product = $ this ->productRepository ->save ($ product );
7374
74- $ this ->assertUrlKeyEmpty ($ product );
75+ $ this ->assertUrlKeyEmpty ($ product, self :: URL_KEY_EMPTY_MESSAGE );
7576 }
7677
7778 /**
@@ -95,15 +96,14 @@ public function invisibleProductDataProvider(): array
9596 * Assert URL key is empty in database for the given product
9697 *
9798 * @param $product
99+ * @param string $message
100+ *
98101 * @return void
99102 */
100- public function assertUrlKeyEmpty ($ product ): void
103+ public function assertUrlKeyEmpty ($ product, $ message = '' ): void
101104 {
102105 $ 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 );
107107 }
108108
109109 /**
0 commit comments