Skip to content

Commit 33d5d9c

Browse files
author
Prabhu Ram
committed
MC-31420: [GraphQL] Flat Rate shipping amount is returned as $10 instead of $5 for 1st configurable product in cart.
- modified customer tests
1 parent 5711910 commit 33d5d9c

File tree

4 files changed

+62
-50
lines changed

4 files changed

+62
-50
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetAvailableShippingMethodsTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ public function testGetAvailableShippingMethods()
8585
/**
8686
* Test case: get available shipping methods from current customer quote with configurable product
8787
*
88-
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php
89-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_address_quote_with_configurable_product.php
88+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
89+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
90+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_configurable_product.php
91+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
9092
*/
9193
public function testGetAvailableShippingMethodsWithConfigurableProduct()
9294
{
93-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_cart_with_configurable');
94-
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
95+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
96+
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId), [], '', $this->getHeaderMap());
9597

9698
self::assertArrayHasKey('cart', $response);
9799
self::assertArrayHasKey('shipping_addresses', $response['cart']);

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ public function testGetAvailableShippingMethods()
8484
/**
8585
* Test case: get available shipping methods from current customer quote with configurable product
8686
*
87-
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php
88-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_address_quote_with_configurable_product.php
87+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
88+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_configurable_product.php
89+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
8990
*/
9091
public function testGetAvailableShippingMethodsWithConfigurableProduct()
9192
{
92-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_cart_with_configurable');
93+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
9394
$response = $this->graphQlQuery($this->getQuery($maskedQuoteId));
9495

9596
self::assertArrayHasKey('cart', $response);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Quote\Api\CartRepositoryInterface;
10+
use Magento\Quote\Model\QuoteFactory;
11+
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
require __DIR__.'/../../../ConfigurableProduct/_files/product_configurable.php';
15+
16+
/** @var ProductRepositoryInterface $productRepository */
17+
$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
18+
/** @var QuoteFactory $quoteFactory */
19+
$quoteFactory = Bootstrap::getObjectManager()->get(QuoteFactory::class);
20+
/** @var QuoteResource $quoteResource */
21+
$quoteResource = Bootstrap::getObjectManager()->get(QuoteResource::class);
22+
/** @var CartRepositoryInterface $cartRepository */
23+
$cartRepository = Bootstrap::getObjectManager()->get(CartRepositoryInterface::class);
24+
25+
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
26+
27+
/** @var $product \Magento\Catalog\Model\Product */
28+
$productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
29+
$product = $productRepository->get('configurable');
30+
/* Create simple products per each option */
31+
/** @var $options \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */
32+
$options = Bootstrap::getObjectManager()->create(
33+
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection::class
34+
);
35+
$option = $options->setAttributeFilter($attribute->getId())->getFirstItem();
36+
37+
$requestInfo = new \Magento\Framework\DataObject(
38+
[
39+
'product' => 1,
40+
'selected_configurable_option' => 1,
41+
'qty' => 1,
42+
'super_attribute' => [
43+
$attribute->getId() => $option->getId()
44+
]
45+
]
46+
);
47+
48+
49+
$quote = $quoteFactory->create();
50+
$quoteResource->load($quote, 'test_quote', 'reserved_order_id');
51+
$quote->addProduct($product, $requestInfo);
52+
$cartRepository->save($quote);

dev/tests/integration/testsuite/Magento/GraphQl/Quote/_files/set_address_quote_with_configurable_product.php

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)