8
8
namespace Magento \Dhl \Model ;
9
9
10
10
use Magento \Framework \App \Config \ReinitableConfigInterface ;
11
+ use Magento \Framework \App \ProductMetadataInterface ;
11
12
use Magento \Framework \DataObject ;
12
13
use Magento \Framework \HTTP \AsyncClient \HttpException ;
13
14
use Magento \Framework \HTTP \AsyncClient \HttpResponseDeferredInterface ;
@@ -48,6 +49,11 @@ class CarrierTest extends TestCase
48
49
*/
49
50
private $ config ;
50
51
52
+ /**
53
+ * @var ProductMetadataInterface
54
+ */
55
+ private $ productMetadata ;
56
+
51
57
/**
52
58
* @var string
53
59
*/
@@ -62,6 +68,7 @@ protected function setUp(): void
62
68
$ this ->dhlCarrier = $ objectManager ->get (Carrier::class);
63
69
$ this ->httpClient = $ objectManager ->get (AsyncClientInterface::class);
64
70
$ this ->config = $ objectManager ->get (ReinitableConfigInterface::class);
71
+ $ this ->productMetadata = $ objectManager ->get (ProductMetadataInterface::class);
65
72
$ this ->restoreCountry = $ this ->config ->getValue ('shipping/origin/country_id ' , 'store ' , 'default_store ' );
66
73
}
67
74
@@ -402,6 +409,7 @@ private function getExpectedLabelRequestXml(
402
409
// phpcs:ignore Magento2.Functions.DiscouragedFunction
403
410
$ expectedRequestElement = new ShippingElement (file_get_contents (__DIR__ . $ requestXmlPath ));
404
411
412
+ $ expectedRequestElement ->Request ->MetaData ->SoftwareVersion = $ this ->buildSoftwareVersion ();
405
413
$ expectedRequestElement ->Consignee ->CountryCode = $ destCountryId ;
406
414
$ expectedRequestElement ->Consignee ->CountryName = $ countryNames [$ destCountryId ];
407
415
$ expectedRequestElement ->Shipper ->CountryCode = $ origCountryId ;
@@ -415,6 +423,16 @@ private function getExpectedLabelRequestXml(
415
423
return $ expectedRequestElement ->asXML ();
416
424
}
417
425
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
+
418
436
/**
419
437
* Tests that valid rates are returned when sending a quotes request.
420
438
*
0 commit comments