Skip to content

Commit ca5171f

Browse files
committed
Merge remote-tracking branch 'origin/BUG#AC-2052' into GL_Mainline_PR_03012022
2 parents 986cef0 + 6cef041 commit ca5171f

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface
6060
*
6161
* @var string
6262
*/
63-
const CODE = 'ups';
63+
public const CODE = 'ups';
6464

6565
/**
6666
* Delivery Confirmation level based on origin/destination
6767
*/
68-
const DELIVERY_CONFIRMATION_SHIPMENT = 1;
68+
public const DELIVERY_CONFIRMATION_SHIPMENT = 1;
6969

70-
const DELIVERY_CONFIRMATION_PACKAGE = 2;
70+
public const DELIVERY_CONFIRMATION_PACKAGE = 2;
7171

7272
/**
7373
* Code of the carrier
@@ -91,22 +91,16 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface
9191
protected $_result;
9292

9393
/**
94-
* Base currency rate
95-
*
9694
* @var float
9795
*/
9896
protected $_baseCurrencyRate;
9997

10098
/**
101-
* Xml access request
102-
*
10399
* @var string
104100
*/
105101
protected $_xmlAccessRequest;
106102

107103
/**
108-
* Default cgi gateway url
109-
*
110104
* @var string
111105
*/
112106
protected $_defaultCgiGatewayUrl = 'https://www.ups.com/using/services/rave/qcostcgi.cgi';
@@ -154,7 +148,7 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface
154148
protected $configHelper;
155149

156150
/**
157-
* @inheritdoc
151+
* @var string[]
158152
*/
159153
protected $_debugReplacePrivateDataKeys = [
160154
'UserId',
@@ -917,7 +911,7 @@ protected function _parseXmlResponse($xmlResponse)
917911
$success = (int)$arr[0];
918912
if ($success === 1) {
919913
$arr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment");
920-
$allowedMethods = explode(",", $this->getConfigData('allowed_methods'));
914+
$allowedMethods = explode(",", $this->getConfigData('allowed_methods') ?? '');
921915

922916
// Negotiated rates
923917
$negotiatedArr = $xml->getXpath("//RatingServiceSelectionResponse/RatedShipment/NegotiatedRates");
@@ -1356,11 +1350,8 @@ public function getResponse()
13561350
}
13571351
}
13581352
}
1359-
if (empty($statuses)) {
1360-
$statuses = __('Empty response');
1361-
}
13621353

1363-
return $statuses;
1354+
return $statuses ?: __('Empty response');
13641355
}
13651356

13661357
/**

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,44 @@ public function testCollectRates(int $negotiable, int $tax, int $responseId, str
206206
$this->assertTrue($requestFound);
207207
}
208208

209+
/**
210+
* Test collect rates function without any allowed methods set.
211+
*
212+
* @return void
213+
* @magentoConfigFixture default_store shipping/origin/country_id GB
214+
* @magentoConfigFixture default_store carriers/ups/type UPS_XML
215+
* @magentoConfigFixture default_store carriers/ups/active 1
216+
* @magentoConfigFixture default_store carriers/ups/shipper_number 12345
217+
* @magentoConfigFixture default_store carriers/ups/origin_shipment Shipments Originating in the European Union
218+
* @magentoConfigFixture default_store carriers/ups/username user
219+
* @magentoConfigFixture default_store carriers/ups/password pass
220+
* @magentoConfigFixture default_store carriers/ups/access_license_number acn
221+
* @magentoConfigFixture default_store carriers/ups/debug 1
222+
* @magentoConfigFixture default_store currency/options/allow GBP,USD,EUR
223+
* @magentoConfigFixture default_store currency/options/base GBP
224+
*/
225+
public function testCollectRatesWithoutAnyAllowedMethods(): void
226+
{
227+
$request = Bootstrap::getObjectManager()->create(
228+
RateRequest::class,
229+
[
230+
'data' => [
231+
'dest_country' => 'GB',
232+
'dest_postal' => '01104',
233+
'product' => '11',
234+
'action' => 'Rate',
235+
'unit_measure' => 'KGS',
236+
'base_currency' => new DataObject(['code' => 'GBP'])
237+
]
238+
]
239+
);
240+
$this->config->setValue('carriers/ups/allowed_methods', '', 'store');
241+
$rates = $this->carrier->collectRates($request)->getAllRates();
242+
$this->assertInstanceOf(Error::class, current($rates));
243+
$this->assertEquals(current($rates)['carrier_title'], $this->carrier->getConfigData('title'));
244+
$this->assertEquals(current($rates)['error_message'], $this->carrier->getConfigData('specificerrmsg'));
245+
}
246+
209247
/**
210248
* Get list of rates variations
211249
*

0 commit comments

Comments
 (0)