Skip to content

Commit 915c1de

Browse files
committed
fixed Unit tests and static tests failures
1 parent b1b28ae commit 915c1de

File tree

3 files changed

+12
-72
lines changed

3 files changed

+12
-72
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,8 @@ protected function _getQuotes()
600600

601601
if ($params['49_residential'] === '01') {
602602
$residentialAddressIndicator = $params['49_residential'];
603+
} else {
604+
$residentialAddressIndicator = '';
603605
}
604606

605607
$rateParams = [
@@ -841,7 +843,6 @@ protected function _parseRestResponse($rateResponse)
841843
* @param array $costArr
842844
* @param array $priceArr
843845
* @param bool $negotiatedActive
844-
* @param array $rateResponseData
845846
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
846847
*/
847848
private function processShippingRateForItem(
@@ -850,8 +851,7 @@ private function processShippingRateForItem(
850851
array $allowedCurrencies,
851852
array &$costArr,
852853
array &$priceArr,
853-
bool $negotiatedActive,
854-
array $rateResponseData
854+
bool $negotiatedActive
855855
): void {
856856
$code = $shipElement['Service']['Code'] ?? '';
857857
if (in_array($code, $allowedMethods)) {
@@ -1196,12 +1196,9 @@ public function getResponse()
11961196
public function getAllowedMethods()
11971197
{
11981198
$allowedMethods = explode(',', (string)$this->getConfigData('allowed_methods'));
1199-
$isUpsXml = $this->getConfigData('type') === 'UPS_API';
12001199
$origin = $this->getConfigData('origin_shipment');
12011200

1202-
$availableByTypeMethods = $isUpsXml
1203-
? $this->configHelper->getCode('originShipment', $origin)
1204-
: $this->configHelper->getCode('method');
1201+
$availableByTypeMethods = $this->configHelper->getCode('originShipment', $origin);
12051202

12061203
$methods = [];
12071204
foreach ($availableByTypeMethods as $methodCode => $methodData) {
@@ -1564,7 +1561,7 @@ private function requestQuotes(DataObject $request): array
15641561
$this->_prepareShipmentRequest($request);
15651562
$rawJsonRequest = $this->_formShipmentRequest($request);
15661563
$accessToken = $this->setAPIAccessRequest();
1567-
$this->_debug(['request_quote' => $this->filterDebugData($rawJsonRequest)]);
1564+
$this->_debug(['request_quote' => $rawJsonRequest]);
15681565
$headers = [
15691566
'Content-Type' => 'application/json',
15701567
'Authorization' => 'Bearer '. $accessToken,
@@ -1626,7 +1623,7 @@ protected function _doShipmentRequest(DataObject $request)
16261623
$this->_prepareShipmentRequest($request);
16271624
$result = new DataObject();
16281625
$rawXmlRequest = $this->_formShipmentRequest($request);
1629-
$this->setXMLAccessRequest();
1626+
//$this->setXMLAccessRequest();
16301627
$xmlRequest = $this->_xmlAccessRequest . $rawXmlRequest;
16311628
$xmlResponse = $this->_getCachedQuotes($xmlRequest);
16321629
$debugData = [];

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
27

38
namespace Magento\Ups\Model;
49

@@ -9,9 +14,6 @@
914
use Magento\Framework\Serialize\Serializer\Json;
1015
use Magento\Store\Model\StoreManagerInterface;
1116

12-
/**
13-
* UPS OAuth Token
14-
*/
1517
class UpsOauth
1618
{
1719
/**

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

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ protected function setUp(): void
137137
$this->countryFactory->method('create')
138138
->willReturn($this->country);
139139

140-
$xmlFactory = $this->getXmlFactory();
141140
$httpClientFactory = $this->getHttpClientFactory();
142141

143142
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
@@ -154,7 +153,6 @@ protected function setUp(): void
154153
'rateErrorFactory' => $this->errorFactory,
155154
'countryFactory' => $this->countryFactory,
156155
'rateFactory' => $rateFactory,
157-
'xmlElFactory' => $xmlFactory,
158156
'logger' => $this->logger,
159157
'httpClientFactory' => $httpClientFactory,
160158
'configHelper' => $this->configHelper
@@ -178,11 +176,9 @@ public function scopeConfigGetValue(string $path)
178176
'carriers/ups/title' => 'ups Title',
179177
'carriers/ups/specificerrmsg' => 'ups error message',
180178
'carriers/ups/min_package_weight' => 2,
181-
'carriers/ups/type' => 'UPS',
182179
'carriers/ups/debug' => 1,
183180
'carriers/ups/username' => 'user',
184-
'carriers/ups/password' => 'pass',
185-
'carriers/ups/access_license_number' => 'acn'
181+
'carriers/ups/password' => 'pass'
186182
];
187183

188184
return $pathMap[$path] ?? null;
@@ -546,7 +542,6 @@ public function getCountryById(?string $id): Country
546542
}
547543

548544
/**
549-
* @param string $carrierType
550545
* @param string $methodType
551546
* @param string $methodCode
552547
* @param string $methodTitle
@@ -557,7 +552,6 @@ public function getCountryById(?string $id): Country
557552
* @dataProvider allowedMethodsDataProvider
558553
*/
559554
public function testGetAllowedMethods(
560-
string $carrierType,
561555
string $methodType,
562556
string $methodCode,
563557
string $methodTitle,
@@ -573,12 +567,6 @@ public function testGetAllowedMethods(
573567
null,
574568
$allowedMethods
575569
],
576-
[
577-
'carriers/ups/type',
578-
ScopeInterface::SCOPE_STORE,
579-
null,
580-
$carrierType
581-
],
582570
[
583571
'carriers/ups/origin_shipment',
584572
ScopeInterface::SCOPE_STORE,
@@ -601,23 +589,6 @@ public function allowedMethodsDataProvider(): array
601589
{
602590
return [
603591
[
604-
'UPS',
605-
'method',
606-
'1DM',
607-
'Next Day Air Early AM',
608-
'',
609-
[]
610-
],
611-
[
612-
'UPS',
613-
'method',
614-
'1DM',
615-
'Next Day Air Early AM',
616-
'1DM,1DML,1DA',
617-
['1DM' => 'Next Day Air Early AM']
618-
],
619-
[
620-
'UPS_XML',
621592
'originShipment',
622593
'01',
623594
'UPS Next Day Air',
@@ -627,36 +598,6 @@ public function allowedMethodsDataProvider(): array
627598
];
628599
}
629600

630-
/**
631-
* Creates mock for XML factory.
632-
*
633-
* @return ElementFactory|MockObject
634-
*/
635-
private function getXmlFactory(): MockObject
636-
{
637-
$xmlElFactory = $this->getMockBuilder(ElementFactory::class)
638-
->disableOriginalConstructor()
639-
->onlyMethods(['create'])
640-
->getMock();
641-
$xmlElFactory->method('create')
642-
->willReturnCallback(
643-
function ($data) {
644-
$helper = new ObjectManager($this);
645-
646-
if (empty($data['data'])) {
647-
$data['data'] = '<?xml version = "1.0" ?><ShipmentAcceptRequest/>';
648-
}
649-
650-
return $helper->getObject(
651-
Element::class,
652-
['data' => $data['data']]
653-
);
654-
}
655-
);
656-
657-
return $xmlElFactory;
658-
}
659-
660601
/**
661602
* Creates mocks for http client factory and client.
662603
*

0 commit comments

Comments
 (0)