@@ -381,84 +381,11 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381381}
382382QUERY ;
383383 $ this ->expectException (\Exception::class);
384- $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 1 specified is greater ' .
385- 'than the number of pages available. ' );
384+ $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 2 specified is greater ' .
385+ 'than the 1 page(s) available ' );
386386 $ this ->graphQlQuery ($ query );
387387 }
388388
389- /**
390- * The query returns a total_count of 2 records; setting the pageSize = 1 and currentPage2
391- * Expected result is to get the second product on the list on the second page
392- *
393- * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
394- */
395- public function testSearchWithFilterPageSizeLessThanCurrentPage ()
396- {
397-
398- $ query
399- = <<<QUERY
400- {
401- products(
402- search : "simple"
403- filter:
404- {
405- special_price:{neq:"null"}
406- price:{lt:"60"}
407- or:
408- {
409- sku:{like:"%simple%"}
410- name:{like:"%configurable%"}
411- }
412- weight:{eq:"1"}
413- }
414- pageSize:1
415- currentPage:2
416- sort:
417- {
418- price:DESC
419- }
420- )
421- {
422- items
423- {
424- sku
425- price {
426- minimalPrice {
427- amount {
428- value
429- currency
430- }
431- }
432- }
433- name
434- ... on PhysicalProductInterface {
435- weight
436- }
437- type_id
438- attribute_set_id
439- }
440- total_count
441- page_info
442- {
443- page_size
444- }
445- }
446- }
447- QUERY ;
448- /**
449- * @var ProductRepositoryInterface $productRepository
450- */
451- $ productRepository = ObjectManager::getInstance ()->get (ProductRepositoryInterface::class);
452- // when pagSize =1 and currentPage = 2, it should have simple2 on first page and simple1 on 2nd page
453- // since sorting is done on price in the DESC order
454- $ product = $ productRepository ->get ('simple1 ' );
455- $ filteredProducts = [$ product ];
456-
457- $ response = $ this ->graphQlQuery ($ query );
458- $ this ->assertEquals (1 , $ response ['products ' ]['total_count ' ]);
459- $ this ->assertProductItems ($ filteredProducts , $ response );
460- }
461-
462389 /**
463390 * Requesting for items that match a specific SKU or NAME within a certain price range sorted by Price in ASC order
464391 *
@@ -549,71 +476,55 @@ public function testQueryProductsInCurrentPageSortedByPriceASC()
549476 }
550477
551478 /**
552- * Verify the items in the second page is correct after sorting their name in ASC order
479+ * Verify the items is correct after sorting their name in ASC order
553480 *
554481 * @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php
555- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
556482 */
557- public function testFilterProductsInNextPageSortedByNameASC ()
483+ public function testQueryProductsSortedByNameASC ()
558484 {
559485 $ query
560486 = <<<QUERY
561487{
562488 products(
563489 filter:
564490 {
565- price:{gt: "5", lt: "50"}
566- or:
567- {
568- sku:{eq:"simple1"}
569- name:{like:"configurable%"}
570- }
491+ sku:{in:["simple2", "simple1"]}
571492 }
572- pageSize:4
493+ pageSize:1
573494 currentPage:2
574495 sort:
575496 {
576- name:ASC
497+ name:ASC
577498 }
578499 )
579500 {
580501 items
581502 {
582503 sku
583- price {
584- minimalPrice {
585- amount {
586- value
587- currency
588- }
589- }
590- }
591504 name
592- type_id
593- ... on PhysicalProductInterface {
594- weight
595- }
596- attribute_set_id
597- }
598- total_count
599- page_info
600- {
505+ }
506+ total_count
507+ page_info
508+ {
601509 page_size
602- }
510+ current_page
511+ }
603512 }
604513}
605514QUERY ;
606515 /**
607516 * @var ProductRepositoryInterface $productRepository
608517 */
609518 $ productRepository = ObjectManager::getInstance ()->get (ProductRepositoryInterface::class);
610- $ product = $ productRepository ->get ('simple1 ' );
611- $ filteredProducts = [$ product ];
519+ $ product = $ productRepository ->get ('simple2 ' );
612520
613521 $ response = $ this ->graphQlQuery ($ query );
614- $ this ->assertEquals (1 , $ response ['products ' ]['total_count ' ]);
615- $ this ->assertProductItems ($ filteredProducts , $ response );
616- $ this ->assertEquals (4 , $ response ['products ' ]['page_info ' ]['page_size ' ]);
522+ $ this ->assertEquals (2 , $ response ['products ' ]['total_count ' ]);
523+ $ this ->assertEquals (['page_size ' => 1 , 'current_page ' => 2 ], $ response ['products ' ]['page_info ' ]);
524+ $ this ->assertEquals (
525+ [['sku ' => $ product ->getSku (), 'name ' => $ product ->getName ()]],
526+ $ response ['products ' ]['items ' ]
527+ );
617528 }
618529
619530 /**
@@ -1132,8 +1043,8 @@ public function testQueryPageOutOfBoundException()
11321043QUERY ;
11331044
11341045 $ this ->expectException (\Exception::class);
1135- $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 1 specified is greater ' .
1136- 'than the number of pages available. ' );
1046+ $ this ->expectExceptionMessage ('GraphQL response contains errors: currentPage value 2 specified is greater ' .
1047+ 'than the 1 page(s) available. ' );
11371048 $ this ->graphQlQuery ($ query );
11381049 }
11391050
0 commit comments