@@ -447,13 +447,31 @@ public function testMapItemSetsExtensionAttributePriceForTaxCalculation(): void
447447 $ quoteDetailsItem ->method ('setDiscountAmount ' )->willReturnSelf ();
448448 $ quoteDetailsItem ->method ('setParentCode ' )->willReturnSelf ();
449449
450- $ extension = $ this ->getMockBuilder (QuoteDetailsItemExtensionInterface::class)
451- ->onlyMethods (['setPriceForTaxCalculation ' , 'getPriceForTaxCalculation ' ])
452- ->getMock ();
453- $ extension ->expects ($ this ->once ())
454- ->method ('setPriceForTaxCalculation ' )
455- ->with (9.99 )
456- ->willReturnSelf ();
450+ $ extension = new class implements \Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterface
451+ {
452+ /**
453+ * @var float|null
454+ */
455+ private $ price ;
456+
457+ /**
458+ * @param float|null $value
459+ * @return $this
460+ */
461+ public function setPriceForTaxCalculation ($ value )
462+ {
463+ $ this ->price = $ value ;
464+ return $ this ;
465+ }
466+
467+ /**
468+ * @return float|null
469+ */
470+ public function getPriceForTaxCalculation ()
471+ {
472+ return $ this ->price ;
473+ }
474+ };
457475
458476 $ quoteDetailsItem ->method ('getExtensionAttributes ' )->willReturn (null );
459477 $ quoteDetailsItem ->expects ($ this ->once ())->method ('setExtensionAttributes ' )->with ($ extension )->willReturnSelf ();
@@ -1282,9 +1300,31 @@ public function testConstructorFallsBackToObjectManagerForOptionalDependencies()
12821300 // Do not call getInstance() in unit context; no original OM to restore
12831301
12841302 $ extFactory = $ this ->createMock (QuoteDetailsItemExtensionInterfaceFactory::class);
1285- $ ext = $ this ->getMockBuilder (QuoteDetailsItemExtensionInterface::class)
1286- ->onlyMethods (['setPriceForTaxCalculation ' , 'getPriceForTaxCalculation ' ])
1287- ->getMock ();
1303+ $ ext = new class implements \Magento \Tax \Api \Data \QuoteDetailsItemExtensionInterface
1304+ {
1305+ /**
1306+ * @var float|null
1307+ */
1308+ private $ price ;
1309+
1310+ /**
1311+ * @param float|null $value
1312+ * @return $this
1313+ */
1314+ public function setPriceForTaxCalculation ($ value )
1315+ {
1316+ $ this ->price = $ value ;
1317+ return $ this ;
1318+ }
1319+
1320+ /**
1321+ * @return float|null
1322+ */
1323+ public function getPriceForTaxCalculation ()
1324+ {
1325+ return $ this ->price ;
1326+ }
1327+ };
12881328 $ extFactory ->method ('create ' )->willReturn ($ ext );
12891329
12901330 $ customerAccount = $ this ->createMock (CustomerAccountManagement::class);
@@ -1327,13 +1367,14 @@ public function testConstructorFallsBackToObjectManagerForOptionalDependencies()
13271367 $ method = $ ref ->getMethod ('setPriceForTaxCalculation ' );
13281368 $ method ->setAccessible (true );
13291369
1330- $ ext -> expects ( $ this -> once ())-> method ( ' setPriceForTaxCalculation ' )-> with ( 12.34 )-> willReturnSelf ();
1370+ // verify via reading back from stub after invocation
13311371
13321372 $ qdi = $ this ->createMock (QuoteDetailsItemInterface::class);
13331373 $ qdi ->method ('getExtensionAttributes ' )->willReturn (null );
13341374 $ qdi ->expects ($ this ->once ())->method ('setExtensionAttributes ' )->with ($ ext )->willReturnSelf ();
13351375
13361376 $ method ->invoke ($ sut , $ qdi , 12.34 );
1377+ $ this ->assertSame (12.34 , $ ext ->getPriceForTaxCalculation ());
13371378
13381379 // Verify CustomerAccountManagement from OM is used in populateAddressData default-billing path
13391380 $ billingMapped = $ this ->createMock (CustomerAddress::class);
0 commit comments