15
15
use Magento \TestFramework \ObjectManager ;
16
16
use Magento \TestFramework \TestCase \GraphQlAbstract ;
17
17
18
+ /**
19
+ * Test for downloadable product.
20
+ */
18
21
class DownloadableProductViewTest extends GraphQlAbstract
19
22
{
20
23
/**
@@ -53,24 +56,16 @@ public function testQueryAllFieldsDownloadableProductsWithDownloadableFileAndSam
53
56
links_purchased_separately
54
57
55
58
downloadable_product_links{
56
- id
57
59
sample_url
58
- sample_type
59
-
60
- is_shareable
61
- number_of_downloads
62
60
sort_order
63
61
title
64
- link_type
65
-
66
62
price
67
63
}
68
64
downloadable_product_samples{
69
65
title
70
66
sort_order
71
67
sort_order
72
- sample_type
73
- sample_file
68
+ sample_url
74
69
}
75
70
}
76
71
}
@@ -82,8 +77,6 @@ public function testQueryAllFieldsDownloadableProductsWithDownloadableFileAndSam
82
77
$ config = ObjectManager::getInstance ()->get (\Magento \Config \Model \ResourceModel \Config::class);
83
78
$ config ->saveConfig (
84
79
\Magento \Downloadable \Model \Link::XML_PATH_CONFIG_IS_SHAREABLE ,
85
- 0 ,
86
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT ,
87
80
0
88
81
);
89
82
$ response = $ this ->graphQlQuery ($ query );
@@ -143,22 +136,15 @@ public function testDownloadableProductQueryWithNoSample()
143
136
links_purchased_separately
144
137
145
138
downloadable_product_links{
146
- id
147
139
sample_url
148
- sample_type
149
- is_shareable
150
- number_of_downloads
151
140
sort_order
152
141
title
153
- link_type
154
142
price
155
143
}
156
144
downloadable_product_samples{
157
145
title
158
146
sort_order
159
- sort_order
160
- sample_type
161
- sample_file
147
+ sample_url
162
148
}
163
149
}
164
150
}
@@ -197,12 +183,8 @@ public function testDownloadableProductQueryWithNoSample()
197
183
$ this ->assertResponseFields (
198
184
$ response ['products ' ]['items ' ][0 ]['downloadable_product_links ' ][0 ],
199
185
[
200
- 'id ' => $ downloadableProductLink ->getId (),
201
- 'is_shareable ' => false ,
202
- 'number_of_downloads ' => $ downloadableProductLink ->getNumberOfDownloads (),
203
186
'sort_order ' => $ downloadableProductLink ->getSortOrder (),
204
187
'title ' => $ downloadableProductLink ->getTitle (),
205
- 'link_type ' => strtoupper ($ downloadableProductLink ->getLinkType ()),
206
188
'price ' => $ downloadableProductLink ->getPrice ()
207
189
]
208
190
);
@@ -221,18 +203,12 @@ private function assertDownloadableProductLinks($product, $actualResponse)
221
203
/** @var LinkInterface $downloadableProductLinks */
222
204
$ downloadableProductLinks = $ product ->getExtensionAttributes ()->getDownloadableProductLinks ();
223
205
$ downloadableProductLink = $ downloadableProductLinks [1 ];
224
-
206
+ $ this -> assertNotEmpty ( ' sample_url ' , $ actualResponse [ ' downloadable_product_links ' ][ 1 ]);
225
207
$ this ->assertResponseFields (
226
208
$ actualResponse ['downloadable_product_links ' ][1 ],
227
209
[
228
- 'id ' => $ downloadableProductLink ->getId (),
229
- 'sample_url ' => $ downloadableProductLink ->getSampleUrl (),
230
- 'sample_type ' => strtoupper ($ downloadableProductLink ->getSampleType ()),
231
- 'is_shareable ' => false ,
232
- 'number_of_downloads ' => $ downloadableProductLink ->getNumberOfDownloads (),
233
210
'sort_order ' => $ downloadableProductLink ->getSortOrder (),
234
211
'title ' => $ downloadableProductLink ->getTitle (),
235
- 'link_type ' => strtoupper ($ downloadableProductLink ->getLinkType ()),
236
212
'price ' => $ downloadableProductLink ->getPrice ()
237
213
]
238
214
);
@@ -251,13 +227,12 @@ private function assertDownloadableProductSamples($product, $actualResponse)
251
227
/** @var SampleInterface $downloadableProductSamples */
252
228
$ downloadableProductSamples = $ product ->getExtensionAttributes ()->getDownloadableProductSamples ();
253
229
$ downloadableProductSample = $ downloadableProductSamples [0 ];
230
+ $ this ->assertNotEmpty ('sample_url ' , $ actualResponse ['downloadable_product_samples ' ][0 ]);
254
231
$ this ->assertResponseFields (
255
232
$ actualResponse ['downloadable_product_samples ' ][0 ],
256
233
[
257
234
'title ' => $ downloadableProductSample ->getTitle (),
258
- 'sort_order ' =>$ downloadableProductSample ->getSortOrder (),
259
- 'sample_type ' => strtoupper ($ downloadableProductSample ->getSampleType ()),
260
- 'sample_file ' => $ downloadableProductSample ->getSampleFile ()
235
+ 'sort_order ' => $ downloadableProductSample ->getSortOrder ()
261
236
]
262
237
);
263
238
}
0 commit comments