File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \GraphQl \Catalog ;
9
+
10
+ use Magento \TestFramework \TestCase \GraphQlAbstract ;
11
+
12
+ /**
13
+ * Test for simple product fragment.
14
+ */
15
+ class ProductFragmentTest extends GraphQlAbstract
16
+ {
17
+ /**
18
+ * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
19
+ */
20
+ public function testSimpleProductFragment ()
21
+ {
22
+ $ sku = 'simple ' ;
23
+ $ name = 'Simple Product ' ;
24
+ $ price = 10 ;
25
+
26
+ $ query = <<<QUERY
27
+ query GetProduct {
28
+ products(filter: { sku: { eq: " $ sku" } }) {
29
+ items {
30
+ sku
31
+ ...BasicProductInformation
32
+ }
33
+ }
34
+ }
35
+
36
+ fragment BasicProductInformation on ProductInterface {
37
+ sku
38
+ name
39
+ price {
40
+ regularPrice {
41
+ amount {
42
+ value
43
+ }
44
+ }
45
+ }
46
+ }
47
+ QUERY ;
48
+ $ result = $ this ->graphQlQuery ($ query );
49
+ $ actualProductData = $ result ['products ' ]['items ' ][0 ];
50
+ $ this ->assertNotEmpty ($ actualProductData );
51
+ $ this ->assertEquals ($ name , $ actualProductData ['name ' ]);
52
+ $ this ->assertEquals ($ price , $ actualProductData ['price ' ]['regularPrice ' ]['amount ' ]['value ' ]);
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments