11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2019 Adobe
4+ * All rights reserved .
55 */
66declare (strict_types=1 );
77
1111use Magento \Catalog \Model \Indexer \Product \Category ;
1212use Magento \CatalogSearch \Model \Indexer \Fulltext as IndexerSearch ;
1313use Magento \Indexer \Model \Indexer ;
14+ use Magento \Indexer \Test \Fixture \Indexer as IndexerFixture ;
15+ use Magento \TestFramework \Fixture \Config ;
1416use Magento \TestFramework \Helper \Bootstrap ;
1517use Magento \TestFramework \ObjectManager ;
1618use Magento \TestFramework \TestCase \GraphQlAbstract ;
19+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
20+ use Magento \TestFramework \Fixture \DataFixture ;
21+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
22+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
1723
1824/**
1925 * Test for getting canonical_url for products
@@ -23,23 +29,28 @@ class ProductCanonicalUrlTest extends GraphQlAbstract
2329 /** @var ObjectManager */
2430 private $ objectManager ;
2531
32+ /** @var DataFixtureStorage */
33+ private $ fixtures ;
34+
2635 /**
2736 * @inheritdoc
2837 */
2938 protected function setUp (): void
3039 {
3140 $ this ->objectManager = Bootstrap::getObjectManager ();
41+ $ this ->fixtures = DataFixtureStorageManager::getStorage ();
3242 }
3343
34- /**
35- * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
36- * @magentoConfigFixture default_store catalog/seo/product_canonical_tag 1
37- *
38- */
44+ #[
45+ Config( ' catalog/seo/product_canonical_tag ' , 1 ),
46+ DataFixture(ProductFixture::class, as: ' product ' ),
47+ DataFixture(IndexerFixture::class)
48+ ]
3949 public function testProductWithCanonicalLinksMetaTagSettingsEnabled ()
4050 {
41- $ this ->reindex ();
42- $ productSku = 'simple ' ;
51+ $ product = DataFixtureStorageManager::getStorage ()->get ('product ' );
52+ $ productSku = $ product ->getSku ();
53+ $ productCanonicalUrl = $ product ->getUrlKey ();
4354 $ query
4455 = <<<QUERY
4556{
@@ -57,10 +68,10 @@ public function testProductWithCanonicalLinksMetaTagSettingsEnabled()
5768 $ this ->assertNotEmpty ($ response ['products ' ]['items ' ]);
5869
5970 $ this ->assertEquals (
60- ' simple-product .html ' ,
71+ $ productCanonicalUrl . ' .html ' ,
6172 $ response ['products ' ]['items ' ][0 ]['canonical_url ' ]
6273 );
63- $ this ->assertEquals (' simple ' , $ response ['products ' ]['items ' ][0 ]['sku ' ]);
74+ $ this ->assertEquals ($ productSku , $ response ['products ' ]['items ' ][0 ]['sku ' ]);
6475 }
6576
6677 /**
0 commit comments