@@ -88,30 +88,69 @@ public function testQueryAllFieldsSimpleProduct()
88
88
new_from_date
89
89
new_to_date
90
90
options_container
91
- options
92
- {
93
- file_extension
94
- image_size_x
95
- image_size_y
96
- is_require
97
- max_characters
98
- option_id
99
- price
100
- price_type
101
- product_sku
102
- sku
103
- sort_order
91
+ ... on CustomizableProductInterface {
92
+ options {
104
93
title
105
- type
106
- values
107
- {
108
- title
109
- sort_order
94
+ required
95
+ sort_order
96
+ ... on CustomizableFieldOption {
97
+ product_sku
98
+ field_option: value {
99
+ sku
110
100
price
111
101
price_type
102
+ max_characters
103
+ }
104
+ }
105
+ ... on CustomizableAreaOption {
106
+ product_sku
107
+ area_option: value {
108
+ sku
109
+ price
110
+ price_type
111
+ max_characters
112
+ }
113
+ }
114
+ ... on CustomizableDateOption {
115
+ product_sku
116
+ date_option: value {
117
+ sku
118
+ price
119
+ price_type
120
+ }
121
+ }
122
+ ... on CustomizableDropDownOption {
123
+ drop_down_option: value {
124
+ option_type_id
112
125
sku
126
+ price
127
+ price_type
128
+ title
129
+ sort_order
130
+ }
131
+ }
132
+ ... on CustomizableRadioOption {
133
+ radio_option: value {
113
134
option_type_id
135
+ sku
136
+ price
137
+ price_type
138
+ title
139
+ sort_order
140
+ }
114
141
}
142
+ ...on CustomizableFileOption {
143
+ product_sku
144
+ file_option: value {
145
+ sku
146
+ price
147
+ price_type
148
+ file_extension
149
+ image_size_x
150
+ image_size_y
151
+ }
152
+ }
153
+ }
115
154
}
116
155
page_layout
117
156
price {
@@ -288,30 +327,67 @@ public function testQueryMediaGalleryEntryFieldsSimpleProduct()
288
327
new_from_date
289
328
new_to_date
290
329
options_container
291
- options
292
- {
293
- file_extension
294
- image_size_x
295
- image_size_y
296
- is_require
297
- max_characters
298
- option_id
299
- price
300
- price_type
301
- product_sku
302
- sku
303
- sort_order
330
+ ... on CustomizableProductInterface {
331
+ field_options: options {
304
332
title
305
- type
306
- values
307
- {
308
- title
309
- sort_order
333
+ required
334
+ sort_order
335
+ ... on CustomizableFieldOption {
336
+ product_sku
337
+ field_option: value {
338
+ sku
310
339
price
311
340
price_type
341
+ max_characters
342
+ }
343
+ }
344
+ ... on CustomizableAreaOption {
345
+ product_sku
346
+ area_option: value {
312
347
sku
348
+ price
349
+ price_type
350
+ max_characters
351
+ }
352
+ }
353
+ ... on CustomizableDateOption {
354
+ product_sku
355
+ date_option: value {
356
+ sku
357
+ price
358
+ price_type
359
+ }
360
+ }
361
+ ... on CustomizableDropDownOption {
362
+ drop_down_option: value {
363
+ option_type_id
364
+ sku
365
+ price
366
+ price_type
367
+ title
368
+ }
369
+ }
370
+ ... on CustomizableRadioOption {
371
+ radio_option: value {
313
372
option_type_id
373
+ sku
374
+ price
375
+ price_type
376
+ title
377
+ }
314
378
}
379
+ ...on CustomizableFileOption {
380
+ product_sku
381
+ file_option: value {
382
+ sku
383
+ price
384
+ price_type
385
+ file_extension
386
+ image_size_x
387
+ image_size_y
388
+ }
389
+ }
390
+ }
315
391
}
316
392
page_layout
317
393
price {
@@ -534,61 +610,71 @@ private function assertOptions($product, $actualResponse)
534
610
$ option = null ;
535
611
/** @var \Magento\Catalog\Model\Product\Option $optionSelect */
536
612
foreach ($ productOptions as $ optionSelect ) {
537
- if ($ optionSelect ->getOptionId () == $ optionsArray ['option_id ' ]) {
613
+ if ($ optionSelect ->getTitle () == $ optionsArray ['title ' ]) {
538
614
$ option = $ optionSelect ;
539
615
break ;
540
616
}
541
617
}
542
618
$ assertionMap = [
543
- ['response_field ' => 'product_sku ' , 'expected_value ' => $ option ->getProductSku ()],
544
619
['response_field ' => 'sort_order ' , 'expected_value ' => $ option ->getSortOrder ()],
545
620
['response_field ' => 'title ' , 'expected_value ' => $ option ->getTitle ()],
546
- ['response_field ' => 'type ' , 'expected_value ' => $ option ->getType ()],
547
- ['response_field ' => 'option_id ' , 'expected_value ' => $ option ->getOptionId ()],
548
- ['response_field ' => 'is_require ' , 'expected_value ' => $ option ->getIsRequire ()],
549
- ['response_field ' => 'sort_order ' , 'expected_value ' => $ option ->getSortOrder ()]
621
+ ['response_field ' => 'required ' , 'expected_value ' => $ option ->getIsRequire ()]
550
622
];
551
623
552
624
if (!empty ($ option ->getValues ())) {
553
- $ value = current ($ optionsArray ['values ' ]);
625
+ $ valueKeyName = $ option ->getType () === 'radio ' ? 'radio_option ' : 'drop_down_option ' ;
626
+ $ value = current ($ optionsArray [$ valueKeyName ]);
554
627
/** @var \Magento\Catalog\Model\Product\Option\Value $productValue */
555
628
$ productValue = current ($ option ->getValues ());
556
629
$ assertionMapValues = [
557
630
['response_field ' => 'title ' , 'expected_value ' => $ productValue ->getTitle ()],
558
631
['response_field ' => 'sort_order ' , 'expected_value ' => $ productValue ->getSortOrder ()],
559
632
['response_field ' => 'price ' , 'expected_value ' => $ productValue ->getPrice ()],
560
- ['response_field ' => 'price_type ' , 'expected_value ' => $ productValue ->getPriceType ()],
633
+ ['response_field ' => 'price_type ' , 'expected_value ' => strtoupper ( $ productValue ->getPriceType () )],
561
634
['response_field ' => 'sku ' , 'expected_value ' => $ productValue ->getSku ()],
562
635
['response_field ' => 'option_type_id ' , 'expected_value ' => $ productValue ->getOptionTypeId ()]
563
636
];
564
637
$ this ->assertResponseFields ($ value , $ assertionMapValues );
565
638
} else {
639
+ $ assertionMap = array_merge (
640
+ $ assertionMap ,
641
+ [
642
+ ['response_field ' => 'product_sku ' , 'expected_value ' => $ option ->getProductSku ()],
643
+ ]
644
+ );
645
+ $ valueKeyName = "" ;
566
646
if ($ option ->getType () === 'file ' ) {
567
- $ assertionMap = array_merge (
568
- $ assertionMap ,
569
- [
570
- ['response_field ' => 'file_extension ' , 'expected_value ' => $ option ->getFileExtension ()],
571
- ['response_field ' => 'image_size_x ' , 'expected_value ' => $ option ->getImageSizeX ()],
572
- ['response_field ' => 'image_size_y ' , 'expected_value ' => $ option ->getImageSizeY ()]
573
- ]
574
- );
647
+ $ valueKeyName = 'file_option ' ;
648
+ $ valueAssertionMap = [
649
+ ['response_field ' => 'file_extension ' , 'expected_value ' => $ option ->getFileExtension ()],
650
+ ['response_field ' => 'image_size_x ' , 'expected_value ' => $ option ->getImageSizeX ()],
651
+ ['response_field ' => 'image_size_y ' , 'expected_value ' => $ option ->getImageSizeY ()]
652
+ ];
575
653
} elseif ($ option ->getType () === 'area ' ) {
576
- $ assertionMap = array_merge (
577
- $ assertionMap ,
578
- [
579
- ['response_field ' => 'max_characters ' , 'expected_value ' => $ option ->getMaxCharacters ()],
580
- ]
581
- );
654
+ $ valueKeyName = 'area_option ' ;
655
+ $ valueAssertionMap = [
656
+ ['response_field ' => 'max_characters ' , 'expected_value ' => $ option ->getMaxCharacters ()],
657
+ ];
658
+ } elseif ($ option ->getType () === 'field ' ) {
659
+ $ valueKeyName = 'field_option ' ;
660
+ $ valueAssertionMap = [
661
+ ['response_field ' => 'max_characters ' , 'expected_value ' => $ option ->getMaxCharacters ()]
662
+ ];
663
+ } else {
664
+ $ valueKeyName = 'date_option ' ;
665
+ $ valueAssertionMap = [];
582
666
}
583
667
584
- $ assertionMap = array_merge (
585
- $ assertionMap ,
668
+ $ valueAssertionMap = array_merge (
669
+ $ valueAssertionMap ,
586
670
[
587
671
['response_field ' => 'price ' , 'expected_value ' => $ option ->getPrice ()],
588
- ['response_field ' => 'price_type ' , 'expected_value ' => $ option ->getPriceType ()],
672
+ ['response_field ' => 'price_type ' , 'expected_value ' => strtoupper ( $ option ->getPriceType () )],
589
673
['response_field ' => 'sku ' , 'expected_value ' => $ option ->getSku ()]
590
674
]
591
675
);
676
+
677
+ $ this ->assertResponseFields ($ optionsArray [$ valueKeyName ], $ valueAssertionMap );
592
678
}
593
679
$ this ->assertResponseFields ($ optionsArray , $ assertionMap );
594
680
}
0 commit comments