Skip to content

Commit 8e994de

Browse files
committed
MAGETWO-82728: Implement Functional test
- Addressed additional use case to test exception
1 parent 6cbd253 commit 8e994de

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

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

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public function testFilterProductsWithinSpecificPriceRangeSortedByNameDesc()
8282
}
8383

8484
/**
85-
* Request items that are visible in Catalog, Search or Both matching SKU or NAME and price < $60 with a special price and weight = 1 sorted by price in DESC
85+
* Requesting for items that are visible in Catalog, Search or Both matching SKU or NAME
86+
* and price < $60 with a special price and weight = 1 sorted by price in DESC
8687
*
8788
* @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php
8889
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -426,6 +427,62 @@ public function testQueryFilterNoMatchingItems()
426427
$this->assertEmpty($response['products']['items'], "No items should be returned.");
427428
}
428429

430+
/**
431+
* Asserts that exception is thrown when current page > totalCount of items returned
432+
*
433+
* @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php
434+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
435+
*/
436+
public function testQueryPageOutOfBoundException()
437+
{
438+
$query
439+
= <<<QUERY
440+
{
441+
products(
442+
find:
443+
{
444+
and:
445+
{
446+
price:{eq:"10"}
447+
448+
}
449+
}
450+
pageSize:2
451+
currentPage:2
452+
sort:
453+
{
454+
name:ASC
455+
}
456+
)
457+
{
458+
items
459+
{
460+
sku
461+
price
462+
name
463+
status
464+
type_id
465+
weight
466+
visibility
467+
attribute_set_id
468+
}
469+
total_count
470+
page_info
471+
{
472+
page_size
473+
current_page
474+
}
475+
476+
}
477+
}
478+
QUERY;
479+
480+
$this->expectException(\Exception::class);
481+
$this->expectExceptionMessage('GraphQL response contains errors: The value' . ' ' .
482+
'specified in the currentPage attribute is greater than the number of pages available (1).');
483+
$this->graphQlQuery($query);
484+
}
485+
429486
/**
430487
* Asserts the different fields of items returned after search query is executed
431488
* @param $filteredProducts

dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_mixed_products_2.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@
110110
->setId($productId)
111111
->setAttributeSetId($attributeSetId)
112112
->setWebsiteIds([1])
113-
// ->setName('Configurable Option' . $option->getLabel())
114-
->setName('ConfigurableOption' .$productId .'_' . $option->getLabel())
113+
->setName('ConfigurableOption' .$productId . '_' . $option->getLabel())
115114
->setSku('simple_' . $productId)
116115
->setPrice($productId)
117116
->setWeight(2)

0 commit comments

Comments
 (0)