Skip to content

Commit 459963f

Browse files
ENGCOM-8537: Fix wrong format error DHL shipping label #31021
2 parents 4d89d46 + b77b1ce commit 459963f

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed

app/code/Magento/Checkout/Test/Mftf/Test/AdminCheckConfigsChangesIsNotAffectedStartedCheckoutProcessTest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<argument name="address" value="US_Address_TX"/>
5959
</actionGroup>
6060

61+
<!-- Select Free Shipping -->
62+
<actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodFreeShipping">
63+
<argument name="shippingMethodName" value="Free Shipping"/>
64+
</actionGroup>
65+
6166
<!-- Assert Free Shipping checkbox -->
6267
<seeCheckboxIsChecked selector="{{CheckoutShippingMethodsSection.shippingMethodFreeShipping}}" stepKey="freeShippingMethodCheckboxIsChecked"/>
6368

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="selectViewAndEditCart"/>
9595

9696
<!--Assert Shopping Cart Summary-->
97-
<actionGroup ref="AssertStorefrontShoppingCartSummaryWithShippingActionGroup" stepKey="AssertCartSummary" >
97+
<actionGroup ref="StorefrontCheckCartActionGroup" stepKey="AssertCartSummary" >
9898
<argument name="subtotal" value="$100.00"/>
9999
<argument name="shipping" value="10.00"/>
100100
<argument name="total" value="110.00"/>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddOneBundleMultiSelectOptionToTheShoppingCartTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="selectViewAndEditCart"/>
8989

9090
<!--Assert Shopping Cart Summary-->
91-
<actionGroup ref="AssertStorefrontShoppingCartSummaryWithShippingActionGroup" stepKey="AssertCartSummary" >
91+
<actionGroup ref="StorefrontCheckCartActionGroup" stepKey="AssertCartSummary" >
9292
<argument name="subtotal" value="$50.00"/>
9393
<argument name="shipping" value="5.00"/>
9494
<argument name="total" value="55.00"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17561756
foreach ($package['items'] as $item) {
17571757
$content[] = $item['name'];
17581758
}
1759-
$nodePiece->addChild('PieceContents', substr(implode(',', $content), 0, 34));
1759+
$nodePiece->addChild('PieceContents', $this->string->substr(implode(',', $content), 0, 34));
17601760
}
17611761

