@@ -381,84 +381,11 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
381
381
}
382
382
QUERY ;
383
383
$ 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 ' );
386
386
$ this ->graphQlQuery ($ query );
387
387
}
388
388
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
-
462
389
/**
463
390
* Requesting for items that match a specific SKU or NAME within a certain price range sorted by Price in ASC order
464
391
*
@@ -549,71 +476,55 @@ public function testQueryProductsInCurrentPageSortedByPriceASC()
549
476
}
550
477
551
478
/**
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
553
480
*
554
481
* @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php
555
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
556
482
*/
557
- public function testFilterProductsInNextPageSortedByNameASC ()
483
+ public function testQueryProductsSortedByNameASC ()
558
484
{
559
485
$ query
560
486
= <<<QUERY
561
487
{
562
488
products(
563
489
filter:
564
490
{
565
- price:{gt: "5", lt: "50"}
566
- or:
567
- {
568
- sku:{eq:"simple1"}
569
- name:{like:"configurable%"}
570
- }
491
+ sku:{in:["simple2", "simple1"]}
571
492
}
572
- pageSize:4
493
+ pageSize:1
573
494
currentPage:2
574
495
sort:
575
496
{
576
- name:ASC
497
+ name:ASC
577
498
}
578
499
)
579
500
{
580
501
items
581
502
{
582
503
sku
583
- price {
584
- minimalPrice {
585
- amount {
586
- value
587
- currency
588
- }
589
- }
590
- }
591
504
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
+ {
601
509
page_size
602
- }
510
+ current_page
511
+ }
603
512
}
604
513
}
605
514
QUERY ;
606
515
/**
607
516
* @var ProductRepositoryInterface $productRepository
608
517
*/
609
518
$ productRepository = ObjectManager::getInstance ()->get (ProductRepositoryInterface::class);
610
- $ product = $ productRepository ->get ('simple1 ' );
611
- $ filteredProducts = [$ product ];
519
+ $ product = $ productRepository ->get ('simple2 ' );
612
520
613
521
$ 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
+ );
617
528
}
618
529
619
530
/**
@@ -1132,8 +1043,8 @@ public function testQueryPageOutOfBoundException()
1132
1043
QUERY ;
1133
1044
1134
1045
$ 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. ' );
1137
1048
$ this ->graphQlQuery ($ query );
1138
1049
}
1139
1050
0 commit comments