Skip to content

Commit 5c7b277

Browse files
committed
Merge branch 'MSI-2288' of github.com:magento-engcom/magento2ce into 2.3-tests-mainline-pr
2 parents 650ff3a + f82af34 commit 5c7b277

File tree

7 files changed

+77
-10
lines changed

7 files changed

+77
-10
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Category/Products.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public function resolve(
6666
]
6767
];
6868
$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+
if ($args['pageSize'] < 1) {
73+
throw new GraphQlInputException(__('pageSize value must be greater than 0.'));
74+
}
6975
$searchCriteria->setCurrentPage($args['currentPage']);
7076
$searchCriteria->setPageSize($args['pageSize']);
7177
$searchResult = $this->filterQuery->getResult($searchCriteria, $info);

app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public function resolve(
7171
array $args = null
7272
) {
7373
$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+
if ($args['pageSize'] < 1) {
78+
throw new GraphQlInputException(__('pageSize value must be greater than 0.'));
79+
}
7480
$searchCriteria->setCurrentPage($args['currentPage']);
7581
$searchCriteria->setPageSize($args['pageSize']);
7682
if (!isset($args['search']) && !isset($args['filter'])) {

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private function paginateList(SearchResult $searchResult, SearchCriteriaInterfac
144144
$offset = $length * ($searchCriteria->getCurrentPage() - 1);
145145

146146
if ($searchCriteria->getPageSize()) {
147-
$maxPages = ceil($searchResult->getTotalCount() / $searchCriteria->getPageSize()) - 1;
147+
$maxPages = ceil($searchResult->getTotalCount() / $searchCriteria->getPageSize());
148148
} else {
149149
$maxPages = 0;
150150
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,64 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings()
11371137
$this->assertEquals(1, $response['products']['total_count']);
11381138
}
11391139

1140+
/**
1141+
* Verify that invalid current page 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 testInvalidCurrentPage()
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+
$this->graphQlQuery($query);
1167+
}
1168+
1169+
/**
1170+
* Verify that invalid page size returns an error.
1171+
*
1172+
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
1173+
* @expectedException \Exception
1174+
* @expectedExceptionMessage pageSize value must be greater than 0
1175+
*/
1176+
public function testInvalidPageSize()
1177+
{
1178+
$query = <<<QUERY
1179+
{
1180+
products (
1181+
filter: {
1182+
sku: {
1183+
like:"simple%"
1184+
}
1185+
}
1186+
pageSize: 0
1187+
currentPage: 1
1188+
) {
1189+
items {
1190+
sku
1191+
}
1192+
}
1193+
}
1194+
QUERY;
1195+
$this->graphQlQuery($query);
1196+
}
1197+
11401198
/**
11411199
* Asserts the different fields of items returned after search query is executed
11421200
*

dev/tests/integration/testsuite/Magento/Bundle/Model/Product/DynamicBundlePriceCalculatorWithDimensionTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@
99

1010
/**
1111
* @magentoDbIsolation disabled
12+
* @magentoAppIsolation enabled
1213
* @magentoIndexerDimensionMode catalog_product_price website_and_customer_group
1314
* @group indexer_dimension
14-
* @magentoAppArea frontend
1515
*/
1616
class DynamicBundlePriceCalculatorWithDimensionTest extends BundlePriceAbstract
1717
{
1818
/**
1919
* @param array $strategyModifiers
2020
* @param array $expectedResults
2121
* @dataProvider getTestCases
22-
* @magentoAppIsolation enabled
2322
* @magentoDataFixture Magento/Bundle/_files/PriceCalculator/dynamic_bundle_product.php
24-
* @magentoDbIsolation disabled
2523
*/
2624
public function testPriceForDynamicBundle(array $strategyModifiers, array $expectedResults)
2725
{
@@ -57,10 +55,8 @@ public function testPriceForDynamicBundle(array $strategyModifiers, array $expec
5755
* @param array $strategyModifiers
5856
* @param array $expectedResults
5957
* @dataProvider getTestCases
60-
* @magentoAppIsolation enabled
6158
* @magentoConfigFixture current_store catalog/price/scope 1
6259
* @magentoDataFixture Magento/Bundle/_files/PriceCalculator/dynamic_bundle_product.php
63-
* @magentoDbIsolation disabled
6460
*/
6561
public function testPriceForDynamicBundleInWebsiteScope(array $strategyModifiers, array $expectedResults)
6662
{

dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,4 @@ Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/
215215
Magento/Elasticsearch6/Model/Client
216216
Magento/Config/App/Config/Type
217217
Magento/InventoryReservationCli/Test/Integration
218+
Magento/InventoryAdminUi/Controller/Adminhtml

0 commit comments

Comments
 (0)