@@ -381,8 +381,10 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381381}
382382QUERY ;
383383 $ 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+ );
386388 $ this ->graphQlQuery ($ query );
387389 }
388390
@@ -1043,8 +1045,10 @@ public function testQueryPageOutOfBoundException()
10431045QUERY ;
10441046
10451047 $ 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+ );
10481052 $ this ->graphQlQuery ($ query );
10491053 }
10501054
@@ -1075,8 +1079,10 @@ public function testQueryWithNoSearchOrFilterArgumentException()
10751079QUERY ;
10761080
10771081 $ 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+ );
10801086 $ this ->graphQlQuery ($ query );
10811087 }
10821088
@@ -1131,6 +1137,66 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
11311137 $ this ->assertEquals (1 , $ response ['products ' ]['total_count ' ]);
11321138 }
11331139
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+
11341200 /**
11351201 * Asserts the different fields of items returned after search query is executed
11361202 *
@@ -1140,7 +1206,7 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
11401206 private function assertProductItems (array $ filteredProducts , array $ actualResponse )
11411207 {
11421208 $ productItemsInResponse = array_map (null , $ actualResponse ['products ' ]['items ' ], $ filteredProducts );
1143-
1209+ // phpcs:ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall
11441210 for ($ itemIndex = 0 ; $ itemIndex < count ($ filteredProducts ); $ itemIndex ++) {
11451211 $ this ->assertNotEmpty ($ productItemsInResponse [$ itemIndex ]);
11461212 $ this ->assertResponseFields (
0 commit comments