Skip to content

Commit 774a39b

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-99673: Implement deferred
1 parent 191c763 commit 774a39b

File tree

6 files changed

+30
-39
lines changed

6 files changed

+30
-39
lines changed

app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,15 @@ public function testSetRequest($countryCode, $foundCountryCode)
339339
{
340340
/** @var RateRequest $request */
341341
$request = $this->helper->getObject(RateRequest::class);
342-
$request->setData([
343-
'orig_country' => 'USA',
344-
'orig_region_code' => 'CA',
345-
'orig_post_code' => 90230,
346-
'orig_city' => 'Culver City',
347-
'dest_country_id' => $countryCode,
348-
]);
342+
$request->setData(
343+
[
344+
'orig_country' => 'USA',
345+
'orig_region_code' => 'CA',
346+
'orig_post_code' => 90230,
347+
'orig_city' => 'Culver City',
348+
'dest_country_id' => $countryCode,
349+
]
350+
);
349351

350352
$this->country->expects($this->at(1))
351353
->method('load')

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

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ private function getExpectedLabelRequestXml(
384384
return $expectedRequestElement->asXML();
385385
}
386386

387-
388387
/**
389388
* Tests that valid rates are returned when sending a quotes request.
390389
*
@@ -466,34 +465,10 @@ public function testCollectRates()
466465
/** @var RateRequest $request */
467466
$request = Bootstrap::getObjectManager()->create(RateRequest::class, $requestData);
468467
$expectedRates = [
469-
[
470-
'carrier' => 'dhl',
471-
'carrier_title' => 'DHL Title',
472-
'cost' => 45.85,
473-
'method' => 'E',
474-
'price' => 45.85
475-
],
476-
[
477-
'carrier' => 'dhl',
478-
'carrier_title' => 'DHL Title',
479-
'cost' => 35.26,
480-
'method' => 'Q',
481-
'price' => 35.26
482-
],
483-
[
484-
'carrier' => 'dhl',
485-
'carrier_title' => 'DHL Title',
486-
'cost' => 37.38,
487-
'method' => 'Y',
488-
'price' => 37.38
489-
],
490-
[
491-
'carrier' => 'dhl',
492-
'carrier_title' => 'DHL Title',
493-
'cost' => 35.26,
494-
'method' => 'P',
495-
'price' => 35.26
496-
]
468+
['carrier' => 'dhl', 'carrier_title' => 'DHL Title', 'cost' => 45.85, 'method' => 'E', 'price' => 45.85],
469+
['carrier' => 'dhl', 'carrier_title' => 'DHL Title', 'cost' => 35.26, 'method' => 'Q', 'price' => 35.26],
470+
['carrier' => 'dhl', 'carrier_title' => 'DHL Title', 'cost' => 37.38, 'method' => 'Y', 'price' => 37.38],
471+
['carrier' => 'dhl', 'carrier_title' => 'DHL Title', 'cost' => 35.26, 'method' => 'P', 'price' => 35.26]
497472
];
498473

499474
$actualRates = $this->dhlCarrier->collectRates($request)->getAllRates();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ public function collectRatesDataProvider()
207207
*/
208208
public function testRequestToShipment(): void
209209
{
210+
//phpcs:disable Magento2.Functions.DiscouragedFunction
210211
$shipmentResponse = file_get_contents(__DIR__ .'/../_files/ShipmentConfirmResponse.xml');
211212
$acceptResponse = file_get_contents(__DIR__ .'/../_files/ShipmentAcceptResponse.xml');
213+
//phpcs:enable Magento2.Functions.DiscouragedFunction
212214
$this->httpClient->nextResponses(
213215
[
214216
new Response(200, [], $shipmentResponse),

dev/tests/integration/testsuite/Magento/Usps/Fixtures/rates_request.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

dev/tests/integration/testsuite/Magento/Usps/Fixtures/response_rates.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
28
<IntlRateV2Response>
39
<Package>
410
<Service ID="12">

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ protected function setUp()
5353
*/
5454
public function testCollectRates(): void
5555
{
56-
$requestXml = (new \SimpleXMLElement(file_get_contents(__DIR__ .'/../Fixtures/rates_request.xml')))
57-
->asXml();
56+
$requestXml = '<?xml version="1.0" encoding="UTF-8"?><RateV4Request USERID="213MAGEN6752">'
57+
.'<Revision>2</Revision><Package ID="0"><Service>ALL</Service><ZipOrigination>90034</ZipOrigination>'
58+
.'<ZipDestination>90032</ZipDestination><Pounds>4</Pounds><Ounces>4.2512000000</Ounces>'
59+
.'<Container>VARIABLE</Container><Size>REGULAR</Size><Machinable>true</Machinable></Package>'
60+
.'</RateV4Request>';
61+
$requestXml = (new \SimpleXMLElement($requestXml))->asXml();
62+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
5863
$responseBody = file_get_contents(__DIR__ .'/../Fixtures/success_usps_response_rates.xml');
5964
$this->httpClient->nextResponses([new Response(200, [], $responseBody)]);
6065
/** @var RateRequest $request */
@@ -98,6 +103,7 @@ public function testCollectRates(): void
98103
$rates = $this->carrier->collectRates($request);
99104
$httpRequest = $this->httpClient->getLastRequest();
100105
$this->assertNotEmpty($httpRequest);
106+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
101107
$uri = parse_url($httpRequest->getUrl(), PHP_URL_QUERY);
102108
$this->assertNotEmpty(preg_match('/API\=([A-z0-9]+)/', $uri, $matches));
103109
$apiV = $matches[1];
@@ -129,6 +135,7 @@ public function testCollectRates(): void
129135
*/
130136
public function testCollectUnavailableRates(): void
131137
{
138+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
132139
$responseBody = file_get_contents(__DIR__ .'/../Fixtures/response_rates.xml');
133140
$this->httpClient->nextResponses([new Response(200, [], $responseBody)]);
134141
/** @var RateRequest $request */

0 commit comments

Comments
 (0)