6 declare(strict_types=1);
23 public function testQueryAllFieldsVirtualProduct()
25 $productSku =
'virtual-product';
30 products(filter: {sku: {eq:
"$productSku"}})
40 ...
on PhysicalProductInterface {
43 ...
on VirtualProduct {
63 $product->getData($metadataPool->getMetadata(ProductInterface::class)->getLinkField())
65 $this->assertArrayHasKey(
'products',
$response);
66 $this->assertArrayHasKey(
'items',
$response[
'products']);
67 $this->assertEquals(1, count(
$response[
'products'][
'items']));
68 $this->assertArrayHasKey(0,
$response[
'products'][
'items']);
70 $this->assertArrayNotHasKey(
73 "response does contain the key weight" 84 $productSku =
'virtual-product';
89 products(filter: {sku: {eq:
"$productSku"}})
99 ...
on PhysicalProductInterface {
102 ...
on VirtualProduct {
114 $this->expectException(\Exception::class);
115 $this->expectExceptionMessage(
116 'GraphQL response contains errors: Cannot query field "weight" on type "VirtualProduct"' 125 private function assertBaseFields(
$product, $actualResponse)
128 [
'response_field' =>
'attribute_set_id',
'expected_value' =>
$product->getAttributeSetId()],
129 [
'response_field' =>
'id',
'expected_value' =>
$product->getId()],
130 [
'response_field' =>
'name',
'expected_value' =>
$product->getName()],
131 [
'response_field' =>
'sku',
'expected_value' =>
$product->getSku()],
132 [
'response_field' =>
'type_id',
'expected_value' =>
$product->getTypeId()]
assertResponseFields($actualResponse, $assertionMap)
taxRateField this edit on("click.mselect-delete", ".mselect-delete", function() { if(!confirm('<?=/*@escapeNotVerified */__( 'Do you really want to delete this tax rate?') ?>')) { return;} var that=$(this), select=that.closest('.mselect-list').prev(), rateValue=that.parent().find( 'input[type="checkbox"]').val();$( 'body').trigger( 'processStart');var ajaxOptions={ type:'POST', data:{ tax_calculation_rate_id:rateValue, form_key:$( 'input[name="form_key"]').val() }, dataType:'json', url:'<?=/*@escapeNotVerified */$block->getTaxRateDeleteUrl() ?>', success:function(result, status) { $( 'body').trigger( 'processStop');if(result.success) { that.parent().remove();select.find( 'option').each(function() { if(this.value===rateValue) { $(this).remove();} });select.trigger( 'change.hiddenSelect');} else { if(result.error_message) alert({ content:result.error_message });else alert({ content:'<?=/*@escapeNotVerified */__( 'An error occurred') ?>' });} }, error:function() { $( 'body').trigger( 'processStop');alert({ content:'<?=/*@escapeNotVerified */__( 'An error occurred') ?>' });} };$.ajax(ajaxOptions);}) .on( 'click.mselectAdd'
testCannotQueryWeightOnVirtualProductException()
graphQlQuery(string $query, array $variables=[], string $operationName='', array $headers=[])