Skip to content

Commit d947d79

Browse files
committed
Merge remote-tracking branch 'origin/AC-8838' into BUG#AC-8834
2 parents 573c59d + 7241c9e commit d947d79

File tree

2 files changed

+349
-25
lines changed

2 files changed

+349
-25
lines changed

dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php

+50-25
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
use Magento\Framework\HTTP\AsyncClient\Response;
1515
use Magento\Framework\HTTP\AsyncClientInterface;
1616
use Magento\Quote\Model\Quote\Address\RateRequest;
17+
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
1718
use Magento\Quote\Model\Quote\Address\RateResult\Error;
19+
use Magento\Shipping\Model\Shipment\Request;
1820
use Magento\TestFramework\Helper\Bootstrap;
19-
use Magento\Quote\Model\Quote\Address\RateRequestFactory;
2021
use Magento\TestFramework\HTTP\AsyncClientInterfaceMock;
21-
use PHPUnit\Framework\TestCase;
2222
use PHPUnit\Framework\MockObject\MockObject;
23-
use Magento\Shipping\Model\Shipment\Request;
23+
use PHPUnit\Framework\TestCase;
2424
use Psr\Log\LoggerInterface;
2525

2626
/**
@@ -113,29 +113,54 @@ public function testGetShipConfirmUrlLive()
113113
}
114114

115115
/**
116-
* Collect free rates.
116+
* Collect rates for UPS Ground method.
117117
*
118118
* @magentoConfigFixture current_store carriers/ups/active 1
119-
* @magentoConfigFixture current_store carriers/ups/type UPS
120-
* @magentoConfigFixture current_store carriers/ups/allowed_methods 1DA,GND
121-
* @magentoConfigFixture current_store carriers/ups/free_method GND
119+
* @magentoConfigFixture current_store carriers/ups/type UPS_XML
120+
* @magentoConfigFixture current_store carriers/ups/allowed_methods 03
121+
* @magentoConfigFixture current_store carriers/ups/free_method 03
122+
* @magentoConfigFixture default_store carriers/ups/shipper_number 12345
123+
* @magentoConfigFixture default_store carriers/ups/origin_shipment Shipments Originating in the United States
124+
* @magentoConfigFixture default_store carriers/ups/username user
125+
* @magentoConfigFixture default_store carriers/ups/password pass
126+
* @magentoConfigFixture default_store carriers/ups/access_license_number acn
127+
* @magentoConfigFixture default_store carriers/ups/debug 1
128+
* @magentoConfigFixture default_store currency/options/allow USD,EUR
129+
* @magentoConfigFixture default_store currency/options/base USD
122130
*/
123131
public function testCollectFreeRates()
124132
{
125-
$rateRequest = Bootstrap::getObjectManager()->get(RateRequestFactory::class)->create();
126-
$rateRequest->setDestCountryId('US');
127-
$rateRequest->setDestRegionId('CA');
128-
$rateRequest->setDestPostcode('90001');
129-
$rateRequest->setPackageQty(1);
130-
$rateRequest->setPackageWeight(1);
131-
$rateRequest->setFreeMethodWeight(0);
132-
$rateRequest->setLimitCarrier($this->carrier::CODE);
133-
$rateRequest->setFreeShipping(true);
134-
$rateResult = $this->carrier->collectRates($rateRequest);
135-
$result = $rateResult->asArray();
136-
$methods = $result[$this->carrier::CODE]['methods'];
137-
$this->assertEquals(0, $methods['GND']['price']);
138-
$this->assertNotEquals(0, $methods['1DA']['price']);
133+
$request = Bootstrap::getObjectManager()->create(
134+
RateRequest::class,
135+
[
136+
'data' => [
137+
'dest_country' => 'US',
138+
'dest_postal' => '90001',
139+
'package_weight' => '1',
140+
'package_qty' => '1',
141+
'free_method_weight' => '5',
142+
'product' => '11',
143+
'action' => 'Rate',
144+
'unit_measure' => 'KGS',
145+
'free_shipping' => '1',
146+
'base_currency' => new DataObject(['code' => 'USD'])
147+
]
148+
]
149+
);
150+
//phpcs:disable Magento2.Functions.DiscouragedFunction
151+
$this->httpClient->nextResponses(
152+
[
153+
new Response(
154+
200,
155+
[],
156+
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option9.xml")
157+
)
158+
]
159+
);
160+
161+
$rates = $this->carrier->collectRates($request)->getAllRates();
162+
$this->assertEquals('19.19', $rates[0]->getPrice());
163+
$this->assertEquals('03', $rates[0]->getMethod());
139164
}
140165

141166
/**
@@ -181,7 +206,7 @@ public function testCollectRates(int $negotiable, int $tax, int $responseId, str
181206
new Response(
182207
200,
183208
[],
184-
file_get_contents(__DIR__ ."/../_files/ups_rates_response_option$responseId.xml")
209+
file_get_contents(__DIR__ . "/../_files/ups_rates_response_option$responseId.xml")
185210
)
186211
]
187212
);
@@ -283,9 +308,9 @@ public function collectRatesDataProvider()
283308
public function testRequestToShipment(): void
284309
{
285310
//phpcs:disable Magento2.Functions.DiscouragedFunction
286-
$expectedShipmentRequest = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmRequest.xml');
287-
$shipmentResponse = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmResponse.xml');
288-
$acceptResponse = file_get_contents(__DIR__ .'/../_files/ShipmentAcceptResponse.xml');
311+
$expectedShipmentRequest = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmRequest.xml');
312+
$shipmentResponse = file_get_contents(__DIR__ . '/../_files/ShipmentConfirmResponse.xml');
313+
$acceptResponse = file_get_contents(__DIR__ . '/../_files/ShipmentAcceptResponse.xml');
289314
//phpcs:enable Magento2.Functions.DiscouragedFunction
290315
$this->httpClient->nextResponses(
291316
[

0 commit comments

Comments
 (0)