Skip to content

Commit ad33ac2

Browse files
author
Eric Bohanon
committed
MAGETWO-82674: GraphQL Full Text Search
- Fix tests
1 parent c304562 commit ad33ac2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ public function getResult(SearchCriteriaInterface $searchCriteria)
6565
{
6666
$realPageSize = $searchCriteria->getPageSize();
6767
$realCurrentPage = $searchCriteria->getCurrentPage();
68+
// Current page must be set to 0 and page size to max for search to grab all ID's as temporary workaround
69+
// for MAGETWO-85611
6870
$searchCriteria->setPageSize(PHP_INT_MAX);
69-
// Search starts pages from 0, whereas filtering starts at 1. GraphQL's query starts at 1, so it must be altered
70-
$searchCriteria->setCurrentPage($realCurrentPage - 1);
71+
$searchCriteria->setCurrentPage(0);
7172
$itemsResults = $this->search->search($searchCriteria);
7273

7374
$ids = [];

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ public function testFilterVisibleProductsWithMatchingSkuOrNameWithSpecialPrice()
151151
* pageSize = total_count and current page = 2
152152
* expected - error is thrown
153153
* Actual - empty array
154-
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
154+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
155+
*
156+
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
155157
*/
156158

157159
public function testSearchWithFilterWithPageSizeEqualTotalCount()
@@ -208,8 +210,10 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
208210
}
209211

210212
/**
211-
the query returns a total_count of 2 records; setting the pageSize = 1 and currentPage2
213+
* The query returns a total_count of 2 records; setting the pageSize = 1 and currentPage2
212214
* Expected result is to get the second product from the list on the second page
215+
*
216+
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
213217
*/
214218
public function testSearchWithFilterPageSizeLessThanCurrentPage()
215219
{
@@ -262,7 +266,7 @@ public function testSearchWithFilterPageSizeLessThanCurrentPage()
262266
* @var ProductRepositoryInterface $productRepository
263267
*/
264268
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
265-
$product = $productRepository->get('simple1');
269+
$product = $productRepository->get('simple2');
266270
$filteredProducts = [$product];
267271

268272
$response = $this->graphQlQuery($query);

0 commit comments

Comments
 (0)