Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExceptionFormatterDefaultModeTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
13 {
15  {
16  $query
17  = <<<QUERY
18  {
19  customAttributeMetadata(attributes:[
20  {
21  entity_type:"catalog_category"
22  entity_type:"catalog_product"
23  }
24  ])
25  {
26  items{
27  attribute_code
28  attribute_type
29  entity_type
30  }
31  }
32  }
33 QUERY;
34  $this->expectException(\Exception::class);
35  $this->expectExceptionMessage('GraphQL response contains errors: There' . ' ' .
36  'can be only one input field named "entity_type"');
37  $this->graphQlQuery($query);
38  }
39 
41  {
42  $query
43  = <<<QUERY
44  {
45  customAttributeMetadata(attributes:[
46  {
47 
48  }
49  ])
50  {
51  items{
52  attribute_code
53  attribute_type
54  entity_type
55  }
56  }
57  }
58 QUERY;
59  $this->expectException(\Exception::class);
60  $this->expectExceptionMessage('GraphQL response contains errors: Missing attribute_code/entity_type for the ' .
61  'input Empty AttributeInput.');
62 
63  $this->graphQlQuery($query);
64  }
66  {
67  $query
68  = <<<QUERY
69  {
70  customAttributeMetadata(attributes:[
71  {
72  attribute_code:"sku"
73  }
74  ])
75  {
76  items{
77  attribute_code
78  attribute_type
79  entity_type
80  }
81  }
82  }
83 QUERY;
84  $this->expectException(\Exception::class);
85  $this->expectExceptionMessage('GraphQL response contains errors: Missing entity_type for the input' .
86  ' attribute_code: sku.');
87 
88  $this->graphQlQuery($query);
89  }
90 
92  {
93  $query
94  = <<<QUERY
95  {
96  customAttributeMetadata(attributes:[
97  {
98  entity_type:"catalog_category"
99  }
100  ])
101  {
102  items{
103  attribute_code
104  attribute_type
105  entity_type
106  }
107  }
108  }
109 QUERY;
110  $this->expectException(\Exception::class);
111  $this->expectExceptionMessage('GraphQL response contains errors: Missing attribute_code for the input ' .
112  'entity_type: catalog_category.');
113 
114  $this->graphQlQuery($query);
115  }
116 
118  {
119  $query
120  = <<<QUERY
121  {
122  customAttributeMetadata(attributes:[
123  {
124  attribute_code:"sku"
125  entity_type:"invalid"
126  }
127  ])
128  {
129  items{
130  attribute_code
131  attribute_type
132  entity_type
133  }
134  }
135  }
136 QUERY;
137  $this->expectException(\Exception::class);
138 
139  $this->expectExceptionMessage('Invalid entity_type specified: invalid');
140 
141  $this->graphQlQuery($query);
142  }
143 }
graphQlQuery(string $query, array $variables=[], string $operationName='', array $headers=[])