17621762
$nodeShipmentDetails->addChild('Weight', sprintf('%.3f', $rawRequest->getPackageWeight()));
@@ -1776,7 +1776,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '')
17761776
$nodeShipmentDetails->addChild('DoorTo', 'DD');
17771777
$nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1));
17781778
$contentType = isset($package['params']['container']) ? $package['params']['container'] : '';
1779-
$packageType = $contentType === self::DHL_CONTENT_TYPE_NON_DOC ? 'CP' : '';
1779+
$packageType = $contentType === self::DHL_CONTENT_TYPE_NON_DOC ? 'CP' : 'EE';
17801780
$nodeShipmentDetails->addChild('PackageType', $packageType);
17811781
if ($this->isDutiable($rawRequest->getOrigCountryId(), $rawRequest->getDestCountryId())) {
17821782
$nodeShipmentDetails->addChild('IsDutiable', 'Y');

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

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@
1717
use Magento\Quote\Model\Quote\Address\RateRequest;
1818
use Magento\Quote\Model\Quote\Address\RateResult\Error;
1919
use Magento\Shipping\Model\Shipment\Request;
20+
use Magento\Shipping\Model\Simplexml\Element as ShippingElement;
2021
use Magento\Shipping\Model\Tracking\Result\Status;
2122
use Magento\Store\Model\ScopeInterface;
2223
use Magento\TestFramework\Helper\Bootstrap;
2324
use Magento\TestFramework\HTTP\AsyncClientInterfaceMock;
24-
use Magento\Shipping\Model\Simplexml\Element as ShippingElement;
25+
use PHPUnit\Framework\TestCase;
2526

2627
/**
2728
* Test for DHL integration.
2829
*
2930
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3031
*/
31-
class CarrierTest extends \PHPUnit\Framework\TestCase
32+
class CarrierTest extends TestCase
3233
{
34+
private const PRODUCT_NAME_SPECIAL_CHARS = 'Φυστίκι Ψημένο με Αλάτι Συσκευασία';
35+
3336
/**
3437
* @var Carrier
3538
*/
@@ -254,10 +257,16 @@ private function assertTrackingResult($expectedTrackingData, $trackingResults):
254257
* @param string $origCountryId
255258
* @param string $expectedRegionCode
256259
* @param string $destCountryId
260+
* @param bool|null $isProductNameContainsSpecialChars
261+
* @return void
257262
* @dataProvider requestToShipmentDataProvider
258263
*/
259-
public function testRequestToShip(string $origCountryId, string $expectedRegionCode, string $destCountryId): void
260-
{
264+
public function testRequestToShip(
265+
string $origCountryId,
266+
string $expectedRegionCode,
267+
string $destCountryId,
268+
bool $isProductNameContainsSpecialChars = false
269+
): void {
261270
$this->config->setValue(
262271
'shipping/origin/country_id',
263272
$origCountryId,
@@ -274,6 +283,8 @@ public function testRequestToShip(string $origCountryId, string $expectedRegionC
274283
)
275284
]
276285
);
286+
$productName = $isProductNameContainsSpecialChars ? self::PRODUCT_NAME_SPECIAL_CHARS : 'item_name';
287+
277288
//phpcs:enable Magento2.Functions.DiscouragedFunction
278289
$request = new Request(
279290
[
@@ -291,7 +302,7 @@ public function testRequestToShip(string $origCountryId, string $expectedRegionC
291302
],
292303
'items' => [
293304
'item1' => [
294-
'name' => 'item_name',
305+
'name' => $productName,
295306
],
296307
],
297308
],
@@ -329,10 +340,15 @@ public function testRequestToShip(string $origCountryId, string $expectedRegionC
329340
$requestElement->Request->ServiceHeader->MessageReference = 'MAGE_SHIP_28TO32_Char_CHECKED';
330341
$requestElement->Request->ServiceHeader->MessageTime = 'currentTime';
331342
$requestElement->ShipmentDetails->Date = 'currentTime';
332-
$this->assertXmlStringEqualsXmlString(
333-
$this->getExpectedLabelRequestXml($origCountryId, $destCountryId, $expectedRegionCode),
334-
$requestElement->asXML()
343+
344+
$expectedLabelRequest = $this->getExpectedLabelRequestXml(
345+
$origCountryId,
346+
$destCountryId,
347+
$expectedRegionCode,
348+
$isProductNameContainsSpecialChars
335349
);
350+
351+
$this->assertXmlStringEqualsXmlString($expectedLabelRequest, $requestElement->asXML());
336352
}
337353

338354
/**
@@ -351,7 +367,10 @@ public function requestToShipmentDataProvider(): array
351367
],
352368
[
353369
'DE', 'EU', 'DE'
354-
]
370+
],
371+
[
372+
'GB', 'EU', 'US', true
373+
],
355374
];
356375
}
357376

@@ -361,12 +380,14 @@ public function requestToShipmentDataProvider(): array
361380
* @param string $origCountryId
362381
* @param string $destCountryId
363382
* @param string $regionCode
383+
* @param bool $isProductNameContainsSpecialChars
364384
* @return string
365385
*/
366386
private function getExpectedLabelRequestXml(
367387
string $origCountryId,
368388
string $destCountryId,
369-
string $regionCode
389+
string $regionCode,
390+
bool $isProductNameContainsSpecialChars
370391
): string {
371392
$countryNames = [
372393
'US' => 'United States Of America',
@@ -387,6 +408,10 @@ private function getExpectedLabelRequestXml(
387408
$expectedRequestElement->Shipper->CountryName = $countryNames[$origCountryId];
388409
$expectedRequestElement->RegionCode = $regionCode;
389410

411+
if ($isProductNameContainsSpecialChars) {
412+
$expectedRequestElement->ShipmentDetails->Pieces->Piece->PieceContents = self::PRODUCT_NAME_SPECIAL_CHARS;
413+
}
414+
390415
return $expectedRequestElement->asXML();
391416
}
392417

0 commit comments

Comments
 (0)