File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
app/code/Magento/CatalogGraphQl/Model/Resolver
dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ public function resolve(
66
66
]
67
67
];
68
68
$ searchCriteria = $ this ->searchCriteriaBuilder ->build ($ field ->getName (), $ args );
69
+ if ($ args ['currentPage ' ] < 1 ) {
70
+ throw new GraphQlInputException (__ ('currentPage value must be greater than 0. ' ));
71
+ }
72
+
69
73
$ searchCriteria ->setCurrentPage ($ args ['currentPage ' ]);
70
74
$ searchCriteria ->setPageSize ($ args ['pageSize ' ]);
71
75
$ searchResult = $ this ->filterQuery ->getResult ($ searchCriteria , $ info );
Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ public function resolve(
71
71
array $ args = null
72
72
) {
73
73
$ searchCriteria = $ this ->searchCriteriaBuilder ->build ($ field ->getName (), $ args );
74
+ if ($ args ['currentPage ' ] < 1 ) {
75
+ throw new GraphQlInputException (__ ('currentPage value must be greater than 0. ' ));
76
+ }
77
+
74
78
$ searchCriteria ->setCurrentPage ($ args ['currentPage ' ]);
75
79
$ searchCriteria ->setPageSize ($ args ['pageSize ' ]);
76
80
if (!isset ($ args ['search ' ]) && !isset ($ args ['filter ' ])) {
Original file line number Diff line number Diff line change @@ -1131,6 +1131,37 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
1131
1131
$ this ->assertEquals (1 , $ response ['products ' ]['total_count ' ]);
1132
1132
}
1133
1133
1134
+ /**
1135
+ * Verify that invalid page numbers return an error
1136
+ *
1137
+ * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1138
+ * @expectedException \Exception
1139
+ * @expectedExceptionMessage currentPage value must be greater than 0
1140
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1141
+ */
1142
+ public function testInvalidPageNumbers ()
1143
+ {
1144
+ $ query = <<<QUERY
1145
+ {
1146
+ products (
1147
+ filter: {
1148
+ sku: {
1149
+ like:"simple%"
1150
+ }
1151
+ }
1152
+ pageSize: 4
1153
+ currentPage: 0
1154
+ ) {
1155
+ items {
1156
+ sku
1157
+ }
1158
+ }
1159
+ }
1160
+ QUERY ;
1161
+
1162
+ $ this ->graphQlQuery ($ query );
1163
+ }
1164
+
1134
1165
/**
1135
1166
* Asserts the different fields of items returned after search query is executed
1136
1167
*
You can’t perform that action at this time.
0 commit comments