1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2019 Adobe
4
+ * All rights reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
11
11
use Magento \Catalog \Model \Indexer \Product \Category ;
12
12
use Magento \CatalogSearch \Model \Indexer \Fulltext as IndexerSearch ;
13
13
use Magento \Indexer \Model \Indexer ;
14
+ use Magento \Indexer \Test \Fixture \Indexer as IndexerFixture ;
15
+ use Magento \TestFramework \Fixture \Config ;
14
16
use Magento \TestFramework \Helper \Bootstrap ;
15
17
use Magento \TestFramework \ObjectManager ;
16
18
use 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 ;
17
23
18
24
/**
19
25
* Test for getting canonical_url for products
@@ -23,23 +29,28 @@ class ProductCanonicalUrlTest extends GraphQlAbstract
23
29
/** @var ObjectManager */
24
30
private $ objectManager ;
25
31
32
+ /** @var DataFixtureStorage */
33
+ private $ fixtures ;
34
+
26
35
/**
27
36
* @inheritdoc
28
37
*/
29
38
protected function setUp (): void
30
39
{
31
40
$ this ->objectManager = Bootstrap::getObjectManager ();
41
+ $ this ->fixtures = DataFixtureStorageManager::getStorage ();
32
42
}
33
43
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
+ ]
39
49
public function testProductWithCanonicalLinksMetaTagSettingsEnabled ()
40
50
{
41
- $ this ->reindex ();
42
- $ productSku = 'simple ' ;
51
+ $ product = DataFixtureStorageManager::getStorage ()->get ('product ' );
52
+ $ productSku = $ product ->getSku ();
53
+ $ productCanonicalUrl = $ product ->getUrlKey ();
43
54
$ query
44
55
= <<<QUERY
45
56
{
@@ -57,10 +68,10 @@ public function testProductWithCanonicalLinksMetaTagSettingsEnabled()
57
68
$ this ->assertNotEmpty ($ response ['products ' ]['items ' ]);
58
69
59
70
$ this ->assertEquals (
60
- ' simple-product .html ' ,
71
+ $ productCanonicalUrl . ' .html ' ,
61
72
$ response ['products ' ]['items ' ][0 ]['canonical_url ' ]
62
73
);
63
- $ this ->assertEquals (' simple ' , $ response ['products ' ]['items ' ][0 ]['sku ' ]);
74
+ $ this ->assertEquals ($ productSku , $ response ['products ' ]['items ' ][0 ]['sku ' ]);
64
75
}
65
76
66
77
/**
0 commit comments