Skip to content

Commit

Permalink
Merge pull request #8317 from magento-gl/2.4.7-develop-sync-ac-8838
Browse files Browse the repository at this point in the history
AC-8838: Undefined array key GND under CarrierTest Integration Test Issue resolved
  • Loading branch information
svera authored May 30, 2023
2 parents 5676386 + 9375cb3 commit 39ec4fa
Show file tree
Hide file tree
Showing 2 changed files with 349 additions and 25 deletions.
75 changes: 50 additions & 25 deletions dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
use Magento\Framework\HTTP\AsyncClient\Response;
use Magento\Framework\HTTP\AsyncClientInterface;
use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
use Magento\Quote\Model\Quote\Address\RateResult\Error;
use Magento\Shipping\Model\Shipment\Request;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
use Magento\TestFramework\HTTP\AsyncClientInterfaceMock;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use Magento\Shipping\Model\Shipment\Request;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -113,29 +113,54 @@ public function testGetShipConfirmUrlLive()
}

/**
* Collect free rates.
* Collect rates for UPS Ground method.
*
* @magentoConfigFixture current_store carriers/ups/active 1
* @magentoConfigFixture current_store carriers/ups/type UPS
* @magentoConfigFixture current_store carriers/ups/allowed_methods 1DA,GND
* @magentoConfigFixture current_store carriers/ups/free_method GND
* @magentoConfigFixture current_store carriers/ups/type UPS_XML
* @magentoConfigFixture current_store carriers/ups/allowed_methods 03
* @magentoConfigFixture current_store carriers/ups/free_method 03
* @magentoConfigFixture default_store carriers/ups/shipper_number 12345
* @magentoConfigFixture default_store carriers/ups/origin_shipment Shipments Originating in the United States
* @magentoConfigFixture default_store carriers/ups/username user
* @magentoConfigFixture default_store carriers/ups/password pass
* @magentoConfigFixture default_store carriers/ups/access_license_number acn
* @magentoConfigFixture default_store carriers/ups/debug 1
* @magentoConfigFixture default_store currency/options/allow USD,EUR
* @magentoConfigFixture default_store currency/options/base USD
*/
public function testCollectFreeRates()
{
$rateRequest = Bootstrap::getObjectManager()->get(RateRequestFactory::class)->create();
$rateRequest->setDestCountryId('US');
$rateRequest->setDestRegionId('CA');
$rateRequest->setDestPostcode('90001');
$rateRequest->setPackageQty(1);
$rateRequest->setPackageWeight(1);
$rateRequest->setFreeMethodWeight(0);
$rateRequest->setLimitCarrier($this->carrier::CODE);
$rateRequest->setFreeShipping(true);
$rateResult = $this->carrier->collectRates($rateRequest);
$result = $rateResult->asArray();
$methods = $result[$this->carrier::CODE]['methods'];
$this->assertEquals(0, $methods['GND']['price']);
$this->assertNotEquals(0, $methods['1DA']['price']);
$request = Bootstrap::getObjectManager()->create(
RateRequest::class,
[
'data' => [
'dest_country' => 'US',
'dest_postal' => '90001',
'package_weight' => '1',
'package_qty' => '1',
'free_method_weight' => '5',
'product' => '11',
'action' => 'Rate',
'unit_measure' => 'KGS',
'free_shipping' => '1',
'base_currency' => new DataObject(['code' => 'USD'])
]
]
);
//phpcs:disable Magento2.Functions.DiscouragedFunction
$this->httpClient->nextResponses(
[
new Response(
200,
[],
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option9.xml")
)
]
);

$rates = $this->carrier->collectRates($request)->getAllRates();
$this->assertEquals('19.19', $rates[0]->getPrice());
$this->assertEquals('03', $rates[0]->getMethod());
}

/**
Expand Down Expand Up @@ -181,7 +206,7 @@ public function testCollectRates(int $negotiable, int $tax, int $responseId, str
new Response(
200,
[],
file_get_contents(__DIR__ ."/../_files/ups_rates_response_option$responseId.xml")
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option$responseId.xml")
)
]
);
Expand Down Expand Up @@ -283,9 +308,9 @@ public function collectRatesDataProvider()
public function testRequestToShipment(): void
{
//phpcs:disable Magento2.Functions.DiscouragedFunction
$expectedShipmentRequest = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmRequest.xml');
$shipmentResponse = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmResponse.xml');
$acceptResponse = file_get_contents(__DIR__ .'/../_files/ShipmentAcceptResponse.xml');
$expectedShipmentRequest = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmRequest.xml');
$shipmentResponse = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmResponse.xml');
$acceptResponse = file_get_contents(__DIR__ . '/../_files/ShipmentAcceptResponse.xml');
//phpcs:enable Magento2.Functions.DiscouragedFunction
$this->httpClient->nextResponses(
[
Expand Down
Loading

0 comments on commit 39ec4fa

Please sign in to comment.