@@ -381,8 +381,10 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381
381
}
382
382
QUERY ;
383
383
$ this ->expectException (\Exception::class);
384
- $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 2 specified is greater ' .
385
- 'than the 1 page(s) available ' );
384
+ $ this ->expectExceptionMessage (
385
+ 'GraphQL response contains errors: currentPage value 2 specified is greater ' .
386
+ 'than the 1 page(s) available '
387
+ );
386
388
$ this ->graphQlQuery ($ query );
387
389
}
388
390
@@ -1043,8 +1045,10 @@ public function testQueryPageOutOfBoundException()
1043
1045
QUERY ;
1044
1046
1045
1047
$ this ->expectException (\Exception::class);
1046
- $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 2 specified is greater ' .
1047
- 'than the 1 page(s) available. ' );
1048
+ $ this ->expectExceptionMessage (
1049
+ 'GraphQL response contains errors: currentPage value 2 specified is greater ' .
1050
+ 'than the 1 page(s) available. '
1051
+ );
1048
1052
$ this ->graphQlQuery ($ query );
1049
1053
}
1050
1054
@@ -1075,8 +1079,10 @@ public function testQueryWithNoSearchOrFilterArgumentException()
1075
1079
QUERY ;
1076
1080
1077
1081
$ this ->expectException (\Exception::class);
1078
- $ this ->expectExceptionMessage ('GraphQL response contains errors: \'search \' or \'filter \' input argument is ' .
1079
- 'required. ' );
1082
+ $ this ->expectExceptionMessage (
1083
+ 'GraphQL response contains errors: \'search \' or \'filter \' input argument is ' .
1084
+ 'required. '
1085
+ );
1080
1086
$ this ->graphQlQuery ($ query );
1081
1087
}
1082
1088
@@ -1131,6 +1137,66 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
1131
1137
$ this ->assertEquals (1 , $ response ['products ' ]['total_count ' ]);
1132
1138
}
1133
1139
1140
+ /**
1141
+ * Verify that invalid page numbers return an error
1142
+ *
1143
+ * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1144
+ * @expectedException \Exception
1145
+ * @expectedExceptionMessage currentPage value must be greater than 0
1146
+ */
1147
+ public function testInvalidPageNumbers ()
1148
+ {
1149
+ $ query = <<<QUERY
1150
+ {
1151
+ products (
1152
+ filter: {
1153
+ sku: {
1154
+ like:"simple%"
1155
+ }
1156
+ }
1157
+ pageSize: 4
1158
+ currentPage: 0
1159
+ ) {
1160
+ items {
1161
+ sku
1162
+ }
1163
+ }
1164
+ }
1165
+ QUERY ;
1166
+
1167
+ $ this ->graphQlQuery ($ query );
1168
+ }
1169
+
1170
+ /**
1171
+ * Verify that invalid page size returns an error
1172
+ *
1173
+ * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1174
+ * @expectedException \Exception
1175
+ * @expectedExceptionMessage pageSize value must be greater than 0
1176
+ */
1177
+ public function testInvalidPageSize ()
1178
+ {
1179
+ $ query = <<<QUERY
1180
+ {
1181
+ products (
1182
+ filter: {
1183
+ sku: {
1184
+ like:"simple%"
1185
+ }
1186
+ }
1187
+ pageSize: 0
1188
+ currentPage: 1
1189
+ ) {
1190
+ items {
1191
+ sku
1192
+ }
1193
+ }
1194
+ }
1195
+ QUERY ;
1196
+
1197
+ $ this ->graphQlQuery ($ query );
1198
+ }
1199
+
1134
1200
/**
1135
1201
* Asserts the different fields of items returned after search query is executed
1136
1202
*
@@ -1140,7 +1206,7 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
1140
1206
private function assertProductItems (array $ filteredProducts , array $ actualResponse )
1141
1207
{
1142
1208
$ productItemsInResponse = array_map (null , $ actualResponse ['products ' ]['items ' ], $ filteredProducts );
1143
-
1209
+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
1144
1210
for ($ itemIndex = 0 ; $ itemIndex < count ($ filteredProducts ); $ itemIndex ++) {
1145
1211
$ this ->assertNotEmpty ($ productItemsInResponse [$ itemIndex ]);
1146
1212
$ this ->assertResponseFields (
0 commit comments