88namespace Magento \Dhl \Model ;
99
1010use Magento \Framework \App \Config \ReinitableConfigInterface ;
11+ use Magento \Framework \App \ProductMetadataInterface ;
1112use Magento \Framework \DataObject ;
1213use Magento \Framework \HTTP \AsyncClient \HttpException ;
1314use Magento \Framework \HTTP \AsyncClient \HttpResponseDeferredInterface ;
@@ -48,6 +49,11 @@ class CarrierTest extends TestCase
4849 */
4950 private $ config ;
5051
52+ /**
53+ * @var ProductMetadataInterface
54+ */
55+ private $ productMetadata ;
56+
5157 /**
5258 * @var string
5359 */
@@ -62,6 +68,7 @@ protected function setUp(): void
6268 $ this ->dhlCarrier = $ objectManager ->get (Carrier::class);
6369 $ this ->httpClient = $ objectManager ->get (AsyncClientInterface::class);
6470 $ this ->config = $ objectManager ->get (ReinitableConfigInterface::class);
71+ $ this ->productMetadata = $ objectManager ->get (ProductMetadataInterface::class);
6572 $ this ->restoreCountry = $ this ->config ->getValue ('shipping/origin/country_id ' , 'store ' , 'default_store ' );
6673 }
6774
@@ -402,6 +409,7 @@ private function getExpectedLabelRequestXml(
402409 // phpcs:ignore Magento2.Functions.DiscouragedFunction
403410 $ expectedRequestElement = new ShippingElement (file_get_contents (__DIR__ . $ requestXmlPath ));
404411
412+ $ expectedRequestElement ->Request ->MetaData ->SoftwareVersion = $ this ->buildSoftwareVersion ();
405413 $ expectedRequestElement ->Consignee ->CountryCode = $ destCountryId ;
406414 $ expectedRequestElement ->Consignee ->CountryName = $ countryNames [$ destCountryId ];
407415 $ expectedRequestElement ->Shipper ->CountryCode = $ origCountryId ;
@@ -415,6 +423,16 @@ private function getExpectedLabelRequestXml(
415423 return $ expectedRequestElement ->asXML ();
416424 }
417425
426+ /**
427+ * Builds a string to be used as the request SoftwareVersion.
428+ *
429+ * @return string
430+ */
431+ private function buildSoftwareVersion (): string
432+ {
433+ return substr ($ this ->productMetadata ->getVersion (), 0 , 10 );
434+ }
435+
418436 /**
419437 * Tests that valid rates are returned when sending a quotes request.
420438 *
0 commit comments